Hi Mr Hulk,
I need some help, have found a strategy for nifty trading with a 95% hit ratio till now on the back test reports, have completed some part of the afl but getting stuck in the 2nd condition, as the 1st condition is complete.........
This main strategy of this afl is, we take eod pivot and resistance 1 and support 1 lines plotted on the charts, then on realtime basis, on 15 min charts, we wait for the candle to touch any of the 3 lines which are plotted on the chart........
If the candle of 15 mins is more then 20 points then we take that candle high low close and generate the intra day pivots..... If the candle doesnt have 20 points after touching the lines then we take the back 3 candles, and which ever candle has a higher candle more then the touching candle on the line.........
I am able to plot the 3 lines on chart, but the second condition i am not able to fullfill can you help me create a afl for the same
Here is the code for 3 lines
_SECTION_BEGIN("Price ADX");
function PercentR( periods )
{ return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods
) ); }
range = Param("Periods", 14, 2, 200, 1 );
ADX(range);
PDI(range) ;
MDI(range);
Plot( C, "Close", IIf( PDI(range) > MDI(range), ParamColor("Up Color",
colorLime), ParamColor("Down Color", colorRed ) ), styleCandle|styleThick,styleNoTitle |
ParamStyle("Style") | GetPriceStyle() );
Bull_Trend=(PercentR( Param("Periods", 14, 2, 100 ) )> -30);
Bear_Trend=(PercentR( Param("Periods", 14, 2, 100 ) )< -70);
_SECTION_END();
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, _DEFAULT_NAME(), colorBlack , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("pivots mw");
SetChartBkColor(2) ;
k=IIf(ParamList("select type","daily|next day")=="daily",-1,0);
k1=-1;
TimeFrameSet(inDaily);
day_h= LastValue(Ref(H,K));
day_l= LastValue(Ref(L,K));
day_c= LastValue(Ref(C,K));
TimeFrameRestore();
/*--------------------------------------*/
// day
DH=Day_h;
DL=Day_L;
DC=Day_C;
// DAY PIVOT Calculation
pd = ( DH+ DL + DC )/3;
sd1 = (2*pd)-DH;
rd1 = (2*pd)-DL;
dp=pd;
ppl = ParamToggle("Plot Pivot Levels","Off|On",1);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = Param("slide all",33,-1000,1000,1);
{
if(ppl==1) {
Plot(pd,"",colorGold,styleLine|styleDashed|styleNoRescale);
Plot(sd1,"",ColorRGB(73,123,201),styleDashed|styleNoRescale);
Plot(rd1,"",ColorRGB(150,60,39),styleDashed|styleNoRescale);
i=1;
PlotText(" Pivot = " + WriteVal(pd,fraction), LastValue(BarIndex())-(numbars/Hts), dp, colorGold);
PlotText(" R1 = " + WriteVal(rd1,fraction), LastValue(BarIndex())-(numbars/Hts), rd1 , ColorRGB(150,60,39));
PlotText(" S1 = " + WriteVal(sd1,fraction), LastValue(BarIndex())-(numbars/Hts), sd1 , ColorRGB(73,123,201));
}}
//--end----------------------------------------------------------------------------
_SECTION_END();
/*--------------------------------------*/
_SECTION_BEGIN("Display");
Display= ParamToggle("Display","Off|On",1);
if(Display==1)
{
x=Param("xposn",0,0,1000,1);
y=Param("yposn",569,0,1000,1);
GfxSetBkColor(ColorRGB(23,25,23));
GfxSelectFont( "Times New Roman",9,500, True);
GfxSetTextColor( colorGrey40);
GfxTextOut("RSI: "+WriteVal(RSI(14),1.0)+" | MACD: "+WriteVal(MACD(),1.2)+" | F(Ema): "+NumToStr(EMA(C,5),1.2)+" |9(Ema): "+NumToStr(EMA(C,9),1.2)+"
|15(EMA): "+NumToStr(EMA(C,15),1.2)+" |30(EMA): "+NumToStr(EMA(C,30),1.2)+" |50(EMA): "+NumToStr (EMA(C,50),1.2), x, y );
cx=Param("cxposn",537,0,1000,1);
cy=Param("cyposn",12,0,1000,1);
GfxSetBkColor(ColorRGB(23,25,23));
GfxSelectFont( "Bodoni MT",14,50, False);
GfxSetTextColor( colorWhite);
GfxTextOut("LTP: "+C+" ", cx, cy );
_SECTION_END();}
_SECTION_BEGIN("Background Color");
BKswitch = ParamToggle("Background Color","On,Off");
OUTcolor = ParamColor("Outer Panel Color",ColorRGB(25,25,25));
INUPcolor = ParamColor("Inner Panel Upper",ColorRGB(23,25,23));
INDNcolor = ParamColor("Inner Panel Lower",ColorRGB(23,25,23));
TitleColor = ParamColor("Title Color ",ColorRGB(23,25,23));
if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
_SECTION_END();
Please help me