Price Analyzer

yasu222

Active Member
#1
PHP:
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("Goodwill Research " + "{{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 )) ));


_SECTION_BEGIN("Price Band");
InitAFL();
SetBarsRequired(500, 500);
//Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Plot(Tulip(Name()), "Tulip", colorWhite, ParamStyle("Style") ); 
Plot(Jasmine(Name()), "Jasmine", colorWhite, ParamStyle("Style"));
_SECTION_END();


_SECTION_BEGIN("Price Metrics");
InitAFL();
//SetBarsRequired( -2, -2 ); 
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("Price Analyzer");
SetBarsRequired(-2,-2);
nb = Rose(Name());
WRange=0.5*ATR(10);
PlotTextSetFont("X","Arial Black",40,0,0,colorGreen);
for(i=0;i<BarCount-1;i++){
	if(nb[i]==1 ){
		PlotTextSetFont("Buy[" + C[i] + "]","Arial Black",10,i,L[i]-WRange[i],colorWhite);
	}else if(nb[i]==2){
		PlotText("Sell[" + C[i] + "]",i,H[i]+WRange[i],colorYellow);
	}
}
_SECTION_END();
 

yasu222

Active Member
#2
Price Metrics"

PHP:
_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();
 

yasu222

Active Member
#3
Price Guide

PHP:
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat(" Research " + "{{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 )) ));

function GetSafePrice(pos,cm){
pric=0;
	if(StrFind(Name(),"CRUD")==1){
			if(cm==1){pric = H[pos]+2;}else if(cm==2){pric = L[pos]-2;}
}else if(StrFind(Name(),"GOLD")==1){
		if(cm==1){pric = H[pos]+8;}else if(cm==2){pric = L[pos]-8;}
}else if(StrFind(Name(),"NGAS")==1){
		if(cm==1){pric = H[pos]+0.1;}else if(cm==2){pric = L[pos]-0.1;}
}else if(StrFind(Name(),"COPP")==1){
	if(cm==1){pric = H[pos]+0.2;}else if(cm==2){pric = L[pos]-0.2;}	
}else if(StrFind(Name(),"NICK")==1){
	if(cm==1){pric = H[pos]+2;}else if(cm==2){pric = L[pos]-2;}
}else if(StrFind(Name(),"SILV")==1){
	if(cm==1){pric = H[pos]+12;}else if(cm==2){pric = L[pos]-12;}
}
	return pric;
}

_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();

_SECTION_BEGIN("Price Metrics");
InitAFL();
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
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 ;
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ),0, IIf( Buy, Low, High+0.25) );
_SECTION_END();

_SECTION_BEGIN("Price Guide");
RequestTimedRefresh(55);
nj=Orange(Name());
nb=Banana(Name());
shapex=nj*shapeDownArrow+ nj *shapeUpArrow ;
colAr=IIf(nj==2,colorYellow,colorWhite);
WRange=0.5*ATR(10);
PlotShapes(shapex,colAr,0,IIf(nj==1,L-WRange,H+WRange));


SetBarFillColor(IIf(nb==2,colorWhite,IIf(nb==1,colorWhite,col)));
Plot( Close, "Price", col, styleCandle );
Dat=DateTime();
da = Day();mo = Month();ye = Year();

cm=0;lpr=0;fndBar=BarCount-1;fndDate="";
for(i=0;i<BarCount;i++){
	if(nb[i]==1){
			PlotText("Buy " + GetSafePrice(i ,1),i,L[i]-WRange[i],colorWhite);
			cm=1;lpr=GetSafePrice(i ,1);fndDate= DateTimeToStr(Dat[i]) + ":"  + C[i];fndBar=i;
	}else if(nb[i]==2){
			PlotText("Sell " + GetSafePrice( i,2),i,H[i]+WRange[i],colorYellow);
			cm=2;lpr=GetSafePrice(i ,2);fndDate= DateTimeToStr(Dat[i]) + ":"  + C[i];fndBar=i;
	}
}
_SECTION_END();

_SECTION_BEGIN("Price Indicator");
function FlipMe(V1,ho,mo){
	nj=0;
	if(mo==1){
		nj=V1 + ho;
	}else{
		nj=V1 - ho;
	}
	return nj;
}
_Ty = "";
_Tar=0;
_Stp=0;
if(cm==1){
_Ty="Buy";
}
else if(cm==2){
_Ty="Sell";
}

if(StrFind(Name(),"CRUD")==1){
	_Tar = FlipMe(lpr,20,cm);_Stp = FlipMe(lpr,-20,cm);	
}else if(StrFind(Name(),"GOLD")==1){
	_Tar = FlipMe(lpr,60,cm);_Stp = FlipMe(lpr,-60,cm);	
}else if(StrFind(Name(),"NGAS")==1){
	_Tar = FlipMe(lpr,1.6,cm);_Stp = FlipMe(lpr,-1.6,cm);	
}else if(StrFind(Name(),"COPP")==1){
	_Tar = FlipMe(lpr,1.5,cm);_Stp = FlipMe(lpr,-1.5,cm);	
}else if(StrFind(Name(),"NICK")==1){
	_Tar = FlipMe(lpr,8,cm);_Stp = FlipMe(lpr,-8,cm);	
}else if(StrFind(Name(),"SILV")==1){
	_Tar = FlipMe(lpr,150,cm);_Stp = FlipMe(lpr,-150,cm);	
}
valid=True;
Kindof = "";
if (cm==1){
if(C[BarCount-1]>_Tar || C[BarCount-1]<_Stp){
	valid=False;
	if(C[BarCount-1]>_Tar){
		Kindof="Target Reached";
	}else if(C[BarCount-1]<_Stp){
		Kindof="Stop Loss Reached";
	}
}else{ Kindof="Signal Active";}
}else if (cm==2){
if(C[BarCount-1]<_Tar || C[BarCount-1]>_Stp){
	valid=False;
	if(C[BarCount-1]<_Tar){
		Kindof="Target Reached";
	}else if(C[BarCount-1]>_Stp){
		Kindof="Stop Loss Reached";
	}

}else{ Kindof="Signal Active";}
}
if(lpr >0 AND cm>0 AND valid==True){	
	GfxSelectFont( "Tahoma", 13, 100 );
	GfxSelectSolidBrush( colorGreen);
	GfxSetBkMode( 1 );
	GfxSetTextColor( colorWhite );
	pxHeight = Status("pxchartheight" ) ;
	x = 5;	x2 = 130;	y = 70;
	GfxSelectPen( colorGreen, 1);
	GfxRoundRect( x, y - 50, x2+40, y-20 , 7, 7 ) ;
	n= BarCount-1;
	GfxTextOut(("" + _Ty + " @ :" + WriteVal(lpr,1.2)),8,y-45);
	GfxSelectSolidBrush( colorBlue);
	GfxRoundRect( x, y-15 , x2+40, y+15, 7, 7 ) ;
	GfxSetTextColor( colorWhite );
	GfxTextOut("Target: " +  _Tar ,7,y-10);
	GfxSelectSolidBrush( colorYellow);
	GfxRoundRect( x, y+20 , x2+40, y+55 , 7, 7 ) ;
	GfxSetTextColor( colorRed );
	GfxTextOut("Stop Loss: " +  _Stp ,7,y+25);	
}
_SECTION_END();