LineBreak for ploting Line

Dear Members,

Kindly support me to break the Pivot line between the yesterday and Today. Request you to help me which code i need to modify it.

//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() );
 
TF = ParamList("ORB Range", "15Min|Hourly|Daily|Weekly",2);
Range = Param("EMA Length",20,10,50,10);

NEWDAY = Day() != Ref(Day(),-1);
EndDay = (Day()!= Ref(Day(), 1));  

 if(TF == "15Min")
	{
		Timeframe = in15Minute;
	}
  if(TF == "Hourly")
	{
		Timeframe = inHourly;
	}
  if(TF == "Daily")
	{
		Timeframe = inDaily;
	}
  if(TF == "Weekly")
	{
		Timeframe = inWeekly;
	}

TimeFrameSet(Timeframe);

PrevDay = 0; // Value should be 1 if your database is updated upto current day

PrevLow = Ref(L,-PrevDay);
PrevHigh = Ref(H,-PrevDay);
PrevClose = Ref(C,-PrevDay);

Pivot1 = (PrevLow+PrevHigh+PrevClose)/3;
BC1 = (PrevLow+PrevHigh)/2;
TC1 = (Pivot1-BC1) + Pivot1;

NRThreshold = 0.2;
NarrowRangeCond = (abs(TC1-BC1)/PrevClose*100) < NRThreshold;
NarrowRange = WriteIF(NarrowRangeCond,"YES","NO");

NarrowRangeFGColor=IIf(NarrowRangeCond,colorWhite,colorBlack);
NarrowRangeBKColor=IIf(NarrowRangeCond,colorBrightGreen,colorWhite);

R11 = (2*Pivot1) - PrevLow;
R21 = (Pivot1+PrevHigh) - PrevLow;
R31 = R11 + (PrevHigh-PrevLow);
R41 = R31 + (R21-R11);

S11 = (2*Pivot1) - PrevHigh;
S21 = Pivot1 - (PrevHigh-PrevLow);
S31 = S11 - (PrevHigh-PrevLow);
S41 = S31 - (S11-S21);

TimeFrameRestore();

Pivot = TimeFrameExpand(Pivot1,Timeframe);
BC = TimeFrameExpand(BC1,Timeframe);
TC = TimeFrameExpand(TC1,Timeframe);
R1 = TimeFrameExpand(R11,Timeframe);
R2 = TimeFrameExpand(R21,Timeframe);
R3 = TimeFrameExpand(R31,Timeframe);
R4 = TimeFrameExpand(R41,Timeframe);
S1 = TimeFrameExpand(S11,Timeframe);
S2 = TimeFrameExpand(S21,Timeframe);
S3 = TimeFrameExpand(S31,Timeframe);
S4 = TimeFrameExpand(S41,Timeframe);


Plot(EMA(C,Range),"EMA",colorOrange,styleLine);
Plot(Pivot,"Pivot",colorBlue,styleLine|styleDots);
Plot(BC,"BC",colorBlue,styleLine|styleDots);
Plot(TC,"TC",colorBlue,styleLine|styleDots);

Plot(R1,"R1",colorRed,styleLine);
Plot(R2,"R2",colorRed,styleLine);
//Plot(R3,"R3",colorRed,styleLine);
//Plot(R4,"R4",colorRed,styleLine);
Plot(S1,"S1",colorGreen,styleLine);
Plot(S2,"S2",colorGreen,styleLine);
//Plot(S3,"S3",colorGreen,styleLine);
//Plot(S4,"S4",colorGreen,styleLine);

did you mean this ?

//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() );
 
TF = ParamList("ORB Range", "15Min|Hourly|Daily|Weekly",2);
Range = Param("EMA Length",20,10,50,10);

NEWDAY = Day() != Ref(Day(),-1);
EndDay = (Day()!= Ref(Day(), 1));  

 if(TF == "15Min")
	{
		Timeframe = in15Minute;
	}
  if(TF == "Hourly")
	{
		Timeframe = inHourly;
	}
  if(TF == "Daily")
	{
		Timeframe = inDaily;
	}
  if(TF == "Weekly")
	{
		Timeframe = inWeekly;
	}

TimeFrameSet(Timeframe);

PrevDay = 0; // Value should be 1 if your database is updated upto current day

PrevLow = Ref(L,-PrevDay);
PrevHigh = Ref(H,-PrevDay);
PrevClose = Ref(C,-PrevDay);

