I realize that when converting a strategy into a conditional order it is necessary to offset the strategy by one in the conditional order (so the conditional buy order looks at the close of the last candle for the trigger and executes at the open of the next candle, just like the strategy back-test does).
So assume the strategy for back-testing I have is this:
def s = StochasticFull();
def buy = s<10 and close<close[1];
plot z = buy;
AddOrder(OrderType.BUY_TO_OPEN, buy, open[-1], 100);
I tried to convert that to a conditional order:
def s = StochasticFull();
def buy = s<10 and close<close[1];
plot z = buy;
This conditional order triggers "before" the last candle has closed (thus not matching the results from the back-test).
But to make the conditional order actually execute at the same point as the strategy I read you must add an offset of 1. The TOS Conditional Wizard to add the offset adds "from 1 bars ago" - but when I add that to my conditional order (which is not built from the Wizard) I get a red error message.
My question is: Can I accomplish the necessary offset of one bar by using the following?:
def s = StochasticFull();
def buy = s[1]<10 and close[1]<close[2];
plot z = buy;
Would adding the [1] to s and close (an offset back additional one bar) cause the conditional buy order to trigger at the same point as the strategy back-testing?
So assume the strategy for back-testing I have is this:
def s = StochasticFull();
def buy = s<10 and close<close[1];
plot z = buy;
AddOrder(OrderType.BUY_TO_OPEN, buy, open[-1], 100);
I tried to convert that to a conditional order:
def s = StochasticFull();
def buy = s<10 and close<close[1];
plot z = buy;
This conditional order triggers "before" the last candle has closed (thus not matching the results from the back-test).
But to make the conditional order actually execute at the same point as the strategy I read you must add an offset of 1. The TOS Conditional Wizard to add the offset adds "from 1 bars ago" - but when I add that to my conditional order (which is not built from the Wizard) I get a red error message.
My question is: Can I accomplish the necessary offset of one bar by using the following?:
def s = StochasticFull();
def buy = s[1]<10 and close[1]<close[2];
plot z = buy;
Would adding the [1] to s and close (an offset back additional one bar) cause the conditional buy order to trigger at the same point as the strategy back-testing?
Last edited: