The question is about auto-trading, not backtesting.
I'm trying to execute orders on the last 30 seconds of the bar.
That's the code of my simple breakout strategy, maybe someone would find it useful, but now it doesn't work.
Code: Select all
[IntrabarOrderGeneration = True]
inputs: Price( Close ), Length(20), MAPeriod (100) ;
variables: var0( 0 ), var1( 0 ), var2 ( 0 ) ;
var0 = Lowest( Low, Length)[1] ;
var1 = Highest( High, Length)[1] ;
var2 = AverageFC( Price, MAPeriod ) ;
condition1 = (Time_s > 102930 and Time_s < 102959)
or (Time_s > 112930 and Time_s < 112959)
or (Time_s > 122930 and Time_s < 122959)
or (Time_s > 132930 and Time_s < 132959)
or (Time_s > 142930 and Time_s < 142959)
or (Time_s > 152930 and Time_s < 152959)
or (Time_s > 162930 and Time_s < 162959);
if condition1 then
Begin
if MarketPosition = 0 then
Begin
if Last > var2 and Last > var1 then
Buy ( "Long Breakout" ) next bar at market;
if Last < var2 and Last < var0 then
SellShort ( "Short Breakout" ) next bar at market;
End;
if MarketPosition <> 0 then
Begin
if Last < var2 then
Sell ( "Long Exit" ) next bar at market;
if Last > var2 then
BuyToCover ( "Short Exit" ) next bar at market;
End;
End;
Thank you!