polynomial curve

cloudTrader

Well-Known Member
#12
leonid iam not yet thinking abt entries and exits but i got a rough idea when i was eyeballing the chart ,here it is for trend reversal i have 2 conditions,

1 - candle close is below than the blue center line and the curve shd be downwards like this,http://imgur.com/edit

2 - and candle close is above than the blue center line and the curve shd be upwards like this, http://imgur.com/edit



it is not like 100% accurate but iam looking forward to it
bunti, I was not able to view the images through the links you posted above.

However I would like to say that its off course good that you are testing your strategy. New things come up through testing .

I am posting a COG Timing Indicator ..it is an addition to COG .. Hope it is of help .. :thumb:

Code:
// COG timing indicator
// AFL translation by E.M.Pottasch, 2011
// from: http://chartstudio.whselfinvest.com/files/COGTiming.ctl

bi=BarIndex();	
eb=LastValue(bi);	
period=Param("Period",5,1,10,1);	
bars=Param("Lookback Period",100,50,500,1);
sv=ParamToggle("Use Selected Value","Off|On",1);
level1=4;
level2=8;
ul1=ul2=ll1=ll2=Null;
oo=hh=ll=cc=Null;
 
if (sv)
{
	eb=SelectedValue(bi);
	bb=Max(0,eb-bars);
}
else
{
	bb=Max(0,eb-bars);
}
for(i=bb+period-1;i<=eb;i++)
{
	ul1[i]=level1;
	ul2[i]=level2;
	ll1[i]=-level1;
	ll2[i]=-level2;
	am=0;
	ar=0;
	for(j=i-period+1;j<=i;j++)
	{
		am=am+(High[j]+Low[j])/2;
		ar=ar+(High[j]-Low[j])/5;
	}
	am=am/period;
	ar=ar/period;
	if(ar!=0)
	{
		oo[i]=(Open[i]-am)/ar;
		hh[i]=(High[i]-am)/ar;
		ll[i]=(Low[i]-am)/ar;
		cc[i]=(Close[i]-am)/ar;
	}
	else
	{
		oo[i]=0;
		hh[i]=0;
		ll[i]=0;
		cc[i]=0;
	}
}
C=cc;O=oo;H=hh;L=ll;
Plot(C,"",colorWhite,styleCandle);
//PlotOHLC(O,H,L,C,"",colorWhite,styleCandle);
//Plot(cc,"Close",colorWhite,styleThick);
//Plot(oo,"\nOpen",colorLightGrey,styleLine);
//Plot(hh,"\nHigh",colorRed,styleLine);
//Plot(ll,"\nLow",colorRed,styleLine);
Plot(ul1,"\nUpper Level 1",colorViolet,styleLine);
Plot(ul2,"\nUpper Level 2",colorViolet,styleLine);
Plot(ll1,"\nLower Level 1",colorViolet,styleLine);
Plot(ll2,"\nLower Level 2",colorViolet,styleLine);
Happy Trading.
 

bunti_k23

Well-Known Member
#13
so far by using diff diff combinations iam upto this ,if u take the trade on latest candle only ,tested on 1m tf target getting 1:2 risk reward ratio if the trend is in our direction then u can hav 1:3 rr trade also and so on....the signals are repainting i dont know how to fix them here is the changes.

http://imgur.com/A9a4p9Y


// COG: Center of Gravity indicator
// MODIFIED BY BUNTI_K23



tf = Param( "TF", 1, 1, 375, 1 );

TimeFrameSet(in1Minute*tf );






sx=Null;b=Null;ai=Null;x=Null;
reg=x1=x2=x3=z1=z2=z3=Null;
rega=x1a=x2a=x3a=z1a=z2a=z3a=Null;

bi=BarIndex();
eb=LastValue(bi);
order=Param("n-th Order",3,1,50,1);
bars=Param("Lookback Period",100,50,5000,1);
sv=ParamToggle("Use Selected Value","Off|On",1);
alt=ParamToggle("Error Levels","Fibonacci|Standard",0);
ecart=1.61803399;

