Simple Coding Help - No Promise.

only today validity signals

Require AFL for below condition -

Buy above 300 simple moving average with only today date validity...

Advance Deevali wishes..
 
dear all
i wants this stratergy amibroker afl can any one create this simple code
1. candle heakin ashi
2. buy at 21 moving average and sell at 21 moving average when signal candle close with buy sell signal
pls
thanks
 

amitrandive

Well-Known Member
dear all
i wants this stratergy amibroker afl can any one create this simple code
1. candle heakin ashi
2. buy at 21 moving average and sell at 21 moving average when signal candle close with buy sell signal
pls
thanks

Try this


Code:
HaClose = (O+H+L+C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), .40); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 
xDiff = (HaHigh - Halow) * IIf(StrFind(Name(),""),100,10000);
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle ); 
 
    Plot(EMA(Close,21),"21EMA",colorRed,style=styleThick);
    Buy=Cross(HaClose,EMA(Close,21));
    Sell=Cross(EMA(Close,21),HaClose);
    Short=Sell;
    Cover=Buy;
    shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
    PlotShapes( shape, IIf( Buy, colorBlue, colorYellow ), 0, IIf( Buy, Low, High ) );
    _SECTION_END();
 
First of all use code tags if you insert code in a forum!
Sorry for being novice , but how to tag code in a post.

Thanx
 
Hello All,

The below afl plots open, high, low, close price in horizontal lines for different timeframes. But the text of some of the timeframes overlaps each other when either of OHLC prices are same. Since I don't no coding can some one please help me to code which slides/aligns the text thru parameters.


Code:
_SECTION_BEGIN("OHLC");

//Previous Month OHLC //

