Simple Coding Help - No Promise.

toocool

Well-Known Member
toocool

As per my limited knowledge , I am not able to plot the ATR on a price chart.
Mostly all systems calculate the stop loss based on the ATR.

You can use the 2nd AFL , I have posted or something like Supertrend.

Experts please feel free to advice.


amit bro , how do you like volume at price in its simple form but working perfectly?:thumb:
 

toocool

Well-Known Member


amit bro , how do you like volume at price in its simple form but working perfectly?:thumb:
just overlay volume at price multi in basic chart list of amibroker itself its above customs list itself :thumb:

it doesnt have actula volume though i believe so VPOC cant be plotted , if you find proper AFL then please dont forget to share with me on forums :D
 
Bro, there is some mismatching in figures
please check


Sorry typing error.rectified it. :thumb:
Code:
_SECTION_BEGIN("FIBO");

dec = (Param("Decimals",2,0,7,1)/10)+1;
SetChartOptions(0,chartShowArrows|chartShowDates);

FibCol= ParamColor("Fib Line Color",colorOrange );//


SetBarFillColor(IIf(C>O,colorWhite ,IIf(C<O,colorCustom4 ,colorYellow)));
Plot(C,"Close",IIf(C>Ref(C,-1),colorWhite ,IIf(C<Ref(C,-1),colorSkyblue ,colorYellow )),64);


YH=TimeFrameGetPrice("H", inDaily, -1);
YL=TimeFrameGetPrice("L", inDaily, -1);

Yo=TimeFrameGetPrice("o", inDaily, -1);
Yc=TimeFrameGetPrice("c", inDaily, -1);

DD=Prec(C-Yc,2);
xx=Prec((DD/Yc)*100,2);


numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);

Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(55) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}" +
	EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ " Low = "+ EncodeColor(33)+ WriteVal(L,dec) + 
	EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec);


Line0=YL;
Line100=YH;

Line1 = Line0 + abs(Line100-Line0)*0.236; 
Line2 = Line0 + abs(Line100-Line0)*0.382; 
Line3 = Line0 + abs(Line100-Line0)*0.5; 
Line4 = Line0 + abs(Line100-Line0)*0.618; 
Line5= Line0 + abs(Line100-Line0)*0.786; 


Plot(C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);

Plot(IIf(Today == Day(),YL,Null), "0%",FibCol,styleDashed |styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),Line1,Null), "23.6%",FibCol,styleDashed |styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),Line2,Null), "38.2%",FibCol,styleDashed |styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),Line3,Null), "50%",FibCol,styleDashed |styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),Line4,Null), "61.8%",FibCol,styleDashed |styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),Line5,Null), "78.6%",FibCol,styleDashed |styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),YH,Null), "100%",FibCol,styleDashed |styleNoRescale|styleNoTitle);

PlotText("0%= " + WriteVal(YL,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (YL,1) , FibCol);
PlotText("23.6%= " + WriteVal(Line1,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line1,1) , FibCol);
PlotText("38.2%" + WriteVal(Line2,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line2,1) , FibCol);
PlotText("50%= " + WriteVal(Line3,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line3,1) , FibCol);
PlotText("61.8%= " + WriteVal(Line4,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line4,1) , FibCol);
PlotText("78.6%= " + WriteVal(Line5,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line5,1) , FibCol);
PlotText("100%= " + WriteVal(YH,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (YH,1) , FibCol);



_SECTION_END();
 
fxarun sir, is it possible to plot fib ratio based on last swing high low ? instead of last day high low, if yes please write code for the same

thanks
Please Check this one.:)

AutoFibo :

Code:
_SECTION_BEGIN("Auto FIBO");

dec = (Param("Decimals",2,0,7,1)/10)+1;
SetChartOptions(0,chartShowArrows|chartShowDates);

FibCol= ParamColor("Fib Line Color",colorOrange );//

tf=Param("Time Frame (min)",60,1,10000,1);
SRPer	 = Param("S/R Percentage", 0.3, 0.1,5,0.1);

tfrm=in1Minute*tf;
H1=TimeFrameGetPrice("H",TFRM);
L1=TimeFrameGetPrice("L",TFRM);

Yc=TimeFrameGetPrice("c", inDaily, -1);


SetBarFillColor(IIf(C>O,colorWhite ,IIf(C<O,colorCustom4 ,colorYellow)));
Plot(C,"Close",IIf(C>Ref(C,-1),colorWhite ,IIf(C<Ref(C,-1),colorSkyblue ,colorYellow )),64);


DD=Prec(C-Yc,2);
xx=Prec((DD/Yc)*100,2);


numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);


Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(55) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}" +
	EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ " Low = "+ EncodeColor(33)+ WriteVal(L,dec) + 
	EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec);