Pivot1 = (PrevLow+PrevHigh+PrevClose)/3;
BC1 = (PrevLow+PrevHigh)/2;
TC1 = (Pivot1-BC1) + Pivot1;

NRThreshold = 0.2;
NarrowRangeCond = (abs(TC1-BC1)/PrevClose*100) < NRThreshold;
NarrowRange = WriteIF(NarrowRangeCond,"YES","NO");

NarrowRangeFGColor=IIf(NarrowRangeCond,colorWhite,colorBlack);
NarrowRangeBKColor=IIf(NarrowRangeCond,colorBrightGreen,colorWhite);

R11 = (2*Pivot1) - PrevLow;
R21 = (Pivot1+PrevHigh) - PrevLow;
R31 = R11 + (PrevHigh-PrevLow);
R41 = R31 + (R21-R11);

S11 = (2*Pivot1) - PrevHigh;
S21 = Pivot1 - (PrevHigh-PrevLow);
S31 = S11 - (PrevHigh-PrevLow);
S41 = S31 - (S11-S21);

TimeFrameRestore();

Pivot = TimeFrameExpand(Pivot1,Timeframe);
BC = TimeFrameExpand(BC1,Timeframe);
TC = TimeFrameExpand(TC1,Timeframe);
R1 = TimeFrameExpand(R11,Timeframe);
R2 = TimeFrameExpand(R21,Timeframe);
R3 = TimeFrameExpand(R31,Timeframe);
R4 = TimeFrameExpand(R41,Timeframe);
S1 = TimeFrameExpand(S11,Timeframe);
S2 = TimeFrameExpand(S21,Timeframe);
S3 = TimeFrameExpand(S31,Timeframe);
S4 = TimeFrameExpand(S41,Timeframe);


Plot(EMA(C,Range),"EMA",colorOrange,styleLine);
//Plot(Pivot,"Pivot",colorBlue,styleLine|styleDots);
//Plot(BC,"BC",colorBlue,styleLine|styleDots);
//Plot(TC,"TC",colorBlue,styleLine|styleDots);

PlotOHLC(R1,R1,R1,R1,"R1",colorBlack,styleBarNoTicks,Null,Null,0,0,6);
//Plot(R2,"R2",colorRed,styleLine);
//Plot(R3,"R3",colorRed,styleLine);
//Plot(R4,"R4",colorRed,styleLine);
//Plot(S1,"S1",colorGreen,styleLine);
//Plot(S2,"S2",colorGreen,styleLine);
//Plot(S3,"S3",colorGreen,styleLine);
//Plot(S4,"S4",colorGreen,styleLine);

image

1 Like

I used the PLOTOHLC. You can find more articles that are on the forum for this.

Here Is the Pivot with line break.

