Hi, could somebody please explain what the following lines of coding mean:
if not longonmarket and buyc2 then
if range>SignalLargerThan*pointsize Then
buy lotsize contract at high-(range*.5) stop
and
if not shortonmarket and sellc2 then
if range>SignalLargerThan*pointsize Then
sellshort lotsize contract at low+(range*.5) stop
else
I think i get the most of it it’s just these parts i don’t understand… buy lotsize contract at high-(range*.5) stop
sellshort lotsize contract at low+(range*.5) stop
If i change the (range*.5) to (range*.0) i get different results… I’m trying to get my head around exactly how the code is executing trades on a backtest.
RANGE*0.5 is just a variable offset to enter a trade. You can write a fixe4d value, such as 20*PipSize.
It means that it will BUY at HIGH – x or SELLSHORT at LOW + x.
You can use any expression of your choice, could be ATR or any other valid offset.
Thanks for your response
Does this mean it creates a market order + x or – x from the close of the previous candle? And the x value is however much I want the offset to be?
so if I don’t want an offset and set it to .0 will the trades be executed immediately?
Yes, 0 will remove the offest.
The offeset is based on the RANGE of the candle, so it is not fixed.
Ok thanks. In this case what would the relationship be between the range of the candle and where the market order gets placed?
is it based on the range of the candle which produces the signal?
I have the: if range>SignalLargerThan*pointsize set to 0 in variable optimisation
is it based on the range of the candle which produces the signal? Yes
what would the relationship be between the range of the candle and where the market order gets placed? It’s the multiplier x.x, be it 0 or 0.5
If SignalLargerThan is set to 0, then the condition IF RANGE >… will always be true.