AddOrder function - schedule buy or close during current bar.

T

tplowe56

New member
I have strategy that uses ADX, MACD, and Double Smoothed Stochastics to pick entries long and short. The audible and printed "alert" are executed at the exact time of the occurrence (when all 3 parameters are met). TheAddOrder function on the other hand appears to default to executing at the next bar, and can be adjusted to High,Low,Close,Open, of the previous bar, if coded like this:

def orderprice = low[1]; Executes a buy at the low of the previous bar (the bar in which the signal was generated) This can lead to back testing which is not accurate.

Is it possible to code the AddOrder function to execute the order at exactly the same time & price as when the alert is issued? Sorry if this has been discussed but I could not find any reference to this.
 
STB

STB

Member
Hi tplowe, did you ever find an answer to this I am also trying to figure out how to do this? Thanks for any info.
 
T

tplowe56

New member
Sorry, as you can see no one has responded. I think there is no solution until TOS changes their code.
 
STB

STB

Member
I think there must be away, I was watching this guys video and his add order appears intrabar, skip to 4:30 minutes into the video and you will see the order entry appear.
 
STB

STB

Member
Thanks Agronis, I’ve done conditional orders in the past, but watching the above video it looks like he has a strategy that is being executed during the candle creation and I can not duplicate it. 😤
 
T

tplowe56

New member
I tried to create a conditional order that used my strategy (which uses tick based charts), but conditional order system does not allow use of ticks.
 
B

barbaros

Member
I find that if you use -1 instead of +1 when referencing the condition in addOrder function, it will look ahead to execute. So if you want to execute in the next bar, you would use close[-1] > low[-1]. I can't seem to figure out a way to open and close at the same bar when a specific target is reached though.
 
Top