afl for drawing different time frames in one chart

1sandeepgupta

Well-Known Member
#1
hi,I am posting one afl for drawing different time frames in one chart in different panes, simply drag and drop the afl into different panes and right click and select Parameters and then the time frame say Monthly,weekly or daily on daily data.

/*This will Plot monthly, weekly, AND daly charts in one chart but different panes. */
//==============================================================================================
SetChartBkGradientFill(colorWhite,colorLightGrey,colorWhite);
Period= ParamList("Base","Daily|Weekly|Monthly",0);

if(Period=="Monthly"){
TimeFrameSet(inMonthly);
PlotOHLC(Open, High, Low, Close, "Monthly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Weekly"){
TimeFrameSet(inWeekly);
PlotOHLC(Open, High, Low, Close, "weekly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Daily"){
TimeFrameSet(inDaily);
PlotOHLC(Open, High, Low, Close, "Daily Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
:)
 
Last edited:
#3
Dear 1sandeepgupta,

Thanks for the afl. In weekly time frame it was showing error. after removing the two lines given below the afl is working in all timeframes i.e daily/weekly/monthly.

=======================
Plot (R,"Resz",22,8+16);
Plot (s,"Supp",19,8+16);
=======================

further i am also having the same question as santoshv2k asked in the above message No.2
 

1sandeepgupta

Well-Known Member
#4
Hi I edited the script It will work fine now. I did not try the script in other time frames as I do not have the intra day data but I am posting the modified afl to work in other time frames also. Please find below and let me know if it worked ok. Thanks.

/*This will Plot monthly, weekly, daly, Hourly, 15 Minute, 5 Minute and 1 Minute charts in one chart but different panes. */
//==============================================================================================
SetChartBkGradientFill(colorWhite,colorLightGrey,colorWhite);
Period= ParamList("Base","Monthly|Weekly|Daily|Hourly|15Minute|5Minute|1Minute",0);

if(Period=="Monthly"){
TimeFrameSet(inMonthly);
PlotOHLC(Open, High, Low, Close, "Monthly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Weekly"){
TimeFrameSet(inWeekly);
PlotOHLC(Open, High, Low, Close, "weekly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Daily"){
TimeFrameSet(inDaily);
PlotOHLC(Open, High, Low, Close, "Daily Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Hourly"){
TimeFrameSet(inHourly);
PlotOHLC(Open, High, Low, Close, "Hourly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="15Minute"){
TimeFrameSet(in15Minute);
PlotOHLC(Open, High, Low, Close, "15Minute Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="5Minute"){
TimeFrameSet(in5Minute);
PlotOHLC(Open, High, Low, Close, "5Minute Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="1Minute"){
TimeFrameSet(in1Minute);
PlotOHLC(Open, High, Low, Close, "1Minute Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
 
Last edited:
#8
Hi,

Help requested for AFL formula for drawing 30min-5ema, Hourly-5ema & Daily-5ema lines in 5min chart (all 3 emas in same 5min chart). If possible selection required for previous or present bar of 30min/Hour/Daily (like "EOD" or "Next Day" for daily).

Regards,
Keerthi
 
#10
90minute option included

Code:
SetChartBkGradientFill(ParamColor("Color Top", colorWhite),ParamColor("Color Bottom", colorLightGrey),ParamColor("Color Title", colorWhite));
Period= ParamList("Base","Monthly|Weekly|Daily|90Minute|Hourly|15Minute|5Minute|1Minute",0);
Plotvol = ParamToggle("Plot Volume", "No|Yes");
style = styleCandle;
ColorOutline = ParamColor("Color outline", colorDarkGrey);
ColorVol = ParamColor("Color Volume", colorWhite);


if(Period=="Monthly"){
 TimeFrameSet(inMonthly);
 PlotOHLC(Open, High, Low, Close, "Monthly Price Chart", ColorOutline, style);
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="Weekly"){
 TimeFrameSet(inWeekly);
 PlotOHLC(Open, High, Low, Close, "Weekly Price Chart", ColorOutline, style );
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="Daily"){
 TimeFrameSet(inDaily);
 PlotOHLC(Open, High, Low, Close, "Daily Price Chart", ColorOutline, style );
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="90Minute"){
 TimeFrameSet(60*90);
 PlotOHLC(Open, High, Low, Close, "90Minute Price Chart", ColorOutline, style);
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="Hourly"){
 TimeFrameSet(inHourly);
 PlotOHLC(Open, High, Low, Close, "Hourly Price Chart", ColorOutline, style );
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="15Minute"){
 TimeFrameSet(in15Minute);
 PlotOHLC(Open, High, Low, Close, "15Minute Price Chart", ColorOutline, style );
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="5Minute"){
 TimeFrameSet(in5Minute);
 PlotOHLC(Open, High, Low, Close, "5Minute Price Chart", ColorOutline, style);
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
if(Period=="1Minute"){
 TimeFrameSet(in1Minute);
 PlotOHLC(Open, High, Low, Close, "1Minute Price Chart", ColorOutline, style);
 if(Plotvol == 1)
  Plot(V,"Volume",ColorVol, styleHistogram|styleOwnScale);
}
 

Similar threads