Need AFL Help: Previous days High Low Close

#1
Hi Members,

Please help me remove the line of HLC in previous days charts. These Previous days High Low Close should only be visible on current days chart.

Below is the AFL and I have attached an image of the chart.

Thanks all.

*************************************
_SECTION_BEGIN("PreDay HLC");
//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inDaily, -1); // low
C1= TimeFrameGetPrice("C", inDaily, -1); // close
DayO = TimeFrameGetPrice("-1", inDaily); // current day open

//PLOTS

Plot(H1, "",colorRed,styleLine+styleThick+styleNoRescale+styleNoLabel);
Plot(L1, "",colorBrightGreen,styleLine+styleThick+styleNoLabel);
Plot(C1, "",colorLightGrey,styleLine+styleNoRescale+styleNoLabel);
_SECTION_END();

**************************************
 
Last edited:

HULK

Active Member
#2
_SECTION_BEGIN("Price");
SetChartBkGradientFill( ParamColor("BgTop",colorBlack),ParamColor("BgBottom",colorBlack),ParamColor("Titleblock",colorLightGrey));
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
GraphXSpace = 5;
Plot(C,"",colorWhite,styleCandle);
_SECTION_END();

//Previous Days HI LO //

YDayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (YDayH,1);// yesterdays high
YDayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (YDayL,1); // yesterdays low
YDayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
YDayO = TimeFrameGetPrice("O", inDaily); // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2); DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2); DayL2I = LastValue (DayL2,1); // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3); DayH3I = LastValue (DayH3,1); // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3); DayL3I = LastValue (DayL3,1); // Three days before low

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

