_SECTION_BEGIN("Price Metrics");
L1Color=colorGreen;L2Color=colorRed;
okg=colorGreen;okr=colorRed;
col=colorWhite;
col=IIf(O>C,okg,okr);
Buy=Cross(MACD( ), Signal());Sell=Cross(Signal(), MACD());Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);okg=colorGreen;okr=colorRed;
col=IIf( MACD()>Signal(), colorLightBlue, colorRed);//CONT
SetBarFillColor(col);
Plot( Close, "Price", col, styleCandle );
b =Optimize("Buy Trigger",70,70,70,1);s=Optimize("Sell Trigger",30,30,30,1);
Sell=Cross(RSI(),b);Buy=Cross(s,RSI());
shape = Buy * shapeCircle +Sell * shapeCircle ;
WTop=0.25*ATR(10);
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ),0, IIf( Buy, Low-WTop, High+WTop) );
_SECTION_END();
_SECTION_BEGIN("ATC");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
SetChartBkColor(colorBlack);
Plot( C, "Close", colorWhite, styleBar, Zorder = 1);
SetChartOptions(0,chartShowArrows | chartShowDates);
P = ParamField("Price field",-1);
Length = 150;
Daysback = Param("Period for Liner Regression Line",Length,1,240,1);
shift = Param("Look back period",0,0,240,1);
x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );
LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
LRStyle = ParamStyle("LR Style");
Angle = Param("Angle", 0.05, 0, 1.5, 0.01);// A slope higher than 0.05 radians will turn green, less than -0.05 will turn red and anything in between will be white.
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
Pi = 3.14159265 * atan(1); // Pi
SlopeAngle = atan(bb)*(180/Pi);
LineUp = SlopeAngle > Angle;
LineDn = SlopeAngle < - Angle;
if(LineUp)
{
Plot(LRLine, "Lin. Reg. Line Up", IIf(LineUp, colorBrightGreen, colorWhite), LRStyle);
}
else
{
Plot(LRLine, "Lin. Reg. Line Down", IIf(LineDn, colorDarkRed, colorWhite), LRStyle);
}
//========================== Plot 1st SD Channel ======================================================================================================
SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;
width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); //Set width of inside chanels here.
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;
SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");
Plot( SDU , "Upper Lin Reg", colorWhite,SDStyle ); //Inside Regression Lines
Plot( SDL , "Lower Lin Reg", colorWhite,SDStyle ); //Inside Regression Lines
//========================== Plot 2d SD Channel ========================================================================================================
SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;
width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); //Set width of outside chanels here.
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;
SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");
Plot( SDU2 , "Upper Lin Reg", colorWhite,SDStyle2 ); //OutSide Regression Lines
Plot( SDL2 , "Lower Lin Reg", colorWhite,SDStyle2 ); //OutSide Regression Lines
Trend = IIf(LRLine > Ref(LRLine,-1),colorGreen,colorRed);//Changes LR line to green if sloping up and red if sloping down.
Plot( LRLine , "LinReg", Trend, LRSTYLE );
//============================ End Indicator Code ========================================================================================================
_SECTION_END();
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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
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());
_SECTION_END();
_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();
_SECTION_BEGIN("Lable");
GfxSelectFont( "Tahoma", 13, 100 );
GfxSelectSolidBrush( colorYellow);
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue);
pxHeight = Status("pxchartheight" ) ;
pxWidth = Status("pxchartwidth" ) ;
x = 5;
x2 =220;
y = pxHeight;//240;
GfxSelectPen( colorGold, 2);
GfxRoundRect( pxWidth, 20, pxWidth-160, 50 , 7, 7 ) ;
n= BarCount-1;
GfxTextOut(("CMP :" + WriteVal(C[n])),pxWidth-150,20);
_SECTION_END();