Johnny sir
ya i need this one thanks
Johnny sir,
This is nick ma with kbrain system in this system how can i omit the false signals please suggest me sir
_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ColorBlend(colorBlack, colorBlack, 0.2));
strWeekday = StrMid("SunMonTueWedThuFriSat", SelectedValue(DayOfWeek())*3,3);
GraphXSpace=Param("GraphXSpace",24,0,100,1);
//===========================================================================================//=================TITLE================================================================================================
_SECTION_BEGIN("Price Ploting");
pricestyle=ParamToggle("Price style","Bar|Candle",1);
if (pricestyle == 1)
{
Candlefill = IIf(C>=Ref(C,-1),ParamColor("Green candle",colorGreen),ParamColor("red candle",colorRed) );
SetBarFillColor (Candlefill);
PlotOHLC( Open, High, Low, Close, "", Candlefill, styleCandle,maskPrice);
}
if (pricestyle == 0)
{
Candlefill = IIf(C>=Ref(C,-1),ParamColor("Green candle",colorLime),ParamColor("red candle",colorRed) );
PlotOHLC( Open, High, Low, Close, "", Candlefill, styleBar,maskPrice);
}
pbfak= Param("Pin Bar Factor",3,0,100,0.25);
CR = abs(H-L);
CB = abs(O-C);
Candlecheck = IIf((CR >=(pbfak*CB)),1,0);
SetBarFillColor (IIf(Candlecheck ==1,candlefill,colorBlack));
PlotOHLC( Open, High, Low, Close, "", IIf(Candlecheck ==1,Candlefill,colorBlack), styleCandle,maskPrice);
_SECTION_END();
//=================TITLE================================================================================================
//=================TITLE================================================================================================
_SECTION_BEGIN("Breakout System");
N = Param("Breakout LookBack Period",12,2,100,1);
//Rx = Param("Range for Breakout",350,1,1000,1);
//Rx = Param("S/R Percentage", 0.5, 0.01,50,0.01);
HiLm = HHV(C,N);
LiLm = LLV(C,N);
Wvx = HiLm - LiLm;
Plot(LiLm, "", colorDarkOliveGreen, styleLine|styleDashed|styleThick);
Plot(HiLm, "", colorDarkRed, styleLine|styleDashed|styleThick);
_SECTION_END();
//================================================
_SECTION_BEGIN("Advanced Trend Lines");
ShowSR = ParamToggle("Show Vert S/R","No|Yes", 1);
SRPer = Param("S/R Percentage", 0.5, 0.1,50,0.1);
SRBack = Param("S/R Back", 1, 1,10,1);
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(ShowSR)
{
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, "", IIf(LastValue(C) > x, colorDarkGrey, colorViolet), styleLine|styleDashed|styleThick);
x0 = GetXResistance(H, SRPer, i);
y0 = GetYResistance(H, SRPer, i);
x = LineArray(x0, y0, x1, y0, 0);
Plot(x, "", IIf(LastValue(C) > x, colorDarkGrey, colorViolet), styleLine|styleDashed|styleThick);
}
}
//=========================================================================================
_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar,
[email protected]//
FS=Param("Font Size",20,11,100,1);
GfxSelectFont("Arial", FS, 400, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",625,1,1200,1);
Ver=Param("Vertical Position",1,500,1,1);
GfxTextOut("CMP "+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorWhite) );
//GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();
//=========================================================================================
//=========================================================================================
_SECTION_BEGIN("Volatility");
//by Vidyasagar,
[email protected]//
FS=Param("Font Size",20,11,100,1);
GfxSelectFont("Arial", FS, 50, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",ColorRGB(255,0,128)) );
Hor=Param("Horizontal Position",650,1,1200,1);
Ver=Param("Vertical Position",40,500,1,1);
GfxTextOut("Volt "+(H-L),Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorWhite) );
//GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();
//=========================================================================================
//=================TITLE================================================================================================
_SECTION_BEGIN("NICK MA Swing");
//SetBarsRequired(200,0);
//GraphXSpace = 5;
//SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );
//j=Haclose;
// Revision
jx = Param("J LookBack Period",3,2,100,1);
j= (HHV(C,jx)+ LLV(C,jx))/2;
//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(14);
rfsctor = WMA(H-L, Per);
revers = k * rfsctor;
Trend = 1;
NW[0] = 0;
for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j
< NW[i-1])
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;
if((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j > NW[i-1])
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;
if((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-1];
}
}
}
}
//===============system================
Plot(NW, "", IIf(Trend == 1, colorDarkOliveGreen, colorDarkRed), styleLine);
nma_test= Trend == 1;
Nma1=WriteIf(nma_test,"NmaL","");
NMAT = (Trend==1);
Buy=Cover=Cross(j,nw);
Sell=Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorWhite)+ "NICK MA Swing System" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
EncodeColor(colorRed) +"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+EncodeColor(colorBrightGreen) + "Bar Volatility =>" +(H-L)+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
/*
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
*/
PlotShapes(IIf(Buy, 23, shapeNone),colorSkyblue, 0, L, Offset=-20);
//PlotShapes(IIf(Buy, 1, shapeNone),colorLime, 0,L, Offset=-50);
//PlotShapes(IIf(Buy, 1, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, 24, shapeNone),colorCustom12, 0, H, Offset=-20);
//PlotShapes(IIf(Sell, 2, shapeNone),colorOrange, 0,H, Offset=50);
//PlotShapes(IIf(Sell, 2, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
//========================================================================
//========================================================================
//KBrain System Coded by Karthikmarar. Blog. www.stocktechnician.blogspot.com email. [email protected]
//System based on the BrainTrend system in Metatrader
// The Turquiose colored Dot indicates start of a Up Trend
// The Magenta DOt indicates end of an Up move and beginning of a downmove
// The system is a Stop and reverse system
//Revision Index - V.1.1 resolves the scan issues
_SECTION_BEGIN("KBrain");
//========================Initiation========================
bts=ParamToggle("BrainTrend1 signal","No|Yes" ,1);
btst=ParamToggle("BrainTrend1 stop","No|Yes" ,1);
btsl=ParamToggle("BrainTrend1 stop line","No|Yes" ,1);
period=Param("Period",10,6,100,1);
x1=53;
x2=47;
d=2.3;
f=7;
s=1.5;
range=ATR(f);
Range1 = ATR(f)/d;
Range2 = (ATR(f)*s)/4;
range3=ATR(10);
//R = ((HHV(H,period) - C) /(HHV (H,period) -LLV (L,period))) *-100;
R = ((HHV(C,period) - C) /(HHV (C,period) -LLV (C,period))) *-100;
//R1 SELECT MA
Usema = Param("UsedMA EMA=1| DEMA=2| GSMA=3| T3MA=4",5,1,5,1);
PI = 3.1415926;
//A=C-Ref(C,-T1);
//a[0]=C[0];
function IIR2( input, f0, f1, f2 )
{
result[ 0 ] = input[ 0 ];
result[ 1 ] = input[ 1 ];
for( i = 10; i < BarCount; i++ )
{
result[ i ] = f0 * input[ i ] +
f1 * result[ i - 1 ] +
f2 * result[ i - 2 ];
}
return result;
}
function GSMA( input, Period )
{
N = 0;
an = 2 * PI / Period;
c0 = b0 = 1;
c1 = b1 = b2 = a1 = a2 = gamma1 = 0;
beta1 = 2.415 * ( 1- cos( an ) );
alpha = -beta1 + sqrt( beta1 ^ 2 + 2 * beta1 );
alpha1 = ( cos( an ) + sin( an ) - 1 )/cos( an );
{
fo = alpha ^ 2;
f1 = 2 * ( 1- alpha ); f2 = -( 1 - alpha )*( 1 - alpha );
}
return IIR2( input, fo,f1,f2);
}
if(USema==3)
{
GSMA1= GSMA(R,Period);
GSMA2= GSMA(GSMA1,5);
Difference= GSMA1 - GSMA2;
ZeroLagEMA= GSMA1 + Difference;
value2=abs(ZeroLagEMA);
}
function T3(price,periods)
{
s = 0.84;
e1=EMA(price,periods);
e2=EMA(e1,Periods);
e3=EMA(e2,Periods);
e4=EMA(e3,Periods);
e5=EMA(e4,Periods);
e6=EMA(e5,Periods);
c1=-s*s*s;
c2=3*s*s+3*s*s*s;
c3=-6*s*s-3*s-3*s*s*s;
c4=1+3*s+s*s*s+3*s*s;
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;
return ti3;
}
if(USema == 4)
{
T3MA1= T3(R,Period);
T3MA2= T3(T3MA1,5);
Difference= T3MA1 - T3MA2;
ZeroLagEMA= T3MA1+ Difference;
value2=abs(ZeroLagEMA);
}
if(USema == 2)
{
DEMA1= DEMA(R,Period);
DEMA2= DEMA(DEMA1,5);
Difference= DEMA1 - DEMA2;
ZeroLagEMA= DEMA1 + Difference;
value2=abs(ZeroLagEMA);
}
if(USema == 1)
{
EMA1= EMA(R,Period);
EMA2= EMA(EMA1,5);
Difference= EMA1 - EMA2;
ZeroLagEMA= EMA1 + Difference;
value2=abs(ZeroLagEMA);
}
function ThreeGMA(Op,Hi,Lo,GPeriode,Kperiode)
{
kurs = (Op+Hi+Lo)/3;
lamda = GPeriode/Kperiode;
alpha = lamda*(GPeriode-1)/(GPeriode-lamda);
ma1 = WMA(kurs, GPeriode);
ma2 = WMA(ma1, KPeriode);
nmaw = (alpha+1)*ma1 - alpha*ma2;
return nmaw;
}
if(USema == 5)
{
GPeriode=Param("GPeriode", 15, 2, 500, 1 );
Kperiode=Param("KPeriode", 2, 2, 500, 1 );
GPeriode1=Param("GPeriode1", 2, 2, 500, 1 );
Kperiode1=Param("KPeriode1", 2, 2, 500, 1 );
nmaw1= ThreeGMA(R,R,R,GPeriode,Kperiode);
nmaw2= ThreeGMA(nmaw1,nmaw1,nmaw1,GPeriode1,Kperiode1);
//DEMA1= DEMA(R,Period);
//nmaw2= DEMA(DEMA1,5);
//nmaw2=DEMA(nmaw1,5);
Difference= nmaw1 - nmaw2;
ZeroLagEMA= nmaw1 + Difference;
value2=abs(ZeroLagEMA);
}
function PercentR( periods )
{
//return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods ) );
return -100 * ( HHV( C, periods ) - C )/( HHV( C, periods ) - LLV( C, periods ) );
}
for( i = 1; i < Period-1; i++ )
{
tm = 1;
bstop = 1;
sstop = 1;
p = 1;
}
for( i = period+10; i < BarCount; i++ )
{
C[0]=0;
Value2[0]=0;
p[0]=0;
Plot1[0]=0;
Plot2[0]=0;
Val1=0;
Val2=0;
temp[0]=0;
Value3[0]=0;
tm[0]=0;
p1=0;
bt1[0]=0;
bt2[0]=0;
r[0]=0;
bt1a[0]=0;
bt2a[0]=0;
istop[0]=Val1[0];
stop=Val1[0];
bstop[0]=0;
sstop=0;
//==================================Indicators============================
{
if (value2 < x2 AND abs(Close-Close[i-2]) > range1)
p = 1 ;
else
{
if (value2 > x1 AND abs(Close-Close[i-2]) > Range1)
p = 2 ;
else
p=0;
}
}
if ((value2 < x2 AND p == 1) OR (value2 < x2 AND p == 0))
{
if (abs(Close-Close[i-2]) > Range1)
{
Plot1=H;
Plot2=L;
}
else
{
Plot1=Plot1[i-1];
Plot2=Plot2[i-1];
}
}
else
{
if ((value2 > x1 AND p == 2) OR (value2 > x1 AND p == 0))
{
Plot1=L;
Plot2=H;
}
else
{
Plot1=Plot1[i-1];
Plot2=Plot2[i-1];
}
}
//==================KBrain Signal ====================================
{
if (value2 < x2 AND (abs(Close-Close[i-2]) > Range1))
{
if (p == 1 OR p == 0)
Value3=L-range3;
val1=Value3;
p=1;
temp=1;
}
else
{
temp=temp[i-1];
}
{
if (value2 > x1 AND (abs(Close-Close[i-2]) > Range1))
{
if (p == 2 OR p == 0)
Value3=H+range3;
val2=Value3;
p=2;
temp=2;;
}
}
}
{
if (temp==1 AND Plot1>0 AND tm != 1)
tm= 1;
if (temp==2 AND Plot2>0 AND tm != 2)
tm=2;
}
//===============================stop========================================
{
if (value2 < x2 AND (abs(Close-Close[i-2]) > Range1)AND p !=2)
{
value3=L-range3;
va1=Value3;
p1=2;
r=Va1;
bstop=Va1;
bt2=bt2[i-1];
}
if (value2 > x1 AND (abs(Close-Close[i-2]) > Range1)AND p !=1)
{
Value3=H+range3;
va2=Value3;
p1=1;
r=Va2;
sstop=Value3;
bt1=bt1[i-1];
}
}
if (val1 == 0 AND val2 == 0 AND p == 0 )
{
bstop=bstop[i-1];
sstop=sstop[i-1];
}
if (bstop<bstop[i-1] AND tm==1 AND tm[i-1]==1) bstop=bstop[i-1];
if (sstop>sstop[i-1] AND tm==2 AND tm[i-1]==2) sstop=sstop[i-1];
}
//=============================SYSTEM======================================
Mycolor=IIf(p==1,colorLime,IIf(p==2,colorRed,colorBlue));
//PlotOHLC( Open, High, Low, Close, "", Mycolor, styleCandle| styleThick );
PlotShapes( shapeSmallCircle* (bts AND tm==1 AND Ref(tm,-1)==2),colorTurquoise, 0, bstop, 10 );
PlotShapes( shapeSmallCircle* (bts AND tm==2 AND Ref(tm,-1)==1), colorCustom12, 0, sstop, 0 );
/*
PlotShapes( IIf(btst AND p==1,shapeSmallCircle,Null), colorTurquoise,0,bstop,0);
Plot(IIf(btsl AND tm==1,bstop,Null),"",colorPaleBlue,1);
PlotShapes( IIf(btst AND p==2,shapeSmallCircle,Null), colorCustom12,0,sstop,0);
Plot(IIf(btsl AND tm==2,sstop,Null),"",colorViolet,1);
*/
klong1_1_color = IIf(btsl AND tm==1,ColorRGB(0,128,192),ParamColor("klon1_R",ColorRGB(128,0,64)));
Plot( 3, "Ribbon",klong1_1_color,styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
//=================TITLE================================================================================================