YHL = ParamToggle("Yesterday HI LO","Show|Hide",0);
if(YHL==1) {
Plot(YDayL,"YL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(YDayH,"YH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}

TDBHL = ParamToggle("2/3Days before HI LO","Show|Hide",0);
if(TDBHL==1) {
Plot(DayL2,"2DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH2,"2DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayL3,"3DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH3,"3DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" 2DBH " , LastValue(BarIndex())-(numbars/Hts), DayH2I, colorTurquoise);
PlotText(" 2DBL " , LastValue(BarIndex())-(numbars/Hts), DayL2I, colorTurquoise);
PlotText(" 3DBH " , LastValue(BarIndex())-(numbars/Hts), DayH3I, colorTurquoise);
PlotText(" 3DBL " , LastValue(BarIndex())-(numbars/Hts), DayL3I, colorTurquoise);
}

// Pivot Levels //
PP = (YDayL + YDayH + YDayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = (PP * 2) - YDayL; R1I = LastValue (R1,1); // Resistance 1
S1 = (PP * 2) - YDayH; S1I = LastValue (S1,1); // Support 1
R2 = PP + R1 - S1; R2I = LastValue (R2,1); // Resistance 2
S2 = PP - R1 + S1; S2I = LastValue (S2,1); // Support 2
R3 = PP + R2 - S1; R3I = LastValue (R3,1); // Resistance 3
S3 = PP - R2 + S1; S3I = LastValue (S3,1); // Support 3

ppl = ParamToggle("Pivot Levels","Show|Hide",0);
if(ppl==1) {
Plot(PP, "PP",colorYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R1, "R1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S1, "S1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R2, "R2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S2, "S2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R3, "R3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S3, "S3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);

PlotText(" Pivot ", LastValue(BarIndex())-(numbars/Hts), PPI, colorYellow);
PlotText(" R1 " , LastValue(BarIndex())-(numbars/Hts), R1I, colorViolet);
PlotText(" S1 " , LastValue(BarIndex())-(numbars/Hts), S1I, colorViolet);
PlotText(" R2 " , LastValue(BarIndex())-(numbars/Hts), R2I, colorViolet);
PlotText(" S2 " , LastValue(BarIndex())-(numbars/Hts), S2I, colorViolet);
PlotText(" R3 " , LastValue(BarIndex())-(numbars/Hts), R3I, colorViolet);
PlotText(" S3 " , LastValue(BarIndex())-(numbars/Hts), S3I, colorViolet);
}

// Current Days Hi Lo //
THL = ParamToggle("Todays Hi Lo","Show|Hide",1);
if(THL==1) {
isRth = TimeNum() >= 084500 & TimeNum() <= 085959;
isdRth = TimeNum() >= 084500 & TimeNum() <= 160000;
aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
Bars = BarsSince(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);
DayHlineI = LastValue (DayHline,1);
DayLlineI = LastValue (DayLline,1);
Plot(DayHline,"DayH",colorYellow,styleBar|styleNoRescale|styleNoTitle);
Plot(DayLline,"DayL",colorYellow,styleBar|styleNoRescale|styleNoTitle);
PlotText(" Day Hi " , LastValue(BarIndex())-(numbars/Hts), DayHlineI +0.05, colorYellow);
PlotText(" Day Lo " , LastValue(BarIndex())-(numbars/Hts), DayLlineI +0.05, colorYellow);
}

//Intraday Hrl HI LO //

HiHrly = TimeFrameGetPrice("H", inHourly);
LoHrly = TimeFrameGetPrice("L", inHourly);

Plot(HiHrly ,"",colorBlue, styleLine );
Plot(LoHrly ,"",colorDarkRed,styleLine);

RangeTitle = EncodeColor(colorBlack) + "TODay Range= " + EncodeColor(colorBlack) + StrToNum(NumToStr(round((DayH - DayL)), 4.4));
YSDAYRangeTitle = EncodeColor(colorBlack) + "YSDay Range= " + EncodeColor(colorBlack) + StrToNum(NumToStr(round((YDayH - YDayL)), 5.4));
Hodcolorsheme=colorDarkBlue;
LodColorscheme=colorOrange;
Title = EncodeColor(colorDarkBlue)+ "HULK HOD-LOD" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorRed) +
" - " + Date() +" - "+"\n" +EncodeColor(colorBlack) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n" +
EncodeColor(Hodcolorsheme) + "HiHrly= " + EncodeColor(colorBlack) + HiHrly + "\n" +
EncodeColor(LodColorscheme) + "LowHrly= " + EncodeColor(colorBlack) + LoHrly + "\n" +
EncodeColor(Hodcolorsheme) + "HOD= " + EncodeColor(colorBlack) + DayH + "\n" +
EncodeColor(LodColorscheme) + "LOD= " + EncodeColor(colorBlack) + DayL + "\n" + RangeTitle +"\n" +
EncodeColor(Hodcolorsheme) + "YsdayHi= " + EncodeColor(colorBlack) + YDayH+ "\n" +
EncodeColor(LodColorscheme) + "YsdayLow= " + EncodeColor(colorBlack) + YDayL + "\n" + YSDAYRangeTitle;
_SECTION_END();


In above code I added Todya Hi / low + Hourly Hi /low , Yesterday Hi/Low , 2Days/3Days Hi / Lo also with range & PP

When u plot a chart by default u cans see 4 lines on chart i.e Hrly hi / low lines , Daily hi / low Doted lines

Now if u go to parameter windows you can see option call, Ysday hi low / 2 Days / 3 Days Hi low & Pivot = Show(by default), if u change to Hide then you can see all lines also on chart.


Enjoy :thumb:

HULK
 

KelvinHand

Well-Known Member
#3
Hi Members,

Please help me remove the line of HLC in previous days charts. These Previous days High Low Close should only be visible on current days chart.

Below is the AFL and I have attached an image of the chart.

Thanks all.

*************************************
_SECTION_BEGIN("PreDay HLC");
//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inDaily, -1); // low
C1= TimeFrameGetPrice("C", inDaily, -1); // close
DayO = TimeFrameGetPrice("-1", inDaily); // current day open

//PLOTS

Plot(H1, "",colorRed,styleLine+styleThick+styleNoRescale+styleNoLabel);
Plot(L1, "",colorBrightGreen,styleLine+styleThick+styleNoLabel);
Plot(C1, "",colorLightGrey,styleLine+styleNoRescale+styleNoLabel);
_SECTION_END();

**************************************
Code:
//----[KH]  After DayO

found = TimeNum()==000000;
for(i=BarCount-1; i>0; i--)
   if (found[i]==True) break;

for(; i>0; i--)
{
    H1[i] = Null;
    L1[i] = Null;
    C1[i] = Null;
}


//----[KH]  Before PLOTS


_SECTION_END();
 

jsb2012

Active Member
#4
Seniors i want to plot the hi, lo & close of 3 hour candle (9.30am to 12.30pm)of previous day. Pls help me by giving afl code only for that its enough.rest i will take care pls
 

trash

Well-Known Member
#5
Hi Members,

Please help me remove the line of HLC in previous days charts. These Previous days High Low Close should only be visible on current days chart.

Below is the AFL and I have attached an image of the chart.

Thanks all.

*************************************
_SECTION_BEGIN("PreDay HLC");
//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
L1 = TimeFrameGetPrice("L", inDaily, -1); // low
C1= TimeFrameGetPrice("C", inDaily, -1); // close
DayO = TimeFrameGetPrice("-1", inDaily); // current day open

//PLOTS

Plot(H1, "",colorRed,styleLine+styleThick+styleNoRescale+styleNoLabel);
Plot(L1, "",colorBrightGreen,styleLine+styleThick+styleNoLabel);
Plot(C1, "",colorLightGrey,styleLine+styleNoRescale+styleNoLabel);
_SECTION_END();

**************************************
Code:
_SECTION_BEGIN("PreDay HLC");
function CDL( array )
{
    doy = DayOfYear();
    Lastdoy = doy == LastValue( doy );
    Dayline = array * Lastdoy;

    return IIf( Dayline, Dayline, Null );
}

//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice( "H", inDaily, -1 ); // yesterdays high
L1 = TimeFrameGetPrice( "L", inDaily, -1 ); // low
C1 = TimeFrameGetPrice( "C", inDaily, -1 ); // close
DayO = TimeFrameGetPrice( "-1", inDaily ); // current day open

//PLOTS
Plot( cdl( H1 ), "", colorRed, styleLine + styleThick + styleNoRescale + styleNoLabel );
Plot( cdl( L1 ), "", colorBrightGreen, styleLine + styleThick + styleNoLabel );
Plot( cdl( C1 ), "", colorLightGrey, styleLine + styleNoRescale + styleNoLabel );
_SECTION_END();
 

jsb2012

Active Member
#6
Seniors i want to plot the hi, lo & close of 3 hour candle (9.30am to 12.30pm)of previous day. Pls help me by giving afl code only for that its enough.rest i will take care pls
 

KelvinHand

Well-Known Member
#9
Seniors i want to plot the hi, lo & close of 3 hour candle (9.30am to 12.30pm)of previous day. Pls help me by giving afl code only for that its enough.rest i will take care pls
Code:
//----[KH]  After DayO

found = TimeNum()>=093000 AND TimeNum()<=123000;

H1 = IIf(found, LastValue(H1), Null);
L1 = IIf(found, LastValue(L1), Null);
C1 = IIf(found, LastValue(C1), Null);


found = TimeNum()==000000;
for(i=BarCount-1; i>0; i--)
   if (found[i]==True) break;

for(; i>0; i--)
{
    H1[i] = Null;
    L1[i] = Null;
    C1[i] = Null;
}

//----[KH]  Before PLOTS
 

KelvinHand

Well-Known Member
#10
Code:
//----[KH]  After DayO
function CDL( array )
{
    doy = DayOfYear();
    Lastdoy = doy == LastValue( doy );
    Dayline = array * Lastdoy;
    Dayline2 = IIf( Dayline, Dayline, Null );
    return IIf( TimeNum()>=093000 AND TimeNum()<=123000, Dayline2, Null);

}//PLOTS

Plot(cdl(H1), ...);
Plot(cdl(L1), ...);
Plot(cdl(C1), ...);
 

Similar threads