AFL to draw line at high and close

#1
Hi,
Could you please someone share the afl to draw horizontal line on yesterday high, low,close and open on todays chart.. for tomorrow it has to take todays high and low etc....

thanks
Bala
 

mastermind007

Well-Known Member
#2
Hi,
Could you please someone share the afl to draw horizontal line on yesterday high, low,close and open on todays chart.. for tomorrow it has to take todays high and low etc....

thanks
Bala
Code:
	Plot (LastValue(TimeFrameGetPrice("High", inDaily, 1)), "Prev H", colorGreen);
	Plot (LastValue(TimeFrameGetPrice("Low", inDaily, 1)), "Prev L", colorOrange);
 

josh1

Well-Known Member
#3
For Yesterday's High Low it should be -

Plot (LastValue(TimeFrameGetPrice("High", inDaily, -1)), "Prev H", colorGreen);
Plot (LastValue(TimeFrameGetPrice("Low", inDaily, -1)), "Prev L", colorOrange);

Is it possible to plot it on current day only? the lines are extended all the way on left side.
 

sr114

Well-Known Member
#4
For Yesterday's High Low it should be -

Plot (LastValue(TimeFrameGetPrice("High", inDaily, -1)), "Prev H", colorGreen);
Plot (LastValue(TimeFrameGetPrice("Low", inDaily, -1)), "Prev L", colorOrange);

Is it possible to plot it on current day only? the lines are extended all the way on left side.
Joshi

here its for u

HTML:
 _SECTION_BEGIN("Background_Setting");
 SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
 ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorGrey40)); 
 SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
 SetChartOptions(0,chartShowArrows|chartShowDates);
 grid_day = IIf(Day()!=Ref(Day(),-1),1,0); 
 Plot(grid_day,"",colorGrey50,styleHistogram|styleDots|styleNoLabel|styleOwnScale);

 SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
 Plot(C,"Close",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
 _SECTION_END();


SetBarsRequired(10000,10000); 

starttime = 091500; 
endtime = 153000;
tn = TimeNum(); 

timecond = tn >= starttime AND tn <= endtime; 
startday = tn == starttime; 

firstBarOfDay = deFlagFirstBarOfDay( starttime ); 
lastBarOfDay = deFlagLastBarOfDay( endtime); 

myHigh = ValueWhen(timecond, HighestSince(firstBarOfDay,High)); 
myLow = ValueWhen(timecond, LowestSince(firstBarOfDay,Low)); 

DH = TimeFrameCompress(myHigh, inDaily, compressLast); 
DL = TimeFrameCompress(myLow, inDaily, compressLast); 

DH = TimeFrameExpand(Ref(DH,-1),inDaily,expandFirst); 
DL = TimeFrameExpand(Ref(DL,-1),inDaily,expandFirst); 

Today = LastValue(Day());

Plot(IIf(Today == Day(),DH,Null),"YDH",colorBrightGreen,styleDashed | styleThick); 
Plot(IIf(Today == Day(),DL,Null),"YDL",colorRed,styleDashed | styleThick); 

Plot( timecond, "", colorDarkGrey, styleArea|styleOwnScale,0,1);
the yesterday high and yesterday low will be plotted only for today and it will not be extended left

rgds
subroto
 
Last edited:

josh1

Well-Known Member
#5
Subroto,

I am getting error in this line. Unexpected "(". Is there a missing semicolon at the end of previous line?

firstBarOfDay = deFlagFirstBarOfDay( starttime );

I have this code but it plots Yesterday's HI/Lo for each day on the chart which I don't like.

//Previous Days HI LO //

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open

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

YHL = ParamToggle("Yesterday HI LO","Show|Hide",0);
if(YHL==1) {
Plot(DayL,"YL",colorAqua,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorLightYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
// PlotText("-" , LastValue(BarIndex()-1), DayHI, colorTurquoise);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}
_SECTION_END();
 
Last edited:

josh1

Well-Known Member
#6
Subroto
Got some idea from your code and did it. Here is the final. Plots on current day only. It is basically part of "Essential Trader Tools".
I shall do it for pivot levels also. Charts look ugly if Pivots plotted for earlier days.
_SECTION_BEGIN("HI LO");

//Previous Days HI LO //

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open

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

YHL = ParamToggle("Yesterday HI LO","Show|Hide",0);
if(YHL==1) {
Plot(IIf(Today == Day(),DayL,Null),"YL",colorAqua,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayH,Null),"YH",colorLightYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
// PlotText("-" , LastValue(BarIndex()-1), DayHI, colorTurquoise);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}
_SECTION_END();
 
Last edited:

josh1

Well-Known Member
#7
Here it for Pivot levels. Worked like charm.

_SECTION_BEGIN("PIVOTS");

// Pivot Levels //
PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = (PP * 2) - DayL; R1I = LastValue (R1,1); // Resistance 1
S1 = (PP * 2) - DayH; 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
Today = LastValue(Day());

ppl = ParamToggle("Pivot Levels","Show|Hide",1);
if(ppl==1) {
Plot(IIf(Today == Day(),PP,Null), "PP",colorGold,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R1,Null), "R1",colorLightGrey,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S1,Null), "S1",colorPaleGreen,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R2,Null), "R2",colorLightGrey,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S2,Null), "S2",colorPaleGreen,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),R3,Null), "R3",colorLightGrey,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today == Day(),S3,Null), "S3",colorPaleGreen,styleDots|styleNoLine|styleNoRescale|styleNoTitle);

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

sr114

Well-Known Member
#8
Subroto,

I am getting error in this line. Unexpected "(". Is there a missing semicolon at the end of previous line?

firstBarOfDay = deFlagFirstBarOfDay( starttime );

I have this code but it plots Yesterday's HI/Lo for each day on the chart which I don't like.

//Previous Days HI LO //

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open

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

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

this happens due to the unavailability of the datetime plugins

the link is here

http://www.amibroker.org/3rdparty/deDateTime.zip

dnld the date plugings from here and put in the plugin directory then the code will work efficiently

http://www.amibroker.org/3rdparty/

rgds
subroto
 

mastermind007

Well-Known Member
#9
josh1

You did not even notice the actual fault. It was plotting wrong H L. Anyway here is the simple and corrected version of the code.

Code:
Plot (SelectedValue(TimeFrameGetPrice("H", inDaily, 1, expandLast)), "Prev H", IIf(abs(BarIndex() - SelectedValue(BarIndex())) > 5, GetChartBkColor(), colorGreen));
Plot (SelectedValue(TimeFrameGetPrice("L", inDaily, 1, expandLast)), "Prev L", IIf(abs(BarIndex() - SelectedValue(BarIndex())) > 5, GetChartBkColor(), colorOrange));
 

Similar threads