if(sv)
{
eb=SelectedValue(bi);
bb=Max(0,eb-bars);
}
else
{
bb=Max(0,eb-bars);
}
fin=eb;
nn=order+1;
sx[1]=bars+1;

if(fin>bars)
{
for(mi=1;mi<=2*nn-2;mi++)
{
suml=0;
for(n=0;n<=bars;n++)
{
suml=suml+n^mi;
}
sx[mi+1]=suml;
}
for(mi=1;mi<=nn;mi++)
{
suml=0;
for(n=0;n<=bars;n++)
{
if (mi==1)
suml=suml+Close[fin-n];
else
suml=suml+Close[fin-n]*n^(mi-1);
b[mi]=suml;
}
}
for(jj=1;jj<=nn;jj++)
{
for(ii=1;ii<=nn;ii++)
{
kk=ii+jj-1;
ai[(ii-1)*nn+jj]=sx[kk];
}
}
for(kk=1;kk<=nn-1;kk++)
{
ll=0;
mm=0;
for(ii=kk;ii<=nn;ii++)
{
if(abs(ai[(ii-1)*nn+kk])>mm)
{
mm=abs(ai[(ii-1)*nn+kk]);
ll=ii;
}
}
if(ll==0) break;
if(ll!=kk)
{
for(jj=1;jj<=nn;jj++)
{
tt=ai[(kk-1)*nn+jj];
ai[(kk-1)*nn+jj]=ai[(ll-1)*nn+jj];
ai[(ll-1)*nn+jj]=tt;
}
tt=b[kk];
b[kk]=b[ll];
b[ll]=tt;
}
for(ii=kk+1;ii<=nn;ii++)
{
qq=ai[(ii-1)*nn+kk]/ai[(kk-1)*nn+kk];
for(jj=1;jj<=nn;jj++)
{
if(jj==kk)
ai[(ii-1)*nn+jj]=0;
else
ai[(ii-1)*nn+jj]=ai[(ii-1)*nn+jj]-qq*ai[(kk-1)*nn+jj];
}
b[ii]=b[ii]-qq*b[kk];
}
}
x[nn]=b[nn]/ai[nn*nn];
for(kk=1;kk<=nn-1;kk++)
{
tt=0;
ii=nn-kk;
for(jj=1;jj<=nn-ii;jj++)
{
tt=tt+ai[(ii-1)*nn+ii+jj]*x[ii+jj];
if(ai[(ii-1)*nn+ii]!=0)
x[ii]=(b[ii]-tt)/ai[(ii-1)*nn+ii];
}
}
for(n=0;n<=bars;n++)
{
suml=0;
for(kk=1;kk<=order;kk++)
{
suml=suml+x[kk+1]*n^kk;
}
reg[fin-n]=x[1]+suml;
}
}
SetChartOptions(0, chartShowDates);
Title = "Symbol: "+ Name()+ "\nPoly Order: "+order;
if(alt)
{
dev=StDev(Close-reg,bars);
sd=dev[fin];
x1a=reg+sd*1;//68%
x2a=reg+sd*2;//95%
x3a=reg+sd*3;//99.83%
z1a=reg-sd*1;
z2a=reg-sd*2;
z3a=reg-sd*3;
Plot(C, "Close",colorLightGrey,styleCandle);
Plot(reg,"reg",colorBlue,1);
Plot(x3a,"x3a",ColorRGB(255,0,0),styleThick);
Plot(x2a,"x2a",ColorRGB(255,100,100),styleDashed);
Plot(x1a,"x1a",ColorRGB(255,200,200),styleDashed);
Plot(z3a,"z3a",ColorRGB(0,255,0),styleThick);
Plot(z2a,"z2a",ColorRGB(100,255,100),styleDashed);
Plot(z1a,"z1a",ColorRGB(200,255,200),styleDashed);
PlotOHLC(x3a,x3a,x1a,x1a,"",ColorRGB(30,0,0),styleCloud|styleNoLabel,0,0,0,-1);
PlotOHLC(z1a,z1a,z3a,z3a,"",ColorRGB(0,30,0),styleCloud|styleNoLabel,0,0,0,-1);
}
else
{
dev=StDev(Close,bars);
sd=ecart*dev[fin];
x1=reg+sd/(1.382*1.618);
x2=reg+sd/1.382;
x3=reg+sd;
z1=reg-sd/(1.382*1.618);
z2=reg-sd/1.382;
z3=reg-sd;
Plot(C, "Close",colorLightGrey,styleCandle);
Plot(reg,"reg",colorBlue,1);
Plot(x3,"x3",ColorRGB(255,0,0),styleThick);
Plot(x2,"x2",ColorRGB(255,100,100),styleDashed);
Plot(x1,"x1",ColorRGB(255,200,200),styleDashed);
Plot(z3,"z3",ColorRGB(0,255,0),styleThick);
Plot(z2,"z2",ColorRGB(100,255,100),styleDashed);
Plot(z1,"z1",ColorRGB(200,255,200),styleDashed);
PlotOHLC(x3,x3,x2,x2,"",ColorRGB(30,0,0),styleCloud|styleNoLabel,0,0,0,-1);
PlotOHLC(z2,z2,z3,z3,"",ColorRGB(0,30,0),styleCloud|styleNoLabel,0,0,0,-1);
}