YupcANDlebackColor= Colorrgb(0,177, 88);
YdowncANDlebackColor= Colorrgb(246,70, 65);
YwickColorbackColor= Colorrgb(88, 97, 100);
Setchartoptions(0,ChartShowarrows|chartShowDates);
SetbarfillColor(Iif( C > O,  YupcANDlebackColor,YdowncANDlebackColor ));
Plot( C, "Price", Iif( C > O,  YupcANDlebackColor,YdowncANDlebackColor ), styleCandle|styleNoTitle);
_N(Title = EncodeColor(colorOrange)+ StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open = %g, Hi = %g, Lo = %g, Close = %g, Volume = %g Change = (%.1f%%) {{VALUES}}", O, H, L, C, V, SelectedValue( ROC( C, 1 ) ) ));

// The Standard Pivot Formula for One Timeframe
SetBarsRequired(sbrAll,sbrAll);
RequestTimedRefresh(5);
_SECTION_BEGIN("Standard Pivot(Akmeheta@gmail.com");
Timeframe = ParamList("Pivot Interval",List = "Hourly,Daily,Monthly,Yearly",1);  
Type=IIf(ParamList("Select Type","Today|Tomorrow")=="Today",-1,0);
DisplaShow = ParamList("Show Pivots", "Selected only|All|Hide" );
Hslide = Param("Slide Pivot Text HorizontAlly",150,1,500,1);

PivotR4 = ParamList("R4", "Hide|Show");  
PivotR3 = ParamList("R3", "Hide|Show"); 
PivotR2 = ParamList("R2", "Hide|Show"); 
PivotR1 = ParamList("R1", "Show|Hide"); 

PivotTC = ParamList("TC", "Hide|Show"); 
PivotP = ParamList("Pivot","Show|Hide");
PivotBC = ParamList("BC", "Hide|Show"); 

PivotS1 = ParamList("S1", "Show|Hide"); 
PivotS2 = ParamList("S2", "Hide|Show"); 
PivotS3 = ParamList("S3", "Hide|Show"); 
PivotS4 = ParamList("S4", "Hide|Show"); 

Rcolor = ParamColor("Resistance Color", colorOrange);
Pcolor = ParamColor("Central Color", colorDarkYellow);
Scolor = ParamColor("Support Color", colorBrightGreen);
_SECTION_END();

Vslide =  50;
GraphLabelDecimals = 2;
dn1= IIf(Timeframe == "Hourly",inHourly,  IIf(Timeframe == "Daily",inDaily,  IIf(Timeframe == "Monthly",inMonthly,  IIf(Timeframe == "Yearly",inYearly, 0))));
separator =     IIf(Timeframe == "Hourly",Hour()!= Ref( Hour() , -1 ),    IIf(Timeframe == "Daily",Day()!= Ref(Day() , -1 ),   IIf(Timeframe == "Monthly",Month()!= Ref( Month() , -1 ),  IIf(Timeframe == "Yearly",Year()!= Ref(Year() , -1 ), 0))));
separatornext =     IIf(Timeframe == "Hourly",Hour()!= Ref( Hour() , 1 ),    IIf(Timeframe == "Daily",Day()!= Ref(Day() , 1 ),   IIf(Timeframe == "Monthly",Month()!= Ref( Month() , 1 ),  IIf(Timeframe == "Yearly",Year()!= Ref(Year() , 1 ), 0))));

Inbetween = Flip(separator, separatornext);

// Get Prices
Previoushigh = TimeFrameGetPrice( "H", dn1, Type );
PreviousLow = TimeFrameGetPrice( "L", dn1, Type );
Previousclose = TimeFrameGetPrice( "C", dn1, Type );

if(Timeframe == "Hourly")
{
 Nextseparator =     Ref(separator, 1);
Previoushigh = HighestSince(separator, High);
PreviousLow = LowestSince(separator, Low);

Previoushigh = ValueWhen( Nextseparator, Previoushigh);
PreviousLow = ValueWhen( Nextseparator, PreviousLow);
Previousclose = ValueWhen( Nextseparator, Close);
}

Plot(Previoushigh , WriteIf(Previoushigh >0, "\n"+Timeframe+" High",""), colorGreen, styleNoDraw|styleOwnScale|styleNoLabel|styleNoLine);
Plot(PreviousLow , WriteIf(PreviousLow >0, "\n"+Timeframe+" Low",""), colorGreen, styleNoDraw|styleOwnScale|styleNoLabel|styleNoLine);


if (Interval() < dn1)Plot( separator, "", Colorlightgrey, Stylehistogram |Styledashed| Styleownscale|Stylenolabel |styleNoTitle, Null, Null, 0,-256, 1);

// Standard Pivot Formula
Pivot = ( Previoushigh+ PreviousLow + Previousclose )/3;
BC = ( Previoushigh+ PreviousLow )/2;
TC = (Pivot - BC) + Pivot;

R1 = (2*Pivot)-PreviousLow;
R2 = Pivot +(Previoushigh -PreviousLow);
R3 = R1 +(Previoushigh-PreviousLow);
R4 = R3 + (R2 - R1);

S1 = (2*Pivot)-Previoushigh;
S2 = Pivot -(Previoushigh - PreviousLow);
S3 = S1 - (Previoushigh-PreviousLow); 
S4 = S3 - (S1 - S2);

Pivot = IIf(Inbetween, Pivot, Null);
BC = IIf(Inbetween, BC, Null);
TC = IIf(Inbetween, TC, Null);

R1 =IIf(Inbetween, R1, Null);
R2 = IIf(Inbetween, R2, Null);
R3 = IIf(Inbetween, R3, Null);
R4 = IIf(Inbetween, R4, Null);

S1 =IIf(Inbetween, S1, Null);
S2 = IIf(Inbetween, S2, Null);
S3 = IIf(Inbetween, S3, Null);
S4 = IIf(Inbetween, S4, Null);


 if ((PivotP=="Show" OR DisplaShow=="All")  AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (Pivot,"\nPivot ",Pcolor,styleLine);
 if ((PivotTC=="Show" OR DisplaShow=="All")  AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (TC,"\nTC ",Pcolor,styleDashed);
 if ((PivotBC=="Show" OR DisplaShow=="All")  AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (BC,"\nBC ",Pcolor,styleDashed);
 
 if ((PivotR1=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot(R1,"\nR1 ",Rcolor,styleDashed);
 if ((PivotR2=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot(R2,"\nR2 ",Rcolor,styleDashed);
 if ((PivotR3=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot(R3,"\nR3 ",Rcolor,styleDashed);
 if ((PivotR4=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot(R4,"\nR4 ",Rcolor,styleDashed);

 if ((PivotS1=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (S1,"\nS1 ",Scolor,styleDashed);
 if ((PivotS2=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (S2,"\nS2 ",Scolor,styleDashed);
 if ((PivotS3=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (S3,"\nS3 ",Scolor,styleDashed);
 if ((PivotS4=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide" AND Interval() < dn1)  Plot (S4,"\nS4 ",Scolor,styleDashed);
 
Timeframe = StrLeft(Timeframe, 1);
for( i = 0; i < BarCount; i++ )  
{
 if(i+Hslide== BarCount AND (PivotR1=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" R1 :"+Prec(SelectedValue(R1), 2) ,i+Vslide,SelectedValue(R1) ,Rcolor ); 
 if(i+Hslide== BarCount AND (PivotR2=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" R2 :"+Prec(SelectedValue(R2), 2) ,i+Vslide,SelectedValue(R2) ,Rcolor );
 if(i+Hslide== BarCount AND (PivotR3=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" R3 :"+Prec(SelectedValue(R3), 2) ,i+Vslide,SelectedValue(R3) ,Rcolor );
 if(i+Hslide== BarCount AND (PivotR4=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" R4 :"+Prec(SelectedValue(R4), 2) ,i+Vslide,SelectedValue(R4) ,Rcolor );
 
 if(i+Hslide== BarCount AND (PivotTC=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide") PlotText( ""+Timeframe+" TC :"+Prec(SelectedValue(TC), 2) ,i+Vslide,SelectedValue(TC) ,Pcolor);
 if(i+Hslide== BarCount AND (PivotP=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide") PlotText( ""+Timeframe+" Pivot :"+Prec(SelectedValue(Pivot), 2) ,i+Vslide,SelectedValue(Pivot) ,Pcolor);
 if(i+Hslide== BarCount AND (PivotBC=="Show" OR DisplaShow=="All") AND DisplaShow!="Hide") PlotText( ""+Timeframe+" BC :"+Prec(SelectedValue(BC), 2) ,i+Vslide,SelectedValue(BC) ,Pcolor);

 if(i+Hslide== BarCount AND (PivotS1=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" S1 :"+Prec(SelectedValue(S1), 2) ,i+Vslide,SelectedValue(S1) ,Scolor  );
 if(i+Hslide== BarCount AND (PivotS2=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" S2 :"+Prec(SelectedValue(S2), 2) ,i+Vslide,SelectedValue(S2) ,Scolor  );
 if(i+Hslide== BarCount AND (PivotS3=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" S3 :"+Prec(SelectedValue(S3), 2) ,i+Vslide,SelectedValue(S3) ,Scolor );
 if(i+Hslide== BarCount AND (PivotS4=="Show" OR DisplaShow=="All")AND DisplaShow!="Hide") PlotText( ""+Timeframe+" S4 :"+Prec(SelectedValue(S4), 2) ,i+Vslide,SelectedValue(S4) ,Scolor );
}
1 Like

Dear @abhishektiwari and @Yogyatrader,

Thank you for your great support. and also can you help me AFL code for
if trading is hit stoploss, The Trading will be reversed.

Ex. If i buy a share at Rs.80, and if the stoploss is hit on Rs.75, Immediately short poistion to be initated with 2 Rupees Target.

I have tried with below code, It is not working.

Buy1 = IIf(CoverPrice > SellPrice, Buy, Null);
Short1 = iif(SellPrice < BuyPrice, Short,Null);

Buy = Buy OR Buy1;
Short = Short OR Short1;

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