Dear hunter,
Here is the following code:
Entry Long:
========
var
res:=false;
ema20:=EMA(C,20);
ema50:=EMA(C,50);
ema200:=EMA(C,200);
cross_20_200:=0;
cross_50_200:=0;
cross_20_50:=0;
end_var
cross_20_200:=BarsSince(CrossAbove(ema20,ema200));
cross_50_200:=BarsSince(CrossAbove(ema50,ema200));
cross_20_50:=BarsSince(CrossBelow(ema20,ema50));
if cross_20_200=-1 or cross_50_200=-1 or cross_20_50=-1 then
return false;
if CrossAbove(ema20,ema50) and
cross_20_50>0 and
cross_20_50<cross_20_200 and
cross_20_50<cross_50_200
then
res:=true;
return res;
Exit Long:
========
var
ema20:=EMA(c,20);
end_var
return Close<ema20 and Close\1\<ema20;
========
Besides, for the successful work of this strategy, it will be necessary to copy the attached BarsSince.tfn file to Alyuda Tradecision\Funct catalogue.
Sincerely,
Tradecision Support Team
Hello Support,
I would appreciate your help in building a strategy that I have tried to explain in the best possible way.
Strategy: 20 EMA & 50 EMA
Entry Long: 20 EMA crosses 200 EMA up from below,
50 EMA crosses 200 EMA up from below…
Then, 20 EMA goes below 50 EMA and comes back above 50 EMA, you enter long
Exit Long: 2 closes below 20 EMA
What we are trying to do is longs are not entered the first time when 20 EMA & 50 EMA crosses above 200 EMA but when 20 EMA crosses below 50 EMA and then goes back above it, it should trigger a buy.
Thanks in advance.