TimeFrameRestore();




/////////////////////////////////////


///////////////////////////////////

Sell = C < z2 ;

Buy = C > x2 ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

PlotShapes( Buy*shapeUpArrow, colorWhite, 0, Low );
PlotShapes( Sell*shapeDownArrow, colorWhite, 0, High );

//////////////////////////////////////
 

bunti_k23

Well-Known Member
#14
here is another version it will give signal pretty early....basically what iam doing is trying to place the trade when candle closses below or above the dotted lines...this version will signal if candle closses above or below the dotted line which is present below the blue line and abv it, in previous version signal was coming at when candle closes abv or below red and green dotted line...but the repainting problem is there.............:annoyed:


// COG: Center of Gravity indicator
// AFL code by E.M.Pottasch, 2011
// translated from: http://chartstudio.whselfinvest.com/files/CenterGravity_0.ctl

tf = Param( "TF", 1, 1, 375, 1 );

TimeFrameSet(in1Minute*tf );






sx=Null;b=Null;ai=Null;x=Null;
reg=x1=x2=x3=z1=z2=z3=Null;
rega=x1a=x2a=x3a=z1a=z2a=z3a=Null;

bi=BarIndex();
eb=LastValue(bi);
order=Param("n-th Order",3,1,50,1);
bars=Param("Lookback Period",100,50,5000,1);
sv=ParamToggle("Use Selected Value","Off|On",1);
alt=ParamToggle("Error Levels","Fibonacci|Standard",0);
ecart=1.61803399;

if(sv)
{
eb=SelectedValue(bi);
bb=Max(0,eb-bars);
}
else
{
bb=Max(0,eb-bars);
}
fin=eb;
nn=order+1;
sx[1]=bars+1;

