I have a question about thinkcript AddOrder() function. Maybe you can help with this. Just learning coding in TOS. I have a signal in a strategy as follows:
where LongEnt is defined. The above is working properly. However, I am looking to actually only have a signal if have the entry of the next bar takes out the high of the current bar.
I am trying an if statement but can’t get it to work. This is what I tried.
Any help would be great as I am trying to learn.
Code:
input barexit = 2;
def LongExt= LongEnt from barexit bars ago;
AddOrder(OrderType.BUY_TO_OPEN, LongEnt, open, TradeSize);
AddOrder(OrderType.SELL_TO_CLOSE, LongExt, open, TradeSize);
where LongEnt is defined. The above is working properly. However, I am looking to actually only have a signal if have the entry of the next bar takes out the high of the current bar.
I am trying an if statement but can’t get it to work. This is what I tried.
Code:
AddOrder(If(high[-1] > high, (OrderType.BUY_TO_OPEN, LongEnt, high, TradeSize), null);
Any help would be great as I am trying to learn.