I am trying to create a Long only strategy when these conditions are confirmed.
1. Close cross Above EMA(Fast)
2. EMA(Fast)> EMA(Medium)
3.EMA(Medium)>EMA(Slow)
Indeed, it is simple strategy but I cannot understand why it open position when these condition are not confirmed. When I am looking at the chart, it becomes clear that the strategy open and close position when the above condition and not confirmed. I have include below a part of the code. If you need the hole code let me know.
Thanks
if (EMA(Fast)[0] > EMA(Medium)[0])
{
Variable0=1;
Variable1=0;
}
if(EMA(Medium)[0]>EMA(Slow)[0])
{
Variable2=1;
Variable3=0;
}
if (CrossAbove(Close, EMA(Fast), 1))
{
Variable4 = 1;
Variable5 = 0;
}
if(Variable0==1 && Variable2==1 && Variable4==1)
{
EnterLong(DefaultQuantity, "");
}

. Have a look at the attached output file and at the code below.
Comment