if(fin>bars)
{
for(mi=1;mi<=2*nn-2;mi++)
{
suml=0;
for(n=0;n<=bars;n++)
{
suml=suml+n^mi;
}
sx[mi+1]=suml;
}
for(mi=1;mi<=nn;mi++)
{
suml=0;
for(n=0;n<=bars;n++)
{
if (mi==1)
suml=suml+Close[fin-n];
else
suml=suml+Close[fin-n]*n^(mi-1);
b[mi]=suml;
}
}
for(jj=1;jj<=nn;jj++)
{
for(ii=1;ii<=nn;ii++)
{
kk=ii+jj-1;
ai[(ii-1)*nn+jj]=sx[kk];
}
}
for(kk=1;kk<=nn-1;kk++)
{
ll=0;
mm=0;
for(ii=kk;ii<=nn;ii++)
{
if(abs(ai[(ii-1)*nn+kk])>mm)
{
mm=abs(ai[(ii-1)*nn+kk]);
ll=ii;
}
}
if(ll==0) break;
if(ll!=kk)
{
for(jj=1;jj<=nn;jj++)
{
tt=ai[(kk-1)*nn+jj];
ai[(kk-1)*nn+jj]=ai[(ll-1)*nn+jj];
ai[(ll-1)*nn+jj]=tt;
}
tt=b[kk];
b[kk]=b[ll];
b[ll]=tt;
}
for(ii=kk+1;ii<=nn;ii++)
{
qq=ai[(ii-1)*nn+kk]/ai[(kk-1)*nn+kk];
for(jj=1;jj<=nn;jj++)
{
if(jj==kk)
ai[(ii-1)*nn+jj]=0;
else
ai[(ii-1)*nn+jj]=ai[(ii-1)*nn+jj]-qq*ai[(kk-1)*nn+jj];
}
b[ii]=b[ii]-qq*b[kk];
}
}
x[nn]=b[nn]/ai[nn*nn];
for(kk=1;kk<=nn-1;kk++)
{
tt=0;
ii=nn-kk;
for(jj=1;jj<=nn-ii;jj++)
{
tt=tt+ai[(ii-1)*nn+ii+jj]*x[ii+jj];
if(ai[(ii-1)*nn+ii]!=0)
x[ii]=(b[ii]-tt)/ai[(ii-1)*nn+ii];
}
}
for(n=0;n<=bars;n++)
{
suml=0;
for(kk=1;kk<=order;kk++)
{
suml=suml+x[kk+1]*n^kk;
}
reg[fin-n]=x[1]+suml;
}
}
SetChartOptions(0, chartShowDates);
Title = "Symbol: "+ Name()+ "\nPoly Order: "+order;
if(alt)
{
dev=StDev(Close-reg,bars);
sd=dev[fin];
x1a=reg+sd*1;//68%
x2a=reg+sd*2;//95%
x3a=reg+sd*3;//99.83%
z1a=reg-sd*1;
z2a=reg-sd*2;
z3a=reg-sd*3;
Plot(C, "Close",colorLightGrey,styleCandle);
Plot(reg,"reg",colorBlue,1);
Plot(x3a,"x3a",ColorRGB(255,0,0),styleThick);
Plot(x2a,"x2a",ColorRGB(255,100,100),styleDashed);
Plot(x1a,"x1a",ColorRGB(255,200,200),styleDashed);
Plot(z3a,"z3a",ColorRGB(0,255,0),styleThick);
Plot(z2a,"z2a",ColorRGB(100,255,100),styleDashed);
Plot(z1a,"z1a",ColorRGB(200,255,200),styleDashed);
PlotOHLC(x3a,x3a,x1a,x1a,"",ColorRGB(30,0,0),styleCloud|styleNoLabel,0,0,0,-1);
PlotOHLC(z1a,z1a,z3a,z3a,"",ColorRGB(0,30,0),styleCloud|styleNoLabel,0,0,0,-1);
}
else
{
dev=StDev(Close,bars);
sd=ecart*dev[fin];
x1=reg+sd/(1.382*1.618);
x2=reg+sd/1.382;
x3=reg+sd;
z1=reg-sd/(1.382*1.618);
z2=reg-sd/1.382;
z3=reg-sd;
Plot(C, "Close",colorLightGrey,styleCandle);
Plot(reg,"reg",colorBlue,1);
Plot(x3,"x3",ColorRGB(255,0,0),styleThick);
Plot(x2,"x2",ColorRGB(255,100,100),styleDashed);
Plot(x1,"x1",ColorRGB(255,200,200),styleDashed);
Plot(z3,"z3",ColorRGB(0,255,0),styleThick);
Plot(z2,"z2",ColorRGB(100,255,100),styleDashed);
Plot(z1,"z1",ColorRGB(200,255,200),styleDashed);
PlotOHLC(x3,x3,x2,x2,"",ColorRGB(30,0,0),styleCloud|styleNoLabel,0,0,0,-1);
PlotOHLC(z2,z2,z3,z3,"",ColorRGB(0,30,0),styleCloud|styleNoLabel,0,0,0,-1);
}





