afl code help

#1
Hi friends,

I trade only price action no any indicator i want help for afl code for my trading idea.

i trade on below assumption.

in intraday trade 30 min chart

dont trade on first candle

If first candle is close green and second candle break high of first candle then buy and stop loss is below first green candle low -2 points target is fixed 50 points for nifty.

If second candle not hit target or stoploss then stoploss trail from first candle low to second candle low.

If first candle is close red and second candle break low of first candle then sell and stop loss is above first red candle high +2 points target is fixed 50 points for nifty.

If second candle not hit target or stoploss then stoploss trail from first candle high to second candle high +2 points.

Please hlep me for code these idea in afl.
 

rvlv

Active Member
#2
hi

here is afl code-not yet perfected.
DONT USE IT-OBSERVE IT FIRST.

I dont have intraday data.
ALSO I could not define first candle. it is is important.
but as i see in intraday trades, mkt goes up,falls,then goes down.
the initial first direction is not right often.
one of the experts can help to get it right.

my point
there is a ma50 line.
if price is above ma50line,try only long trades.
if price is below ma50,try only short trades.
price above ma50,means at least 3 bars must be above ma50 line.
------------------
HTML:
//http://www.traderji.com/algo-automated-trading/96596-afl-code-help.html
/*

in intraday trade 30 Min chart

dont trade on first candle

if first candle is Close green AND Second candle break High of first candle then Buy AND stop loss is below first green candle Low -2 points target is fixed 50 points for nifty.

if Second candle NOT hit target OR stoploss then stoploss trail from first candle Low to Second candle Low. 

if first candle is Close red AND Second candle break Low of first candle then Sell AND stop loss is above first red candle High +2 points target is fixed 50 points for nifty.

if Second candle NOT hit target OR stoploss then stoploss trail from first candle High to Second candle High +2 points. 

Please hlep me for code these idea in afl.
*/
Buy = Ref(C,-1)>Ref(O,-1) AND Cross(H,Ref(H,-1));
longstop =(LLV(L,2)-2);
tgt = Buy +50 ;
Sell =Ref(C,-1)<Ref(O,-1)  AND Cross(Ref(L,-1),L);
Shortstop =HHV(H,2)+2 ;
Plot(Shortstop,"shortstop",colorCustom12,styleLine);
barcolor =IIf(C>O,colorGreen,colorRed);
Plot(Close,"close",barcolor,styleBar,styleThick);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;  
 PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );  
Plot(Longstop,"longstop",colorCustom12,styleDashed);
//Plot (s,"Supp",colorRed,8+16);//19
MA50 =MA(C,50);
MA50color = IIf(C>MA50,colorGreen,colorRed);
Plot(MA50,"ma50",MA50color,styleThick);
PS: This is a small effort-instead of doing nothing,try to begin doing something though it may be not perfect.The expert who sees it,would help you soon,if he has free time.