// Downloaded From https://www.WiseStockTrader.com
// Compilated from any

GfxSetBkMode(0);
	
_SECTION_BEGIN("Price");
ChartStyle = ParamToggle("ChartStyle", "Candles|Bars", 0);
if ( ChartStyle == 0 )
{
	BodyColor  =  IIf(C==O, colorBlue, IIf (C<O, colorRed, colorLime));
	SetBarFillColor(BodyColor);
	ChStyle = styleCandle;
}
else
if ( ChartStyle == 1 )
{
	BodyColor =  colorDarkGrey;
	ChStyle = styleBar|styleThick;
}

Plot(C,"Selected Bar Close", colorBlack, ChStyle|styleNoLabel); 
PR    = LastValue (Close);
PRCol = LastValue (BodyColor);
Plot(PR, "", PRCol, styleLine, Null, Null, 10);

// Time to Go
function GetSecondNum()
{
	Time = Now(4);
	Seconds = int(Time % 100);
	Minutes = int(Time / 100 % 100);
	Hours   = int(Time / 10000 % 100);
	SecondNum = int(Hours * 60 * 60 + Minutes * 60 + Seconds);
	return SecondNum;
}
	TimeFrame = Interval();
	SecNumber = GetSecondNum();
	Newperiod = SecNumber % TimeFrame == 0;
	SecsLeft  = SecNumber - int(SecNumber / TimeFrame) * TimeFrame;
	SecsToGo  = TimeFrame - SecsLeft;

	GfxSetTextColor(colorBlack);
	GfxSelectPen(colorBlack, 1);
	GfxSelectSolidBrush(colorLightYellow);	
	GfxRoundRect(12,24,230,50,6,6);
	GfxDrawText("Time to Go   "+SecsToGo+"   sec",12,24,230,50, 1|4|16|32);

// DAILY HI LO
DH = TimeFrameGetPrice("H", inDaily);
DL = TimeFrameGetPrice("L", inDaily);
HL = DH-DL;
CloudColor = colorDarkGrey;

if ( ParamToggle("Daily High Low","Hide|Show",0) )
{
	Plot(DH, "", colorOrange, styleStaircase|styleNoRescale, Null, Null, 0, 0, width = -80);
	Plot(DL, "", colorGreen,  styleStaircase|styleNoRescale, Null, Null, 0, 0, width = -80);
}
	GfxSetTextColor(colorBlack);
	GfxSelectPen(colorBlack, 1);
	GfxSelectSolidBrush(colorLightYellow);	
	GfxRoundRect(12,54,230,80,6,6);
	GfxDrawText("Daily Range = "+WriteVal(HL,1),12,54,230,80, 1|4|16|32);
_SECTION_END();


_SECTION_BEGIN("Sup_Res");
SRShow   = ParamToggle("Sup_Res","Hide|Show", 1);
SRBack   = Param("Levels Num", 3, 1, 20, 1);
SRPer    = Param("Accuracy", 0.5, 0.1, 5, 0.1);
SupColor = colorPink;
ResColor = colorPaleGreen;

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

if (SRShow)
{
    for (i=1; i<=SRBack; i++)
    {
        x0 = GetXSupport(L, SRPer, i);
        x1 = BarCount-1;
        y0 = GetYSupport(L, SRPer, i);
        x = LineArray(x0, y0, x1, y0, 0);
		Plot(x, "", ResColor, styleNoRescale, Null, Null, 0, 0, width = -60);

        x0 = GetXResistance(H, SRPer, i);
        y0 = GetYResistance(H, SRPer, i);
        x = LineArray(x0, y0, x1, y0, 0);
		Plot(x, "", SupColor, styleNoRescale, Null, Null, 0, 0, width = -60);
    }
} else { }
_SECTION_END();


_SECTION_BEGIN("Moving Averages");
Fast = Param("Period Fast",  8, 8, 50,1);
Slow = Param("Period Slow", 30,13,300,1);
ShowMA = ParamToggle("Moving Averages", "Hide|Show", 0);
if ( ShowMA == 1 )
{
	Plot(EMA(C, Fast), "", colorRed,  styleNoRescale, Null, Null, 0, 0, -30);
	Plot(EMA(C, Slow), "", colorBlue, styleNoRescale, Null, Null, 0, 0, -30);
}
_SECTION_END();