You post some nonsense code and don’t even post the code that you have actually compared it with. No one knows what you are actually doing.
Re-read my last post. The examples given by Steve and me are working. Steve’s example does work too but as mentioned just with constant incrementing periods ( 10, 20, 30 or 5, 10, 15, 20 etc).
So far for claiming things being far away from truth.
Have a nice day. I’m out of this thread… I do not want to waste more time with non-productive posts leading to no where.
EDIT:
This code
SetPositionSize( 1, spsShares );
period1 = 10;
period2 = 20;
period3 = 30;
period4 = 40;
period5 = 50;
for( i = 1; i < 6; i++ )
{
a_period = VarGet( "period" + i );
a_1 = Cross( H, Ma( C, a_period ) );
a_2 = (H - L) > Ref( H - L, -1 );
a_3 = L < Ref( L, -1 );
a_signal = a_1 AND a_2 AND a_3;
VarSet( "Buy" + i, a_signal );
}
Buy = Buy1 OR Buy2 OR Buy3 OR Buy4 OR Buy5;
Sell = 0;
Short = Cover = 0;
bars = 60; // exit after 60 bars
ApplyStop( stopTypeNBar, stopModeBars, bars, True );
outputs same results as this code
SetPositionSize( 1, spsShares );
period1 = 10;
period2 = 20;
period3 = 30;
period4 = 40;
period5 = 50;
a_2 = ( H - L ) > Ref( H - L, -1 );
a_3 = L < Ref( L, -1 );
Buy1 = Cross( H, Ma( C, period1 ) ) AND a_2 AND a_3;
Buy2 = Cross( H, Ma( C, period2 ) ) AND a_2 AND a_3;
Buy3 = Cross( H, Ma( C, period3 ) ) AND a_2 AND a_3;
Buy4 = Cross( H, Ma( C, period4 ) ) AND a_2 AND a_3;
Buy5 = Cross( H, Ma( C, period5 ) ) AND a_2 AND a_3;
Buy = Buy1 OR Buy2 OR Buy3 OR Buy4 OR Buy5;
Sell = 0;
Short = Cover = 0;
bars = 60; // exit after 60 bars
ApplyStop( stopTypeNBar, stopModeBars, bars, True );
Quod erat demonstrandum!