function GetXSupport(L1, Percentage, Back)
{
return ((BarCount - 1) - LastValue(TroughBars(L1, Percentage,Back)));
}
function GetYSupport(L1, Percentage, Back)
{
return (LastValue(Trough(L1, Percentage, back)));
}
function GetXResistance(H1, Percentage, Back)
{
return ((BarCount - 1) -LastValue(PeakBars(H1, Percentage, Back)));
}
function GetYResistance(H1, Percentage, Back)
{
return (LastValue(Peak(H1, Percentage, Back)));
}

x0 = GetXSupport(L1, SRPer, 1);
x1 = BarCount-1;
y0 = GetYSupport(L1, SRPer, 1);
a0 = GetXResistance(H1, SRPer, 1);
b0 = GetYResistance(H1, SRPer, 1);



Line0=y0;
Line100=b0;



Line1 = Line0 + abs(Line100-Line0)*0.236; 
Line2 = Line0 + abs(Line100-Line0)*0.382; 
Line3 = Line0 + abs(Line100-Line0)*0.5; 
Line4 = Line0 + abs(Line100-Line0)*0.618; 
Line5= Line0 + abs(Line100-Line0)*0.786; 


x = LineArray(x0, y0, x1, y0, 0);
y = LineArray(a0, b0, x1, b0, 0);
fib1 = LineArray(x0, Line1 , x1, Line1 , 0);
fib2 = LineArray(x0, Line2 , x1, Line2 , 0);
fib3 = LineArray(x0, Line3 , x1, Line3 , 0);
fib4 = LineArray(x0, Line4 , x1, Line4 , 0);
fib5 = LineArray(x0, Line5 , x1, Line5 , 0);


Plot(x, "0%", colorBrightGreen,styleLine|styleDashed|styleThick);
Plot(y, "100%", colorRed,styleLine|styleDashed|styleThick);
Plot(fib1 , "23.6%", FibCol,styleLine|styleDashed|styleThick);
Plot(fib2 , "38.2%", FibCol,styleLine|styleDashed|styleThick);
Plot(fib3 , "50%", FibCol,styleLine|styleDashed|styleThick);
Plot(fib4 , "61.8%", FibCol,styleLine|styleDashed|styleThick);
Plot(fib5 , "78.6%", FibCol,styleLine|styleDashed|styleThick);


PlotText("0%= " + WriteVal(y0,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (y0,1) , colorBrightGreen);
PlotText("23.6%= " + WriteVal(fib1 ,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line1,1) , FibCol);
PlotText("38.2%" + WriteVal(fib2 ,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line2,1) , FibCol);
PlotText("50%= " + WriteVal(fib3 ,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line3,1) , FibCol);
PlotText("61.8%= " + WriteVal(fib4 ,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line4,1) , FibCol);
PlotText("78.6%= " + WriteVal(fib5 ,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (Line5,1) , FibCol);
PlotText("100%= " + WriteVal(b0,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (b0 ,1) , colorRed);



_SECTION_END();
 
@happy bro can you help me in this AFL?

As you requested.:thumb:

Floor Pivots.

Code:
_SECTION_BEGIN("Floor Pivots");

dec = (Param("Decimals",2,0,7,1)/10)+1;
SetChartOptions(0,chartShowArrows|chartShowDates);

FibCol= ParamColor("Fib Line Color",colorOrange );//


SetBarFillColor(IIf(C>O,colorWhite ,IIf(C<O,colorCustom4 ,colorYellow)));
Plot(C,"Close",IIf(C>Ref(C,-1),colorWhite ,IIf(C<Ref(C,-1),colorSkyblue ,colorYellow )),64);


DayH=TimeFrameGetPrice("H", inDaily, -1);
DayL=TimeFrameGetPrice("L", inDaily, -1);

DayO=TimeFrameGetPrice("o", inDaily, -1);
DayC=TimeFrameGetPrice("c", inDaily, -1);

DD=Prec(C-DayC,2);
xx=Prec((DD/DayC)*100,2);


numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);

Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(55) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}" +
	EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ " Low = "+ EncodeColor(33)+ WriteVal(L,dec) + 
	EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec);

