Developing Pivot Range

After the lovely solution from my recent "ask for help" for plotting prior days HLC values I have been trying to write a code for the "Developing Pivot Range" on an intra day chart, a concept from the book "Secrets of A Pivot Boss " by Franklin Ochoa.

I am facing a bump - getting the plots connecting 2 days, request for help to get rid of these lines, Thanks.

Below is the code :-1:


_SECTION_BEGIN("DEVELOPING CPR");

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), "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

SetChartOptions(0,chartHideQuoteMarker);
GraphLabelDecimals = 2;
GraphXSpace = 10;


// DYNAMIC CENTRAL PIVOT RANGE
PP=((H+L+C)/3); BP = ((H+L)/2); TP =(PP+(PP-BP));

Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == 0915000, BarIndex());

HD= HHV(H,Bars_so_far_today); 
LD =LLV(L,Bars_so_far_today);
DPP =(HD+LD+C)/3; 
DBP = (HD+LD)/2; 
DTP = DPP+(DPP-DBP);

DPV = LastValue(DPP);	DBV=LastValue(DBP);		DTV = LastValue(DTP);

/// HELP = want to get rid of the pivot lines between the end of a day and start of the next day
//kindly see posted chart plot


Plot (DPP,"DPP",colorCustom11, styleStaircase |styleLine|  styleNoTitle,0,0,0,1,1);
PlotTextSetFont("DPP = "+DPP,"ARIALBOLD",12,BarCount,DPV,colorCustom11);

Plot (DTP,"DTP",colorDarkBlue, styleStaircase|styleLine| styleNoTitle ,0,0,0,1,1); 
PlotTextSetFont("DTP = "+DTP,"ARIALBOLD",12,BarCount,DTV,colorDarkBlue);

Plot (DBP,"DBP",colorCustom12, styleStaircase| styleLine|  styleNoTitle ,0,0,0,1,1);
PlotTextSetFont("DBP = "+DBP,"ARIALBOLD",12,BarCount,DBV,colorCustom12);

_SECTION_END();

Below is a screen shot showing my problem:


![DPL|690x387](upload://tm3Va4k62HrsbEANvWXQC04WOLk.png)

Thanks for your help.

you need to "Null" out the last or the first bar of the day. So a solution could be:

separator = Day() != Ref( Day(), -1 );

Plot( IIf( !separator, DPP, Null ), "DPP", colorCustom11, styleStaircase | styleLine |  styleNoTitle, 0, 0, 0, 1, 1 );
PlotTextSetFont( "DPP = " + DPP, "ARIALBOLD", 12, BarCount, DPV, colorCustom11 );

Plot( IIf( !separator, DTP, Null ), "DTP", colorDarkBlue, styleStaircase | styleLine | styleNoTitle , 0, 0, 0, 1, 1 );
PlotTextSetFont( "DTP = " + DTP, "ARIALBOLD", 12, BarCount, DTV, colorDarkBlue );

Plot( IIf( ! separator, DBP, Null ), "DBP", colorCustom12, styleStaircase | styleLine |  styleNoTitle , 0, 0, 0, 1, 1 );
PlotTextSetFont( "DBP = " + DBP, "ARIALBOLD", 12, BarCount, DBV, colorCustom12 );

it depends a bit how you define your "day". Meaning that for instance for US futures the trading day starts at 18:00 and ends at 17:00 the next day. In this case you define your day in the "Database Settings" (Intraday settings) and you can use as the separator:

separator = Ref( Nz( TimeFrameExpand( 1, inDaily, expandPoint ) ), -1 );

or something like that. In any case the trick is to "Null" out 1 point at the boundaries

3 Likes

Thank you very much, below is the code I am using:-


_SECTION_BEGIN("DEVELOPING CPR");

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), "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

SetChartOptions(0,chartHideQuoteMarker);
GraphLabelDecimals = 2;
GraphXSpace = 10;


// DYNAMIC CENTRAL PIVOT RANGE
PP=((H+L+C)/3); BP = ((H+L)/2); TP =(PP+(PP-BP));

Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == 0915000, BarIndex());

HD= HHV(H,Bars_so_far_today); 
LD =LLV(L,Bars_so_far_today);
DPP =(HD+LD+C)/3; 
DBP = (HD+LD)/2; 
DTP = DPP+(DPP-DBP);

DPV = LastValue(DPP);	DBV=LastValue(DBP);		DTV = LastValue(DTP);

//Below solurion, with many thanks from EDWARD POTTASCH
// In any case the trick is to "Null" out 1 point at the boundaries
separator = Ref( Nz( TimeFrameExpand( 1, inDaily, expandPoint ) ), -1 );

Plot( IIf( !separator, DPP, Null ), "DPP", colorCustom11, styleStaircase | styleLine |  styleNoTitle, 0, 0, 0, 1, 1 );
PlotTextSetFont( "DPP = " + DPP, "ARIALBOLD", 12, BarCount, DPV, colorCustom11 );

Plot( IIf( !separator, DTP, Null ), "DTP", colorDarkBlue, styleStaircase | styleLine | styleNoTitle , 0, 0, 0, 1, 1 );
PlotTextSetFont( "DTP = " + DTP, "ARIALBOLD", 12, BarCount, DTV, colorDarkBlue );

Plot( IIf( ! separator, DBP, Null ), "DBP", colorCustom12, styleStaircase | styleLine |  styleNoTitle , 0, 0, 0, 1, 1 );
PlotTextSetFont( "DBP = " + DBP, "ARIALBOLD", 12, BarCount, DBV, colorCustom12 );


_SECTION_END();

Via this post I will thank all the masters on this forum who have guided and helped me, for now over 5 years.

Thanks a ton.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.