TimeFrameRestore();




/////////////////////////////////////



///////////////////////////////////

Sell = C < z1 ;

Buy = C > x1 ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

PlotShapes( Buy*shapeUpArrow, colorWhite, 0, Low );
PlotShapes( Sell*shapeDownArrow, colorWhite, 0, High );

//////////////////////////////////////
 

bunti_k23

Well-Known Member
#15
hello guys i was working on polynomial curve so far by filtering using different combinations of set of indicators i finally made this version which i found good on backtesting (manually).i will be using this version to trade in january so uptil then in this mean time if i m able to make any further improvements i will post it.:)
 

bunti_k23

Well-Known Member
#16
CONSTRUCTION AND LOGIC USED IN THE SYSTEM :

after using different combinations ive found out the price mostly remains within the dotted line x1 and z1 which is located above and below the cog line (dark blue) and whenever price breaks this zone price tend to shift the trend and the move was big enough. so we are taking entry on a trend reversal mode .so i was looking to enter at these levels ,uptil now i figured out the entry but there were way more wrong trades associated with it so my sole aim was to filter the wrong trades without loosing good trades .then i combined some suitable situations of adx (by using hit and try method ) so we are taking entry at trend reversal mode and ensuring that our direction is right by adx .i added another volatality indicator (bollingerband squeeze ) which i found tj forum itself in old posts from amibroker section .just to again ensure that the volatality is increasing to our desired direction .

uptil now i figured out there were 2 things clear in the system
1- entry
2- stoploss(must be above or below of candle and fibonacci level ).

the 3rd thing is hard to configure that is exit.the system gives nice 1:1.5 rr trades ,so either take exit on 1.5 rr or trail the stoploss further to see the move.later i added fibonacci retracement levels to take exit on proper levels its gelling up with the system almost properly.:)

by manual backtesting i see winning 6/10 trades and drawdown of continous 3 wrong trades(losing streak).
 

bunti_k23

Well-Known Member
#17
RULES

1-ENTRY

a - entry is defined by arrow ,whenever arrow appears on latest candle trade can be initiated only by confirmation of next candle ,next candle should break high or low of signal candle or if any fibonacci level is near our entry wait to close the candle above or below it

b - if the signal is not confirmed u can take REVERSE ENTRY only on break of fibonacci level
target will be upper fibonacci levels.

if the trade procedes successfully in our direction after 1:1.5 rr trail the stoploss below the fibonacci levels

NOTE : NEGLECT ENTRIES ON LONG BAR DUE TO RISK INITIATED WITH IT ENTRY CAN BE DONE FURTHER AFTER SOME FIBONACCI RETRACEMENT.

2- STOPLOSS

stoploss can be placed above or below of fibonacci level near to signal candle

3 - TARGET

1st target is 1.5 reward level and further targets can be expected by fibonacci levels
 

bunti_k23

Well-Known Member
#18
UPDATED CODE:)


Code:
// COG: Center of Gravity indicator
// AFL code by E.M.Pottasch, 2011
// translated from: http://chartstudio.whselfinvest.com/files/CenterGravity_0.ctl
 
tf = Param( "TF", 1, 1, 375, 1 );

TimeFrameSet(in1Minute*tf );






sx=Null;b=Null;ai=Null;x=Null;
reg=x1=x2=x3=z1=z2=z3=Null;
rega=x1a=x2a=x3a=z1a=z2a=z3a=Null; 
     