RANGE = (DayH - DayL);
PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = ( 2*PP ) - DayL  ; 
S1 = ( 2*PP ) - DayH; 
R2 = PP + RANGE; 
S2 = PP - RANGE; 
R3 = R1 + RANGE; 
S3 = S1 - RANGE; 
R4 = R3 + (R2-R1); 
S4 = S3 - (S1-S2);

BC = (DayH + DayL)/2;
TC = ( PP - BC ) + PP;


Plot(IIf(Today == Day(),PP,Null), "PP",colorGold,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R1,Null), "R1",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S1,Null), "S1",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R2,Null), "R2",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S2,Null), "S2",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R3,Null), "R3",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S3,Null), "S3",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R4,Null), "R4",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S4,Null), "S4",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);

Plot(IIf(Today == Day(),TC,Null), "TC",colorWhite,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),BC,Null), "BC",colorWhite,styleDots|styleNoRescale|styleNoTitle);

PlotText("Pivot = " + WriteVal(pp,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (pp,1) , colorGold);
PlotText("R1 = " + WriteVal(R1,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R1,1) , colorOrange);
PlotText("S1 = " + WriteVal(S1,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S1,1) , colorPaleGreen);
PlotText("R2 = " + WriteVal(R2,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R2,1) , colorOrange);
PlotText("S2 = " + WriteVal(S2,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S2,1) , colorPaleGreen);
PlotText("R3 = " + WriteVal(R3,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R3,1) , colorOrange);
PlotText("S3 = " + WriteVal(S3,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S3,1) , colorPaleGreen);
PlotText("R4 = " + WriteVal(R4,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R4,1) , colorOrange);
PlotText("S4 = " + WriteVal(S4,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S4,1) , colorPaleGreen);

PlotText("TC = " + WriteVal(TC,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (TC,1) , colorWhite);
PlotText("BC = " + WriteVal(BC,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (BC,1) , colorWhite);

_SECTION_END();
 


guys i tried to find this kind of formula pivot AFL , didnt find anywhere , can you guys help please? :)
If you want a change in the way its plotted you can ask other members as my plotting knowledge is limited.

Now, the Pivots are calculated on daily timeframe and taking into account previous days Values.
So if you plot them on today's 5 min chart the support and resistances will be shown as per yesterday's OHLC( which is the way it is meant to be calculated.)



Code:
_SECTION_BEGIN("Floor pivot");

// Using Previous day OHLC to calculate Support and resistance on current //Day chart.
//Support and resistance are calculated on Daily prices.

TimeFrameSet(inDaily);

// Assigning previous days O,H,L,C.
pc = Ref(C,-1);
ph = Ref(H,-1);
pl = Ref(L,-1);



// Calculating basic elements for later derivation. 
a = ((ph+pl+pc)/3);
bc = (ph+pl)/2;
tc = ((a - bc)+a);

// Calculation of resistances.
R1 = ((2*a)-pl);
R2 = (a + (ph-pl));
R3 = R1+(ph-pl);
R4 = R3 + (R2-R1);

// Calculation of Supports.
S1 = ((2*a)-Ref(H,-1));
S2 = (a-(Ref(H,-1)-Ref(L,-1)));
S3 = (S1-(Ref(H,-1)-Ref(L,-1)));
S4 = (S3-(S1-S2));
TimeFrameRestore();

// Call for time Frame Expand funtion to use it on any Intraday chart.
R1 = TimeFrameExpand(R1,inDaily);
R2 = TimeFrameExpand(R2,inDaily);
R3 = TimeFrameExpand(R3,inDaily);
R4 = TimeFrameExpand(R4,inDaily);

S1 = TimeFrameExpand(S1,inDaily);
S2 = TimeFrameExpand(S2,inDaily);
S3 = TimeFrameExpand(S3,inDaily);
S4 = TimeFrameExpand(S4,inDaily);


// plotting resistance lines.
Plot(R1,"R1",colorYellow,styleLine);
Plot(R2,"R2",colorGreen,styleLine);
Plot(R3,"R3",colorRed,styleLine);
Plot(R4,"R4",colorBlue,styleLine);

//PLOTTING SUPPORT LINES.
Plot(S1,"S1",colorYellow,styleLine);
Plot(S2,"S2",colorGreen,styleLine);
Plot(S3,"S3",colorRed,styleLine);
Plot(S4,"S4",colorBlue,styleLine);

_SECTION_END();


All I can do is give a Try.:D
 
Last edited:

trash

Well-Known Member
As you requested.:thumb:

Floor Pivots.

Code:
_SECTION_BEGIN("Floor Pivots");

dec = (Param("Decimals",2,0,7,1)/10)+1;
SetChartOptions(0,chartShowArrows|chartShowDates);

FibCol= ParamColor("Fib Line Color",colorOrange );//


SetBarFillColor(IIf(C>O,colorWhite ,IIf(C<O,colorCustom4 ,colorYellow)));
Plot(C,"Close",IIf(C>Ref(C,-1),colorWhite ,IIf(C<Ref(C,-1),colorSkyblue ,colorYellow )),64);


DayH=TimeFrameGetPrice("H", inDaily, -1);
DayL=TimeFrameGetPrice("L", inDaily, -1);

DayO=TimeFrameGetPrice("o", inDaily, -1);
DayC=TimeFrameGetPrice("c", inDaily, -1);

DD=Prec(C-DayC,2);
xx=Prec((DD/DayC)*100,2);


numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);

Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(55) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}" +
	EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ " Low = "+ EncodeColor(33)+ WriteVal(L,dec) + 
	EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec);