PMonthH = TimeFrameGetPrice("H", inMonthly, -1); PMonthHI = LastValue (PMonthH,1);// LastMonth high
PMonthL = TimeFrameGetPrice("L", inMonthly, -1); PMonthLI = LastValue (PMonthL,1); // LastMonth low
PMonthC = TimeFrameGetPrice("C", inMonthly, -1); PMonthCI = LastValue (PMonthC,1);// LastMonth close
PMonthO = TimeFrameGetPrice("O", inMonthly, -1); PMonthOI = LastValue (PMonthO,1);// LastMonth open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
PMHL = ParamToggle("PreviousMonth OHLC","Hide|Show",0);
if(PMHL==1) {

Plot(IIf(Today == Day(),PMonthL,Null),"PML",ParamColor("PML Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthH,Null),"PMH",ParamColor("PMH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthC,Null),"PMC",ParamColor("PMC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthO,Null),"PMO",ParamColor("PMO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("PMH" , LastValue(BarIndex())-(numbars/Hts), PMonthHI, colorGreen);
PlotText("PML" , LastValue(BarIndex())-(numbars/Hts), PMonthLI, colorRed);
PlotText("PMC" , LastValue(BarIndex())-(numbars/Hts), PMonthCI, colorBlue);
PlotText("PMO" , LastValue(BarIndex())-(numbars/Hts), PMonthOI, colorDarkYellow);

}

//This Month OHLC //

MonthH = TimeFrameGetPrice("H", inMonthly, 0); MonthHI = LastValue (MonthH,1);// ThisMonth high
MonthL = TimeFrameGetPrice("L", inMonthly, 0); MonthLI = LastValue (MonthL,1); // ThisMonth low
MonthC = TimeFrameGetPrice("C", inMonthly, 0); MonthCI = LastValue (MonthC,1);// ThisMonth close
MonthO = TimeFrameGetPrice("O", inMonthly, 0); MonthOI = LastValue (MonthO,1);// ThisMonth open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
MHL = ParamToggle("ThisMonth OHLC","Hide|Show",0);
if(MHL==1) {

Plot(IIf(Today == Day(),MonthL,Null),"ML",ParamColor("ML Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthH,Null),"MH",ParamColor("MH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthC,Null),"MC",ParamColor("MC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthO,Null),"MO",ParamColor("MO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("MH" , LastValue(BarIndex())-(numbars/Hts), MonthHI, colorGreen);
PlotText("ML" , LastValue(BarIndex())-(numbars/Hts), MonthLI, colorRed);
PlotText("MC" , LastValue(BarIndex())-(numbars/Hts), MonthCI, colorBlue);
PlotText("MO" , LastValue(BarIndex())-(numbars/Hts), MonthOI, colorDarkYellow);

}




//Previous Week OHLC //

PWeekH = TimeFrameGetPrice("H", inWeekly, -1); PWeekHI = LastValue (PWeekH,1);// LastWeek high
PWeekL = TimeFrameGetPrice("L", inWeekly, -1); PWeekLI = LastValue (PWeekL,1); // LastWeek low
PWeekC = TimeFrameGetPrice("C", inWeekly, -1); PWeekCI = LastValue (PWeekC,1);// LastWeek close
PWeekO = TimeFrameGetPrice("O", inWeekly, -1); PWeekOI = LastValue (PWeekO,1);// LastWeek open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
PWHL = ParamToggle("PreviousWeek OHLC","Hide|Show",0);
if(PWHL==1) {

Plot(IIf(Today == Day(),PWeekL,Null),"PWL",ParamColor("PWL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekH,Null),"PWH",ParamColor("PWH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekC,Null),"PWC",ParamColor("PWC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekO,Null),"PWO",ParamColor("PWO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("PWH" , LastValue(BarIndex())-(numbars/Hts), PWeekHI, colorGreen);
PlotText("PWL" , LastValue(BarIndex())-(numbars/Hts), PWeekLI, colorRed);
PlotText("PWC" , LastValue(BarIndex())-(numbars/Hts), PWeekCI, colorBlue);
PlotText("PWO" , LastValue(BarIndex())-(numbars/Hts), PWeekOI, colorDarkYellow);

}

//This Week OHLC //

WeekH = TimeFrameGetPrice("H", inWeekly, 0); WeekHI = LastValue (WeekH,1);// ThisWeek high
WeekL = TimeFrameGetPrice("L", inWeekly, 0); WeekLI = LastValue (WeekL,1); // ThisWeek low
WeekC = TimeFrameGetPrice("C", inWeekly, 0); WeekCI = LastValue (WeekC,1);// ThisWeek close
WeekO = TimeFrameGetPrice("O", inWeekly, 0); WeekOI = LastValue (WeekO,1);// ThisWeek open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
WHL = ParamToggle("ThisWeek OHLC","Hide|Show",0);
if(WHL==1) {

Plot(IIf(Today == Day(),WeekL,Null),"WL",ParamColor("WL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekH,Null),"WH",ParamColor("WH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekC,Null),"WC",ParamColor("WC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekO,Null),"WO",ParamColor("WO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("WH" , LastValue(BarIndex())-(numbars/Hts), WeekHI, colorGreen);
PlotText("WL" , LastValue(BarIndex())-(numbars/Hts), WeekLI, colorRed);
PlotText("WC" , LastValue(BarIndex())-(numbars/Hts), WeekCI, colorBlue);
PlotText("WO" , LastValue(BarIndex())-(numbars/Hts), WeekOI, colorDarkYellow);

}


//Previous Days OHLC //

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); DayCI = LastValue (DayC,1);// yesterdays close
DayO = TimeFrameGetPrice("O", inDaily, -1); DayOI = LastValue (DayO,1);// current day open

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

YHL = ParamToggle("Yesterday OHLC","Hide|Show",0);
if(YHL==1) {
Plot(IIf(Today == Day(),DayL,Null),"YL",ParamColor("YL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayH,Null),"YH",ParamColor("YH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayC,Null),"YC",ParamColor("YC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayO,Null),"YO",ParamColor("YO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

// PlotText("-" , LastValue(BarIndex()-1), DayHI, colorTurquoise);
PlotText("YH" , LastValue(BarIndex())-(numbars/Hts), DayHI, colorGreen);
PlotText("YL" , LastValue(BarIndex())-(numbars/Hts), DayLI, colorRed);
PlotText("YC" , LastValue(BarIndex())-(numbars/Hts), DayCI, colorBlue);
PlotText("YO" , LastValue(BarIndex())-(numbars/Hts), DayOI, colorDarkYellow);

}
_SECTION_END();
Screenshot for your reference.

 

amitrandive

Well-Known Member
Hello All,

The below afl plots open, high, low, close price in horizontal lines for different timeframes. But the text of some of the timeframes overlaps each other when either of OHLC prices are same. Since I don't no coding can some one please help me to code which slides/aligns the text thru parameters.


Code:
_SECTION_BEGIN("OHLC");

//Previous Month OHLC //

PMonthH = TimeFrameGetPrice("H", inMonthly, -1); PMonthHI = LastValue (PMonthH,1);// LastMonth high



}
_SECTION_END();
Screenshot for your reference.

Try this , have modified to be align

Code:
_SECTION_BEGIN("Price1");
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() ); 
_SECTION_END();

_SECTION_BEGIN("OHLC");

//Previous Month OHLC //

PMonthH = TimeFrameGetPrice("H", inMonthly, -1); PMonthHI = LastValue (PMonthH,1);// LastMonth high
PMonthL = TimeFrameGetPrice("L", inMonthly, -1); PMonthLI = LastValue (PMonthL,1); // LastMonth low
PMonthC = TimeFrameGetPrice("C", inMonthly, -1); PMonthCI = LastValue (PMonthC,1);// LastMonth close
PMonthO = TimeFrameGetPrice("O", inMonthly, -1); PMonthOI = LastValue (PMonthO,1);// LastMonth open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
PMHL = ParamToggle("PreviousMonth OHLC","Hide|Show",0);
if(PMHL==1) {

Plot(IIf(Today == Day(),PMonthL,Null),"PML",ParamColor("PML Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthH,Null),"PMH",ParamColor("PMH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthC,Null),"PMC",ParamColor("PMC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthO,Null),"PMO",ParamColor("PMO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("PMH" , LastValue(BarIndex())+(0), PMonthHI, colorGreen);
PlotText("PML" , LastValue(BarIndex())+(0), PMonthLI, colorRed);
PlotText("PMC" , LastValue(BarIndex())+(0), PMonthCI, colorBlue);
PlotText("PMO" , LastValue(BarIndex())+(0), PMonthOI, colorDarkYellow);

}

//This Month OHLC //

MonthH = TimeFrameGetPrice("H", inMonthly, 0); MonthHI = LastValue (MonthH,1);// ThisMonth high
MonthL = TimeFrameGetPrice("L", inMonthly, 0); MonthLI = LastValue (MonthL,1); // ThisMonth low
MonthC = TimeFrameGetPrice("C", inMonthly, 0); MonthCI = LastValue (MonthC,1);// ThisMonth close
MonthO = TimeFrameGetPrice("O", inMonthly, 0); MonthOI = LastValue (MonthO,1);// ThisMonth open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
MHL = ParamToggle("ThisMonth OHLC","Hide|Show",0);
if(MHL==1) {

Plot(IIf(Today == Day(),MonthL,Null),"ML",ParamColor("ML Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthH,Null),"MH",ParamColor("MH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthC,Null),"MC",ParamColor("MC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthO,Null),"MO",ParamColor("MO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("MH" , LastValue(BarIndex())-(0), MonthHI, colorGreen);
PlotText("ML" , LastValue(BarIndex())-(0), MonthLI, colorRed);
PlotText("MC" , LastValue(BarIndex())-(0), MonthCI, colorBlue);
PlotText("MO" , LastValue(BarIndex())-(0), MonthOI, colorDarkYellow);

}




//Previous Week OHLC //

PWeekH = TimeFrameGetPrice("H", inWeekly, -1); PWeekHI = LastValue (PWeekH,1);// LastWeek high
PWeekL = TimeFrameGetPrice("L", inWeekly, -1); PWeekLI = LastValue (PWeekL,1); // LastWeek low
PWeekC = TimeFrameGetPrice("C", inWeekly, -1); PWeekCI = LastValue (PWeekC,1);// LastWeek close
PWeekO = TimeFrameGetPrice("O", inWeekly, -1); PWeekOI = LastValue (PWeekO,1);// LastWeek open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
PWHL = ParamToggle("PreviousWeek OHLC","Hide|Show",0);
if(PWHL==1) {

Plot(IIf(Today == Day(),PWeekL,Null),"PWL",ParamColor("PWL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekH,Null),"PWH",ParamColor("PWH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekC,Null),"PWC",ParamColor("PWC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekO,Null),"PWO",ParamColor("PWO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("PWH" , LastValue(BarIndex())-(10), PWeekHI, colorGreen);
PlotText("PWL" , LastValue(BarIndex())-(10), PWeekLI, colorRed);
PlotText("PWC" , LastValue(BarIndex())-(10), PWeekCI, colorBlue);
PlotText("PWO" , LastValue(BarIndex())-(10), PWeekOI, colorDarkYellow);

}

//This Week OHLC //

WeekH = TimeFrameGetPrice("H", inWeekly, 0); WeekHI = LastValue (WeekH,1);// ThisWeek high
WeekL = TimeFrameGetPrice("L", inWeekly, 0); WeekLI = LastValue (WeekL,1); // ThisWeek low
WeekC = TimeFrameGetPrice("C", inWeekly, 0); WeekCI = LastValue (WeekC,1);// ThisWeek close
WeekO = TimeFrameGetPrice("O", inWeekly, 0); WeekOI = LastValue (WeekO,1);// ThisWeek open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
WHL = ParamToggle("ThisWeek OHLC","Hide|Show",0);
if(WHL==1) {

Plot(IIf(Today == Day(),WeekL,Null),"WL",ParamColor("WL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekH,Null),"WH",ParamColor("WH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekC,Null),"WC",ParamColor("WC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekO,Null),"WO",ParamColor("WO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("WH" , LastValue(BarIndex())-(5), WeekHI, colorGreen);
PlotText("WL" , LastValue(BarIndex())-(5), WeekLI, colorRed);
PlotText("WC" , LastValue(BarIndex())-(5), WeekCI, colorBlue);
PlotText("WO" , LastValue(BarIndex())-(5), WeekOI, colorDarkYellow);

}


//Previous Days OHLC //

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); DayCI = LastValue (DayC,1);// yesterdays close
DayO = TimeFrameGetPrice("O", inDaily, -1); DayOI = LastValue (DayO,1);// current day open

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

YHL = ParamToggle("Yesterday OHLC","Hide|Show",0);
if(YHL==1) {
Plot(IIf(Today == Day(),DayL,Null),"YL",ParamColor("YL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayH,Null),"YH",ParamColor("YH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayC,Null),"YC",ParamColor("YC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayO,Null),"YO",ParamColor("YO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

// PlotText("-" , LastValue(BarIndex()-1), DayHI, colorTurquoise);
PlotText("YH" , LastValue(BarIndex())-(numbars/Hts), DayHI, colorGreen);
PlotText("YL" , LastValue(BarIndex())-(numbars/Hts), DayLI, colorRed);
PlotText("YC" , LastValue(BarIndex())-(numbars/Hts), DayCI, colorBlue);
PlotText("YO" , LastValue(BarIndex())-(numbars/Hts), DayOI, colorDarkYellow);

}
_SECTION_END();
This idea is to modify the plot text with the numerical value to suit your requirement.For example

In this line of the code
Change the numerical value of 5 to suit your requirement.
Code:
PlotText("WH" , LastValue(BarIndex())-[COLOR="Blue"][B](5)[/B][/COLOR], WeekHI, colorGreen);
 
Thanks Amit for your reply.:thanx:

I have modified a bit by adding param. In case if any body needs, here is the code.

Code:
_SECTION_BEGIN("OHLC");

//Previous Month OHLC //

PMonthH = TimeFrameGetPrice("H", inMonthly, -1); PMonthHI = LastValue (PMonthH,1);// LastMonth high
PMonthL = TimeFrameGetPrice("L", inMonthly, -1); PMonthLI = LastValue (PMonthL,1); // LastMonth low
PMonthC = TimeFrameGetPrice("C", inMonthly, -1); PMonthCI = LastValue (PMonthC,1);// LastMonth close
PMonthO = TimeFrameGetPrice("O", inMonthly, -1); PMonthOI = LastValue (PMonthO,1);// LastMonth open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
PMHL = ParamToggle("PreviousMonth OHLC","Hide|Show",0);
if(PMHL==1) {

Plot(IIf(Today == Day(),PMonthL,Null),"PML",ParamColor("PML Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthH,Null),"PMH",ParamColor("PMH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthC,Null),"PMC",ParamColor("PMC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PMonthO,Null),"PMO",ParamColor("PMO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("PMH" , LastValue(BarIndex())+Param("PMHScale",0,-100,100), PMonthHI, colorGreen);
PlotText("PML" , LastValue(BarIndex())+Param("PMLScale",0,-100,100), PMonthLI, colorRed);
PlotText("PMC" , LastValue(BarIndex())+Param("PMCScale",0,-100,100), PMonthCI, colorBlue);
PlotText("PMO" , LastValue(BarIndex())+Param("PMOScale",0,-100,100), PMonthOI, colorDarkYellow);

}

//This Month OHLC //

MonthH = TimeFrameGetPrice("H", inMonthly, 0); MonthHI = LastValue (MonthH,1);// ThisMonth high
MonthL = TimeFrameGetPrice("L", inMonthly, 0); MonthLI = LastValue (MonthL,1); // ThisMonth low
MonthC = TimeFrameGetPrice("C", inMonthly, 0); MonthCI = LastValue (MonthC,1);// ThisMonth close
MonthO = TimeFrameGetPrice("O", inMonthly, 0); MonthOI = LastValue (MonthO,1);// ThisMonth open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
MHL = ParamToggle("ThisMonth OHLC","Hide|Show",0);
if(MHL==1) {

Plot(IIf(Today == Day(),MonthL,Null),"ML",ParamColor("ML Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthH,Null),"MH",ParamColor("MH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthC,Null),"MC",ParamColor("MC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),MonthO,Null),"MO",ParamColor("MO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("MH" , LastValue(BarIndex())+Param("MHScale",0,-100,100), MonthHI, colorGreen);
PlotText("ML" , LastValue(BarIndex())+Param("MLScale",0,-100,100), MonthLI, colorRed);
PlotText("MC" , LastValue(BarIndex())+Param("MCScale",0,-100,100), MonthCI, colorBlue);
PlotText("MO" , LastValue(BarIndex())+Param("MOScale",0,-100,100), MonthOI, colorDarkYellow);

}




//Previous Week OHLC //

PWeekH = TimeFrameGetPrice("H", inWeekly, -1); PWeekHI = LastValue (PWeekH,1);// LastWeek high
PWeekL = TimeFrameGetPrice("L", inWeekly, -1); PWeekLI = LastValue (PWeekL,1); // LastWeek low
PWeekC = TimeFrameGetPrice("C", inWeekly, -1); PWeekCI = LastValue (PWeekC,1);// LastWeek close
PWeekO = TimeFrameGetPrice("O", inWeekly, -1); PWeekOI = LastValue (PWeekO,1);// LastWeek open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
PWHL = ParamToggle("PreviousWeek OHLC","Hide|Show",0);
if(PWHL==1) {

Plot(IIf(Today == Day(),PWeekL,Null),"PWL",ParamColor("PWL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekH,Null),"PWH",ParamColor("PWH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekC,Null),"PWC",ParamColor("PWC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),PWeekO,Null),"PWO",ParamColor("PWO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("PWH" , LastValue(BarIndex())+Param("PWHScale",0,-100,100), PWeekHI, colorGreen);
PlotText("PWL" , LastValue(BarIndex())+Param("PWLScale",0,-100,100), PWeekLI, colorRed);
PlotText("PWC" , LastValue(BarIndex())+Param("PWCScale",0,-100,100), PWeekCI, colorBlue);
PlotText("PWO" , LastValue(BarIndex())+Param("PWOScale",0,-100,100), PWeekOI, colorDarkYellow);

}

//This Week OHLC //

WeekH = TimeFrameGetPrice("H", inWeekly, 0); WeekHI = LastValue (WeekH,1);// ThisWeek high
WeekL = TimeFrameGetPrice("L", inWeekly, 0); WeekLI = LastValue (WeekL,1); // ThisWeek low
WeekC = TimeFrameGetPrice("C", inWeekly, 0); WeekCI = LastValue (WeekC,1);// ThisWeek close
WeekO = TimeFrameGetPrice("O", inWeekly, 0); WeekOI = LastValue (WeekO,1);// ThisWeek open
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Today = LastValue(Day());
WHL = ParamToggle("ThisWeek OHLC","Hide|Show",0);
if(WHL==1) {

Plot(IIf(Today == Day(),WeekL,Null),"WL",ParamColor("WL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekH,Null),"WH",ParamColor("WH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekC,Null),"WC",ParamColor("WC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),WeekO,Null),"WO",ParamColor("WO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

PlotText("WH" , LastValue(BarIndex())+Param("WHScale",0,-100,100), WeekHI, colorGreen);
PlotText("WL" , LastValue(BarIndex())+Param("WLScale",0,-100,100), WeekLI, colorRed);
PlotText("WC" , LastValue(BarIndex())+Param("WCScale",0,-100,100), WeekCI, colorBlue);
PlotText("WO" , LastValue(BarIndex())+Param("WOScale",0,-100,100), WeekOI, colorDarkYellow);

}


//Previous Days OHLC //

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); DayCI = LastValue (DayC,1);// yesterdays close
DayO = TimeFrameGetPrice("O", inDaily, -1); DayOI = LastValue (DayO,1);// current day open

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

YHL = ParamToggle("Yesterday OHLC","Hide|Show",0);
if(YHL==1) {
Plot(IIf(Today == Day(),DayL,Null),"YL",ParamColor("YL Color",colorRed),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayH,Null),"YH",ParamColor("YH Color",colorGreen),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayC,Null),"YC",ParamColor("YC Color",colorBlue),styleLine|styleLine|styleNoRescale|styleNoTitle);
Plot(IIf(Today==Day(),DayO,Null),"YO",ParamColor("YO Color",colorTan),styleLine|styleLine|styleNoRescale|styleNoTitle);

// PlotText("-" , LastValue(BarIndex()-1), DayHI, colorTurquoise);
PlotText("YH" , LastValue(BarIndex())+Param("YHScale",0,-100,100), DayHI, colorGreen);
PlotText("YL" , LastValue(BarIndex())+Param("YLScale",0,-100,100), DayLI, colorRed);
PlotText("YC" , LastValue(BarIndex())+Param("YCScale",0,-100,100), DayCI, colorBlue);
PlotText("YO" , LastValue(BarIndex())+Param("YOScale",0,-100,100), DayOI, colorDarkYellow);

}
_SECTION_END();
 

Similar threads