bi=BarIndex(); 
eb=LastValue(bi);  
order=Param("n-th Order",1,1,50,1); 
bars=Param("Lookback Period",100,50,5000,1);
sv=ParamToggle("Use Selected Value","Off|On",1);
alt=ParamToggle("Error Levels","Fibonacci|Standard",0);
ecart=1.61803399;
   
if(sv)
{
    eb=SelectedValue(bi);
    bb=Max(0,eb-bars);
}
else
{
    bb=Max(0,eb-bars);
}
fin=eb;
nn=order+1;
sx[1]=bars+1;
 
if(fin>bars)
{
for(mi=1;mi<=2*nn-2;mi++)
{
    suml=0;
    for(n=0;n<=bars;n++)
    {
        suml=suml+n^mi;
    }
    sx[mi+1]=suml;
}
for(mi=1;mi<=nn;mi++)
{
    suml=0;
    for(n=0;n<=bars;n++)
    {
        if (mi==1)
            suml=suml+Close[fin-n];
        else
            suml=suml+Close[fin-n]*n^(mi-1);
            b[mi]=suml;
    }
}
for(jj=1;jj<=nn;jj++)
{
    for(ii=1;ii<=nn;ii++)
    {
        kk=ii+jj-1;
        ai[(ii-1)*nn+jj]=sx[kk];
    }
}
for(kk=1;kk<=nn-1;kk++)
{
    ll=0;
    mm=0;
    for(ii=kk;ii<=nn;ii++)
    {
        if(abs(ai[(ii-1)*nn+kk])>mm)
        {
            mm=abs(ai[(ii-1)*nn+kk]);
            ll=ii;
        }
    }
    if(ll==0) break;
    if(ll!=kk)
    {
        for(jj=1;jj<=nn;jj++)
        {
            tt=ai[(kk-1)*nn+jj];
            ai[(kk-1)*nn+jj]=ai[(ll-1)*nn+jj];
            ai[(ll-1)*nn+jj]=tt;
        }
        tt=b[kk];
        b[kk]=b[ll];
        b[ll]=tt;
    }
    for(ii=kk+1;ii<=nn;ii++)
    {
        qq=ai[(ii-1)*nn+kk]/ai[(kk-1)*nn+kk];
        for(jj=1;jj<=nn;jj++)
        {
            if(jj==kk)
                ai[(ii-1)*nn+jj]=0;
            else
                ai[(ii-1)*nn+jj]=ai[(ii-1)*nn+jj]-qq*ai[(kk-1)*nn+jj];
        }
        b[ii]=b[ii]-qq*b[kk];
    }
}
x[nn]=b[nn]/ai[nn*nn];
for(kk=1;kk<=nn-1;kk++)
{
    tt=0;
    ii=nn-kk;
    for(jj=1;jj<=nn-ii;jj++)
    {
        tt=tt+ai[(ii-1)*nn+ii+jj]*x[ii+jj];
        if(ai[(ii-1)*nn+ii]!=0)
            x[ii]=(b[ii]-tt)/ai[(ii-1)*nn+ii];
    }
}
for(n=0;n<=bars;n++)
{
    suml=0;
    for(kk=1;kk<=order;kk++)
    {
        suml=suml+x[kk+1]*n^kk;
    }
    reg[fin-n]=x[1]+suml;
}
}
SetChartOptions(0, chartShowDates);
Title = "Symbol: "+ Name()+ "\n>>>AMIT TRADING SYSTEM<<<\nmade by BUNTI_K23 ";
if(alt)
{
dev=StDev(Close-reg,bars);
sd=dev[fin];
x1a=reg+sd*1;//68%
x2a=reg+sd*2;//95%
x3a=reg+sd*3;//99.83%
z1a=reg-sd*1;
z2a=reg-sd*2;
z3a=reg-sd*3;
Plot(C, "Close",colorLightGrey,styleCandle);
Plot(reg,"reg",colorBlue,1);
Plot(x3a,"x3a",ColorRGB(255,0,0),styleThick);
Plot(x2a,"x2a",ColorRGB(255,100,100),styleDashed);
Plot(x1a,"x1a",ColorRGB(255,200,200),styleDashed);
Plot(z3a,"z3a",ColorRGB(0,255,0),styleThick);
Plot(z2a,"z2a",ColorRGB(100,255,100),styleDashed);
Plot(z1a,"z1a",ColorRGB(200,255,200),styleDashed);
PlotOHLC(x3a,x3a,x1a,x1a,"",ColorRGB(30,0,0),styleCloud|styleNoLabel,0,0,0,-1);
PlotOHLC(z1a,z1a,z3a,z3a,"",ColorRGB(0,30,0),styleCloud|styleNoLabel,0,0,0,-1);
}
else
{
dev=StDev(Close,bars);
sd=ecart*dev[fin];
x1=reg+sd/(1.382*1.618);
x2=reg+sd/1.382;
x3=reg+sd;
z1=reg-sd/(1.382*1.618);
z2=reg-sd/1.382;
z3=reg-sd;
Plot(C, "Close",colorLightGrey,styleCandle);
//Plot(reg,"reg",colorBlue,1);
//Plot(x3,"x3",ColorRGB(255,0,0),styleThick);
//Plot(x2,"x2",ColorRGB(255,100,100),styleDashed);
Plot(x1,"x1",ColorRGB(255,200,200),styleDashed);
//Plot(z3,"z3",ColorRGB(0,255,0),styleThick);
//Plot(z2,"z2",ColorRGB(100,255,100),styleDashed);
Plot(z1,"z1",ColorRGB(200,255,200),styleDashed);
PlotOHLC(x3,x3,x2,x2,"",ColorRGB(30,0,0),styleCloud|styleNoLabel,0,0,0,-1);
PlotOHLC(z2,z2,z3,z3,"",ColorRGB(0,30,0),styleCloud|styleNoLabel,0,0,0,-1);
}