RANGE = (DayH - DayL);
PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = ( 2*PP ) - DayL  ; 
S1 = ( 2*PP ) - DayH; 
R2 = PP + RANGE; 
S2 = PP - RANGE; 
R3 = R1 + RANGE; 
S3 = S1 - RANGE; 
R4 = R3 + (R2-R1); 
S4 = S3 - (S1-S2);

BC = (DayH + DayL)/2;
TC = ( PP - BC ) + PP;


Plot(IIf(Today == Day(),PP,Null), "PP",colorGold,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R1,Null), "R1",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S1,Null), "S1",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R2,Null), "R2",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S2,Null), "S2",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R3,Null), "R3",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S3,Null), "S3",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R4,Null), "R4",colorOrange,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S4,Null), "S4",colorPaleGreen,styleDots|styleNoRescale|styleNoTitle);

Plot(IIf(Today == Day(),TC,Null), "TC",colorWhite,styleDots|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),BC,Null), "BC",colorWhite,styleDots|styleNoRescale|styleNoTitle);

PlotText("Pivot = " + WriteVal(pp,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (pp,1) , colorGold);
PlotText("R1 = " + WriteVal(R1,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R1,1) , colorOrange);
PlotText("S1 = " + WriteVal(S1,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S1,1) , colorPaleGreen);
PlotText("R2 = " + WriteVal(R2,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R2,1) , colorOrange);
PlotText("S2 = " + WriteVal(S2,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S2,1) , colorPaleGreen);
PlotText("R3 = " + WriteVal(R3,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R3,1) , colorOrange);
PlotText("S3 = " + WriteVal(S3,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S3,1) , colorPaleGreen);
PlotText("R4 = " + WriteVal(R4,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (R4,1) , colorOrange);
PlotText("S4 = " + WriteVal(S4,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (S4,1) , colorPaleGreen);

PlotText("TC = " + WriteVal(TC,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (TC,1) , colorWhite);
PlotText("BC = " + WriteVal(BC,fraction),LastValue(BarIndex())-(numbars/hts),LastValue (BC,1) , colorWhite);

_SECTION_END();
And then people start to wonder why AB reacts slow. Exactly because of codes similar to your one or worse. Next time please also use arrays within loop. Thank you!


EDIT:

much better readable/maintainable and faster

Code:
_SECTION_BEGIN("Floor Pivots");
// modified, optimized, cleaned by trash

dd = Day();
Today = LastValue( dd );
lastday = Today == dd;
    
function lastdayarray( array )
{    
    return IIf( lastday, array, Null );
}

SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle );

FibCol = ParamColor( "Fib Line Color", colorOrange );//

SetBarFillColor( IIf( C > O, colorWhite , IIf( C < O, colorCustom4 , colorYellow ) ) );
Plot( C, "Close", IIf( C > Ref( C, -1 ), colorWhite , IIf( C < Ref( C, -1 ), colorSkyblue , colorYellow ) ), 64 );


DayH = TimeFrameGetPrice( "H", inDaily, -1 );
DayL = TimeFrameGetPrice( "L", inDaily, -1 );

DayO = TimeFrameGetPrice( "O", inDaily, -1 );
DayC = TimeFrameGetPrice( "C", inDaily, -1 );

// some unknown leftovers, not used in this code
//DD = C - DayC;
//xx = Prec( ( DD / DayC ) * 100, 2 );

defaultcol = EncodeColor( 55 );
Title = StrFormat( defaultcol + Name() + "     " +
                   defaultcol + Date() + "      " + EncodeColor( 5 ) + "{{INTERVAL}}" +
                   defaultcol + " Open = " + EncodeColor( 52 ) + "%g" +
                   defaultcol + " High = " + EncodeColor( 5 ) + "%g" +
                   defaultcol + " Low = " + EncodeColor( 33 ) + "%g" +
                   defaultcol + " Close = " + EncodeColor( 52 ) + "%g", O, H, L, C );
                   

RANGE = ( DayH - DayL );
PP = ( DayL + DayH + DayC ) / 3;
//PPI = LastValue ( PP, 1 ); // Pivot, unused variable
R1 = ( 2 * PP ) - DayL  ;
S1 = ( 2 * PP ) - DayH;
R2 = PP + RANGE;
S2 = PP - RANGE;
R3 = R1 + RANGE;
S3 = S1 - RANGE;
R4 = R3 + ( R2 - R1 );
S4 = S3 - ( S1 - S2 );

BC = ( DayH + DayL ) / 2;
TC = ( PP - BC ) + PP;


style = styleDots | styleNoRescale | styleNoTitle;

Plot( lastdayarray( PP ), "PP", colorGold, style );
Plot( lastdayarray( R1 ), "R1", colorOrange, style );
Plot( lastdayarray( S1 ), "S1", colorPaleGreen, style );
Plot( lastdayarray( R2 ), "R2", colorOrange, style );
Plot( lastdayarray( S2 ), "S2", colorPaleGreen, style );
Plot( lastdayarray( R3 ), "R3", colorOrange, style );
Plot( lastdayarray( S3 ), "S3", colorPaleGreen, style );
Plot( lastdayarray( R4 ), "R4", colorOrange, style );
Plot( lastdayarray( S4 ), "S4", colorPaleGreen, style );

Plot( lastdayarray( TC ), "TC", colorWhite, style );
Plot( lastdayarray( BC ), "BC", colorWhite, style );


numbars = LastValue( Cum( Status( "barvisible" ) ) );
hts = -33.5;
xtext = LastValue( BarIndex() ) - ( numbars / hts );

PlotText( StrFormat( "Pivot = %g", pp ), xtext, LastValue ( pp, 1 ), colorGold );
PlotText( StrFormat( "R1 = %g", R1 ), xtext, LastValue ( R1, 1 ), colorOrange );
PlotText( StrFormat( "S1 = %g", S1 ), xtext, LastValue ( S1, 1 ), colorPaleGreen );
PlotText( StrFormat( "R2 = %g", R2 ), xtext, LastValue ( R2, 1 ), colorOrange );
PlotText( StrFormat( "S2 = %g", S2 ), xtext, LastValue ( S2, 1 ), colorPaleGreen );
PlotText( StrFormat( "R3 = %g", R3 ), xtext, LastValue ( R3, 1 ), colorOrange );
PlotText( StrFormat( "S3 = %g", S3 ), xtext, LastValue ( S3, 1 ), colorPaleGreen );
PlotText( StrFormat( "R4 = %g", R4 ), xtext, LastValue ( R4, 1 ), colorOrange );
PlotText( StrFormat( "S4 = %g", S4 ), xtext, LastValue ( S4, 1 ), colorPaleGreen );

PlotText( StrFormat( "TC = %g", TC ), xtext, LastValue ( TC, 1 ), colorWhite );
PlotText( StrFormat( "BC = %g", BC ), xtext, LastValue ( BC, 1 ), colorWhite );
_SECTION_END();
 
Last edited:

Similar threads