Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Thinkscript Strategies not executing orders immediately
Question, on your strategy you are buying and selling exactly at the point your condition is met, which I have not been able to do. as far as the price are you wanting it to show on the chart?
Can you help answer these questions from other members on NexusFi?
I believe you just adapt the trigger for the order as the price for the order as well (in most cases at least). For example, simply put the price in the addorder function as the EMA, pivot point, etc., so it will backtest correctly as if you bought/sold as soon as the price=EMA/pivot point etc (or use EMA+X if you want to wait for it to cross fully by X). You can even use if/then statements if necessary.. you're not limited to close/high/low/hlc3 etc.
I hope this is accurate, when I changed to sell on high . it doubled my profits. Just wish we could automate with TOS, so we could really test our strategies
Question how do you set up your strategy to buy on Ask and Sell on Bid. If we could ever automate this is what would be needed to use in trading after hours. Least unless just open or close price worked. When you state open or close, does that make it a Limit Order?
You wouldn't want to set the price part of the AddOrder function to "high" unless the high of the bar is where you would actually buy/sell if you were actively trading it based on the strategy's signals. If you plan to live trade it by setting a limit order at an EMA or pivot point, for example, and wanted to backtest to see the efficacy, you'd set the "price" part of the addorder function to the EMA or pivot point. You are not making a limit order or market order for the strategy, it doesn't work that way... all you're doing is telling the AddOrder function what price to assume you were able to buy/sell at when it is backtesting for you. If you put "100" in there, it will it will pretend like every time the addorder function activated you were able to buy/sell at $100, regardless of if that's even possible if you were trading it in real life. If you want to see if your strategy is working correctly in your backtest and providing accurate data, you have to go through all the buy/sell orders and verify that they are buying/selling at the correct price that you intended to set, otherwise you'll get garbage and not realize it.
Were you able to figure out the reason it was waiting a few bars?
I'm having a very similar issue. I have a pretty simple strategy with addorder functions that don't involve offsets at all. When I backtest it over the last 30 days, before June 26th it delays executing the addorder by 1 extra bar (it buys/sells 2 bars after the condition is met), but after that date it operates normally (buys/sells the bar after the condition is met).
I have had similar issues, in it waiting 2 bars
Question how wold I bring the current close Nasdaq into my script. TOS shows how to chart a comparison, I just want to get the close and have it trigger a if/then
Ok, but what happens when your condition is "volume>volume[1]" and you want to buy or sell when the current bar volume crosses above the previous volume bar. In that case you don't have any EMA or Pivot as reference. I want to print that price when that condition is triggered. Is there a way to print that price on the strategy?
It's just "close("symbol")". So you could say, for example, "def signal = if close("NDX") > close("NDX")[1] then 1 else 0;", then use signal to trigger a buy if you wanted.
That's trickier and I don't know how you could do that exactly (I'm sure there's a way, I am just not experienced enough to know it). In live trading of course it would be easier, and for backtesting you could get closer to the real price you would be buying at by using hlc3 or hl2 instead of just close or open, but it still obviously wouldn't be perfect.