► ZERODHA - Open Instant Account | ► ProStocks - Unlimited Trading @ ₹899 |
► ZERODHA - Open Instant Account |
► ProStocks - Unlimited Trading @ ₹899 |
_SECTION_BEGIN("Pivot Points between two MAs");
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();
_SECTION_BEGIN("MA");
MA9 = MA(C,9);
MA20 = EMA(MA( C, 9),20 );
Plot( MA9, "MA9", colorRed, styleline );
Plot( MA20, "MA20", colorbluegrey, styleline );
CrossUp = Cross(MA9,MA20);
CrossDn = Cross(MA20,MA9);
//Modified original code available at below location for the requirement
//https://www.traderji.com/community/threads/trading-with-obv-for-beginners-only.104279/
isemapvts = ParamToggle("Want Pivots ", "No|Yes", 1) ;
periodtype = 20;//max MA20 period
//Hi = HHV(H,20);
//Lo = LLV(L,20);
PeriodUp = MA9>MA20;
Hi = HHV(H, PeriodUp);
Lo = LLV(L,PeriodUp);
B1 = Cross(H,Ref(Hi,-1));
S1 = Cross(Ref(Lo,-1),L);
B1 = ExRem(B1,S1); S1 = ExRem(S1,B1);
UP1 = Flip(B1,S1); DN1 = Flip(S1,B1);
ro = ParamField("Open", 0) ;
rh = ParamField("High", 1) ;
rl = ParamField("Low", 2) ;
rc = ParamField("Close", 3) ;
ismph = H-H ;
ismpl = L-L ;
if (isemapvts)
{
if(periodtype)
{
upcross = b1;
downcross = s1;
}
bi = BarIndex() ;
mphbar = HighestSinceBars(upcross, rH) ;
mplbar = LowestSinceBars(downcross, rL) ;
mphbi = ValueWhen(downcross, bi, 0) - ValueWhen(downcross, mphbar, 0) ;
ismph = mphbi == bi ;
mplbi = ValueWhen(upCross, bi, 0) - ValueWhen(upCross, mplbar, 0) ;
ismpl = mplbi == bi ;
ismph = IIf(downCross AND mphbar == 0, True, ismph) ;
ismpl = IIf(upcross AND mplbar == 0, True, ismpl) ;
}
showpvtHiLoline = ParamToggle("Show Pvt Hi/Lo line", "No|Yes", 1) ;
if (showpvtHiLoline)
{
bi = Cum(1)-1;
cbar = Param("cbar",2,2,50,1);
P1 = ismph;//GetTop(Ch);
V1 = ismpl;//GetValley(Ch);
P1 = IIf(P1,IIf(ValueWhen(P1,bi,2) < ValueWhen(V1,bi),P1,IIf(ValueWhen(P1,H,2) > H,False,P1)),P1);
P1 = IIf(P1 AND ValueWhen(P1,bi,0) > bi,IIf(ValueWhen(P1,bi,0) < ValueWhen(V1,bi,0),IIf(ValueWhen(P1,H,0) >= H,False,P1),P1),P1);
V1 = IIf(V1,IIf(ValueWhen(V1,bi,2) < ValueWhen(P1,bi),V1,IIf(ValueWhen(V1,L,2)<L,False, V1)),V1);
V1 = IIf(V1 AND ValueWhen(V1,bi,0) > bi ,IIf(ValueWhen(V1,bi,0) < ValueWhen(P1,bi,0),IIf(ValueWhen(V1,L,0) <= L, False,V1),V1),V1);
RF=ValueWhen(P1,H);
SF=ValueWhen(V1,L);
RF1 = IIf(RF AND BarsSince(P1) <=cbar,RF,Null);
SF1 = IIf(SF AND BarsSince(V1) <=cbar,SF,Null);
Plot(RF1,"",colorBlue,styleDots | styleNoLine|styleNoRescale);
Plot(SF1,"",colorBlue,styleDots | styleNoLine|styleNoRescale);
Plot(RF,"Resist",colorOrange,40+16+2048);//2048 is stylenorescale
Plot(SF,"Suprt",colorbrightGreen,40+16+2048);
PlotText("Peak "+ WriteVal(RF,1.2), BarCount+2, SelectedValue(RF),colororange,colorDefault,5);
PlotText("Valley "+ WriteVal(SF,1.2), BarCount+2, SelectedValue(SF),colorbrightgreen,colordefault,5);
}
_SECTION_END();
_SECTION_BEGIN("Pivot Points between two MAs");
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();
_SECTION_BEGIN("MA");
MA9 = MA(C,9);
MA20 = EMA(MA( C, 9),20 );
Plot( MA9, "MA9", colorRed, styleline );
Plot( MA20, "MA20", colorbluegrey, styleline );
CrossUp = Cross(MA9,MA20);
CrossDn = Cross(MA20,MA9);
//Modified original code available at below location for the requirement
//https://www.traderji.com/community/threads/trading-with-obv-for-beginners-only.104279/
isemapvts = ParamToggle("Want Pivots ", "No|Yes", 1) ;
periodtype = 20;//max MA20 period
//Hi = HHV(H,20);
//Lo = LLV(L,20);
PeriodUp = MA9>MA20;
Hi = HHV(H, PeriodUp);
Lo = LLV(L,PeriodUp);
B1 = Cross(H,Ref(Hi,-1));
S1 = Cross(Ref(Lo,-1),L);
B1 = ExRem(B1,S1); S1 = ExRem(S1,B1);
UP1 = Flip(B1,S1); DN1 = Flip(S1,B1);
ro = ParamField("Open", 0) ;
rh = ParamField("High", 1) ;
rl = ParamField("Low", 2) ;
rc = ParamField("Close", 3) ;
ismph = H-H ;
ismpl = L-L ;
if (isemapvts)
{
if(periodtype)
{
upcross = b1;
downcross = s1;
}
bi = BarIndex() ;
mphbar = HighestSinceBars(upcross, rH) ;
mplbar = LowestSinceBars(downcross, rL) ;
mphbi = ValueWhen(downcross, bi, 0) - ValueWhen(downcross, mphbar, 0) ;
ismph = mphbi == bi ;
mplbi = ValueWhen(upCross, bi, 0) - ValueWhen(upCross, mplbar, 0) ;
ismpl = mplbi == bi ;
ismph = IIf(downCross AND mphbar == 0, True, ismph) ;
ismpl = IIf(upcross AND mplbar == 0, True, ismpl) ;
}
showpvtHiLoline = ParamToggle("Show Pvt Hi/Lo line", "No|Yes", 1) ;
if (showpvtHiLoline)
{
bi = Cum(1)-1;
cbar = Param("cbar",2,2,50,1);
P1 = ismph;//GetTop(Ch);
V1 = ismpl;//GetValley(Ch);
P1 = IIf(P1,IIf(ValueWhen(P1,bi,2) < ValueWhen(V1,bi),P1,IIf(ValueWhen(P1,H,2) > H,False,P1)),P1);
P1 = IIf(P1 AND ValueWhen(P1,bi,0) > bi,IIf(ValueWhen(P1,bi,0) < ValueWhen(V1,bi,0),IIf(ValueWhen(P1,H,0) >= H,False,P1),P1),P1);
V1 = IIf(V1,IIf(ValueWhen(V1,bi,2) < ValueWhen(P1,bi),V1,IIf(ValueWhen(V1,L,2)<L,False, V1)),V1);
V1 = IIf(V1 AND ValueWhen(V1,bi,0) > bi ,IIf(ValueWhen(V1,bi,0) < ValueWhen(P1,bi,0),IIf(ValueWhen(V1,L,0) <= L, False,V1),V1),V1);
RF=ValueWhen(P1,H);
SF=ValueWhen(V1,L);
RF1 = IIf(RF AND BarsSince(P1) <=cbar,RF,Null);
SF1 = IIf(SF AND BarsSince(V1) <=cbar,SF,Null);
Plot(RF1,"",colorBlue,styleDots | styleNoLine|styleNoRescale);
Plot(SF1,"",colorBlue,styleDots | styleNoLine|styleNoRescale);
Plot(RF,"Resist",colorOrange,40+16+2048);//2048 is stylenorescale
Plot(SF,"Suprt",colorbrightGreen,40+16+2048);
PlotText("Peak "+ WriteVal(RF,1.2), BarCount+2, SelectedValue(RF),colororange,colorDefault,5);
PlotText("Valley "+ WriteVal(SF,1.2), BarCount+2, SelectedValue(SF),colorbrightgreen,colordefault,5);
}
_SECTION_END();