Need AFL code for a simple intra day stratergy

#1
Experts/Seniors, Please code the afl for the following simple intra day stratergy.

Conditions:

For Buy : Two successive candles should close above ema 34, and when the third or the subsequent candle breaks the high of the two candles initiate Buy

For Sell: Two successive candles should close below ema 34 and when the third or subsequent candle breach the low of the two candles initiate Short

For Stop loss : Recent low for Buy calls, Recent high for the Sell calls.

Thanks in advance for the help.
 

mastermind007

Well-Known Member
#2
Experts/Seniors, Please code the afl for the following simple intra day stratergy.

Conditions:

For Buy : Two successive candles should close above ema 34, and when the third or the subsequent candle breaks the high of the two candles initiate Buy

For Sell: Two successive candles should close below ema 34 and when the third or subsequent candle breach the low of the two candles initiate Short

For Stop loss : Recent low for Buy calls, Recent high for the Sell calls.

Thanks in advance for the help.

I could not understand your SL rule fully, so I am considering Low and High over past 5 candles and then staying just off that by 1%.

Also, there is no logic about target, which needs to be added.


Code:
ema34 = EMA(Close, 34);

BuyCond = Cross(Close, ema34);
Buy = Ref(BuyCond, -2) == 1 AND Ref(BuyCond, -1) == 1 AND Close > HHV(High, 2);
LongStop = Close <= (LLV(Low, 5) * 0.99);
Sell = LongStop ; // AND LONG Target condition 

ShortCond = Cross(ema34,Close);
Buy = Ref(ShortCond, -2) == 1 AND Ref(ShortCond, -1) == 1 AND Close < LLV(Low, 2);
ShortStop = Close >= (HHV(High, 5) * 1.01);
Cover = ShortStop  ; // AND SHORT Target condition
 

Similar threads