TimeFrameRestore();




/////////////////////////////////////

////////////////////////
Length = 8;
Price = EMA(Close, Length);
 
// Keltner
kLength = Length;
kN = 1.5;
kATR = ATR(kLength);
kUpper = Price + kN * kATR;
kLower = Price - kN * kATR;
 
// Bollinger
bbLength = Length;
bbN = 2;
bbStDevValues = StDev(Close, bbLength);
bbUpper = Price + bbN * bbStDevValues;
bbLower = Price - bbN * bbStDevValues;
 
IsSignal =
    bbUpper <= kUpper AND
    bbLower >= kLower;
 ///////////////////////////////////

///////////////////////////////////////////



Buy =  C > x1 AND PDI(20) > Ref(PDI(20),-1) AND MDI(20) < ADX(20) AND PDI(20) > ADX(20) AND issignal < 1;

Short = C < z1 AND MDI(20) > Ref(MDI(20),-1) AND PDI(20) < ADX(20) AND MDI(20) > ADX(20) AND issignal < 1;



Buy = ExRem( Buy, Short );
Short = ExRem( Short, Buy );


PlotShapes( Buy*shapeUpArrow, colorWhite, 0, Low );
PlotShapes( Short*shapeDownArrow, colorWhite, 0, High );

//////////////////////////////////////



DayH = TimeFrameGetPrice("H", in1Minute, 0);
DayL = TimeFrameGetPrice("L", in1Minute, 0);
DayC = TimeFrameGetPrice("C", in1Minute, 0);
DayO = TimeFrameGetPrice("O", in1Minute, 0);
pDayC = TimeFrameGetPrice("C", in1Minute, -1);

