I get very confused with the signal when the marketing position is not 1 or -1..i.e. with flat position, don't understand why the line after else goes like
Code: Select all
Sell ( "AtrLX-eb" ) next bar at High - var0 stop
I am trying to use this signal to exit in my HSI trading algo, and it always cause the buy and sell to happen within the same bar.
Hope someone experienced with this signal can give me some guidance.
Thanks
The original code source is here:
Code: Select all
[IntrabarOrderGeneration = false]
inputs: ATRLength( 10 ), NumATRs( 3 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = AvgTrueRange( ATRLength ) * NumATRs ;
var1 = MarketPosition ;
if var1 = 1 then
begin
condition1 = var1[1] <> 1 or High > var2 ;
if condition1 then var2 = High ;
Sell ( "AtrLX" ) next bar at var2 - var0 stop ;
end
else
Sell ( "AtrLX-eb" ) next bar at High - var0 stop ;