Hi,
The code I got questions about is in the following picture:
function run()
{
BarPeriod = 240;
StartDate = 2003;
EndDate = 2012;
set(PARAMETERS);
var *Price = series(price());
var *LP5 = series (LowPass(Price,5));
var *LP10 = series(LowPass(Price, optimize(10,6,20)));
var *RSI10 = series(RSI(Price,10));
Stop = optimize(5,1,10) *ATR(30);
static int crossed = 0;
if(crossOver(LP5,LP10))
crossed = 3;
else if (crossUnder(LP5,LP10))
crossed = -3;
if(crossed > 0 && crossOver(RSI10, 50))
{
enterLong();
crossed = 0;
}
else if(crossed < 0 && crossUnder(RSI10, 50))
{
enterShort();
crossed = 0;
}
else crossed -= sign(crossed);
plot ("RSI", RSI10[0], NEW, BLUE);
}
First off, I didn't create this strategy. At Babypips, a guy called LiftOff did the first version of the strategy, and then JCL helped him with the version I linked above (correct me if I'm wrong).
To the questions:
Why do you use NumYears
and StartDate?
The manual says "Number of years of the simulation if no StartDate or EndDate is given (default: 6 years)."
But in the code, there are both?
And if anyone please could explain the use of static int? And why we give crossed the value 3/-3? Why not 1 or 2 instead?
Thanks in advance!
Ibra