FS=Param("Font Size",15,11,100,1);
GfxSelectFont("Comic Sans M", FS , 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( colorBlack );
Hor=Param("Horizontal Position",820,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1);
GfxTextOut(""+C, Hor, Ver);
GfxSetTextColor( colorGrey50 );
GfxTextOut("PC:"+pDayC,700, Ver);
GfxSetTextColor( colorBlue );
GfxTextOut("C:"+DayC, 600, Ver);
GfxSetTextColor(colorRed );
GfxTextOut("L:"+DayL,500, Ver);
GfxSetTextColor(colorBrightGreen );
GfxTextOut("H:"+DayH,400, Ver);
GfxSetTextColor( colorLightBlue );
GfxTextOut("O:"+DayO,300, Ver);

/////////////////////////////////////

_SECTION_BEGIN("Background");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    SetChartBkColor(ParamColor("Outer panel",colorGrey40)); // color of outer border
    SetChartBkGradientFill( ParamColor("Inner panel upper",colorGrey40),ParamColor("Inner panel lower",colorBlack));
    tchoice=Param("Title Selection ",2,1,2,1);
 
Plot(C, "", IIf(O>=C, colorOrange, colorGreen), ParamStyle("Price Style",styleCandle, maskPrice));
 
//////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////
_SECTION_BEGIN("Fib Retracements");
    fibs = ParamToggle("Plot Fibs","Off|On",1);
    pctH = Param ("Pivot Hi %", 0.325,0.001,2.0,0.002);
    HiLB = Param ("Hi LookBack",1,1,BarCount-1,1);
    pctL = Param ("Pivot Lo %", 0.325,0.001,2.0,0.002);
    LoLB = Param ("Lo LookBack",1,1,BarCount-1,1);
    Back = Param ("Extend Left = 2",1,1,500,1);
    Fwd  = Param("Plot Forward", 0, 0, 500, 1);
    text = ParamToggle("Plot Text","Off|On",1);
    hts  = Param ("Text Shift", -33.5,-50,50,0.10);
    style =ParamStyle("Line Style",styleLine,styleNoLabel);
x = BarIndex();
pRp  = PeakBars( H, pctH, 1) == 0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
pSp  = TroughBars( L, pctL, 1) == 0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;
 
function fib(ret)
{
retval = (Delta * ret);
Fibval = IIf(ret < 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
AND xSp0 > xRp0, ySp0 + retval, Null))));
return FibVal;
}
 
x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);
//////////////////////////////////////////////////////////////////
r236 = fib(0.236);  r236I = LastValue (r236,1);
r382 = fib(0.382);  r382I = LastValue (r382,1);
r050 = fib(0.50);       r050I = LastValue (r050,1);
r618 = fib(0.618);  r618I = LastValue (r618,1);
r786 = fib(0.786);  r786I = LastValue (r786,1);
e127 = fib(1.27);       e127I = LastValue (e127,1);
e162 = fib(1.62);       e162I = LastValue (e162,1);
e200 = fib(2.00);       e200I = LastValue (e200,1);
e262 = fib(2.62);       e262I = LastValue (e262,1);
e424 = fib(4.24);       e424I = LastValue (e424,1);
//////////////////////////////////////////////////////////////////
p00 = IIf(xSp0 > xRp0,ySp0,yRp0);    p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0);   p100I = LastValue (p100,1);
color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
color100 =IIf(xSp0 < xRp0,colorLime,colorRed);
//////////////////////////////////////////////////////////////////
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
//////////////////////////////////////////////////////////////////
if(fibs==1)
{
Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",45,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",44,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",41,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",43,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",42,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",25,style|styleNoRescale,Null, Null,Fwd);
}
//////////////////////////////////////////////////////////////////
if(text==1)
{
PlotText(" 0% = " + WriteVal(p00,fraction),     LastValue(BarIndex())-(numbars/hts), p00I  + 0.05, color00);
PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, 45);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, 44);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, 41);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, 43);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, 42);
PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color100);
PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, 47);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, 47);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, 47);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, 47);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, 25);
}
_SECTION_END();
 

bunti_k23

Well-Known Member
#20
TYPES OF TRADES

here are the different scenarios as an e.g;)

reversal trade



normal trade





trade in consolidation period



normal trade



longbar retracement trade



normal trade



normal trade




stoploss hits



wrong reversal

 

Similar threads