Hi
I want to have 10 bar of delay since entry for my ApplyStop to start to work, but I cant get the "validFrom" trigger to work, my code are;
initial = 100000;
SetOption( "InitialEquity", initial );
lev1 = 1;
lev = 1 / lev1 ;
MarginDeposit = 100000 * lev;
OptimizerSetEngine( "cmae" );
OptimizerSetOption( "Runs", 5 ); // 5 är strandard
SetOption( "PriceBoundChecking", False );
SetOption( "ActivateStopsImmediately", True );
SetOption( "AllowSameBarExit", True );
SetPositionSize( 0.01, spsShares );
p_trend = Optimize( "2", 75, 1, 100, 5 );
p_trend_L = p_trend + Optimize( "3", 5000, 1, 10000, 100 );
trend = DEMA( C, p_trend );
trend_L = DEMA( C, p_trend_L );
SetTradeDelays( 0, 0, 0, 0 );
Buy =
H > Ref( HHV( H, 10 ), -1 ) AND
O < Ref( HHV( H, 10 ), -1 ) AND
O > trend AND
trend > trend_L AND
trend > Ref( trend, -1 ) AND
trend_L > Ref( trend_L, -1 );
BuyPrice = Ref( HHV( H, 10 ), -1 ) ;
Sell = 0;
short =
L < Ref( LLV( L, 10 ), -1 ) AND
O > Ref( LLV( L, 10 ), -1 ) AND
O < trend AND
trend < trend_L AND
trend < Ref( trend, -1 ) AND
trend_L < Ref( trend_L, -1 );
shortPrice = Ref( LLV( L, 10 ), -1 ) ;
Cover = 0;
SL_m = 0.001;
tp_m = SL_m ;
ApplyStop( stopTypeProfit, stopModePoint, tp_m, 1, False, 10, 10 );
ApplyStop( stopTypeLoss, stopModePoint, SL_m , 1, False, 10 , 10 );
So I should have at least 10 bars before any StopLoss starts to work , but that are not the case, it gets activated directly as can be seen in the results;
Any ideas where to start to fault find?