Pls correct this simple AFL -Need help.

#1
Hello Friends,

I am new to AFL coding and facing problem in this AFL.
First what I need:-
I want that:

a. a circle or star in GREEN should appear BELOW the PRICE CANDLE when
RSI(9) goes BELOW 30.

b. A circle or Star in RED should appear ABOVE the price candle when RSI(9) goes ABOVE 70.

I want these symbols in PRICE CHART not in a separate window, I also don't want to show rsi line, just these two symbols.

Now this is what I did in my AFL:-

s=RSI(9);
C=IIf(s>70, colorRed, IIf(s<30, colorGreen, colorBlue));
Cond=IIf(s>70, T, IIf(s<30, B, A);
pos=IIf(Cond=T, shapePositionAbove, (IIf(Cond=B, ShapePositionBelow));
PlotShapes(shapeCircle, C, pos);


But this is giving me all sort of problems with one error after another.
Pls help me by rectifying this coding.

Thanks
Sanjeev Bhatia
 
#2
Hello Friends,

I am new to AFL coding and facing problem in this AFL.
First what I need:-
I want that:

a. a circle or star in GREEN should appear BELOW the PRICE CANDLE when
RSI(9) goes BELOW 30.

b. A circle or Star in RED should appear ABOVE the price candle when RSI(9) goes ABOVE 70.

I want these symbols in PRICE CHART not in a separate window, I also don't want to show rsi line, just these two symbols.

Now this is what I did in my AFL:-

s=RSI(9);
C=IIf(s>70, colorRed, IIf(s<30, colorGreen, colorBlue));
Cond=IIf(s>70, T, IIf(s<30, B, A);
pos=IIf(Cond=T, shapePositionAbove, (IIf(Cond=B, ShapePositionBelow));
PlotShapes(shapeCircle, C, pos);


But this is giving me all sort of problems with one error after another.
Pls help me by rectifying this coding.

Thanks
Sanjeev Bhatia
Hi sanjeev,
now try this, you can take off from here

Code:
Clr=IIf(RSI(9)>70, colorRed, IIf(RSI(9)<30, colorGreen, colorBlue));
gC = IIf(RSI(9)>70, True, False);
rC = IIf(RSI(9)<30, True, False);
PlotShapes(rC*shapeSmallCircle, Clr, 0,L,-10);
PlotShapes(gC*shapeSmallCircle, Clr, 0,H,10);
PlotOHLC(O,H,L,C,"",colorRed,styleBar);
regards
srivastava
 
#3
Hi sanjeev,
now try this, you can take off from here

Code:
Clr=IIf(RSI(9)>70, colorRed, IIf(RSI(9)<30, colorGreen, colorBlue));
gC = IIf(RSI(9)>70, True, False);
rC = IIf(RSI(9)<30, True, False);
PlotShapes(rC*shapeSmallCircle, Clr, 0,L,-10);
PlotShapes(gC*shapeSmallCircle, Clr, 0,H,10);
PlotOHLC(O,H,L,C,"",colorRed,styleBar);
regards
srivastava
Hi Ashutosh,

Thanks a lot. Actually Bhavani Shankar (Tradetogain) has given a much simpler and easier code which I am sharing below:-
cond1=cross(rsi(9),70);
cond2=cross(30,rsi(9));

PlotShapes(IIf(cond2,shapeCircle,shapeNone) ,colorgreen,0,Low, Offset=-25);
PlotShapes(IIf(cond1 ,shapeCircle,shapeNone),colorred,0,High, Offset=25);

This is working perfectly.

Thanks a lot.

Sanjeev Bhatia
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?