changes need for this AFL code

#1
Dear Coders .. given code in candle format ., i dont want basic candle stick so pls remove it and add HEIKENASHI candle for breakout trade and also pls make selecting number of candles in parameter ... each n every time i have to edit this code to give input to select which number of candle i need ...,, so pls code me accordingly so that i can select number of candle in parameter ELSE ADD TIME OF CANDLE SO THAT I CAN CHOOSE CANDLE BY ITS TIME IN PARAMETER ...


CODE :-


_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();




x=BarsSince(Day()!=Ref(Day(),-1))+1;
y=ValueWhen(x==9,H);

( THIS CANDLE NUMBER SELECTION Y & Z SHOULD BE IN PARAMETER SO THAT I CAN SELECT 9 th HA CANDLE OR 6th WHICH EVER I NEED IN PARAMETER SECTION
ELSE ADD TIME OF CANDLE SO THAT I CAN CHOOSE CANDLE BY ITS TIME IN PARAMETER ...)

z=ValueWhen(x==9,L);
Buy=x>9 AND Cross(H,y);
Short=x>9 AND Cross(z,L);


PlotOHLC ( O, H, L, C, "", IIf(C>O,colorBrightGreen,colorRed), styleCandle);
Plot( y, "", colorRed, styleLine | styleThick );
Plot( z, "", colorGreen, styleLine | styleThick );
il=L-0.05;
ih=H+0.05;

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0, iL, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0,iL, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorLightBlue, 0,iL, Offset=-45);
PlotShapes(IIf(Short , shapeSquare, shapeNone),colorRed, 0, iH, Offset=40);
PlotShapes(IIf(Short , shapeSquare, shapeNone),colorRed, 0,iH, Offset=50);
PlotShapes(IIf(Short , shapeDownArrow, shapeNone),colorDarkRed, 0,iH, Offset=-45);
 
Last edited:

rvlv

Active Member
#3
hi bluesquare
i can remove normal candlesticks and add heikin ashi
for the other conditions you need help from experts
check it on 5 min chart
see the image on banknifty futures
1652720652109.png

===================================================


//https://www.traderji.com/community/threads/changes-need-for-this-afl-code.111245/
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
//===========================================
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorBRIGHTgreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );



x=BarsSince(Day()!=Ref(Day(),-1))+1;
y=ValueWhen(x==9,H);

//( THIS CANDLE NUMBER SELECTION Y & Z SHOULD BE IN PARAMETER SO THAT I CAN SELECT 9 th HA CANDLE OR 6th WHICH EVER I NEED IN PARAMETER SECTION
//ELSE ADD TIME OF CANDLE SO THAT I CAN CHOOSE CANDLE BY ITS TIME IN PARAMETER ...)

z=ValueWhen(x==9,L);
Buy=x>9 AND Cross(H,y);
Short=x>9 AND Cross(z,L);


//PlotOHLC ( O, H, L, C, "", IIf(C>O,colorBrightGreen,colorRed), styleCandle);
Plot( y, "", colorRed, styleLine | styleThick );
Plot( z, "", colorGreen, styleLine | styleThick );
il=L-0.05;
ih=H+0.05;

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0, iL, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0,iL, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorLightBlue, 0,iL, Offset=-45);
PlotShapes(IIf(Short , shapeSquare, shapeNone),colorRed, 0, iH, Offset=40);
PlotShapes(IIf(Short , shapeSquare, shapeNone),colorRed, 0,iH, Offset=50);
PlotShapes(IIf(Short , shapeDownArrow, shapeNone),colorDarkRed, 0,iH, Offset=-45);