polynomial curve

bunti_k23

Well-Known Member
#1
bajao taliya.............:clapping::clapping::clapping:

ye hai polynomial curve ,parameter setting mese lookback period badado ,but this is dynamic not a stationary one so that is a prob anyone want to improve this or anyone has sum gud idea pls participate...


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

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,8,1);
bars=Param("Lookback Period",100,50,500,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);
}
 

cloudTrader

Well-Known Member
#6
Trading strategy: Centre of Gravity - Belkhayate

The Centre of Gravity (COG) strategy is based on the premise that the market prices evolves around a "centre of gravity". When the market price deviates strongly from this centre of gravity the probability is considered high that the market price will evolve back towards the centre of gravity.
This trading strategy is also called the Belkhayate COG strategy. E.M. Belkayate is a technical analyst and the inventor of the strategy. The COG strategy is popular in France.

In 2009 it was awarded the golden trophy during the technical analysis fair in Paris.

Suitable for : Market indices (FTSE, CAC , DAX ...)
Forex (EUR/USD, GBP/USD …)
Commodities (oil, gold …)
Instruments : Futures and CFDs
Trading type : Swing trading
Trading tempo : Low - 3 to 4 signals per month.

A position is opened when the real market price deviates significantly from the centre of gravity of the market price. Belkhayate calculates the centre of gravity on the basis of a 4-hour chart and visualizes it as a single line [middle one]. Belkhayate also calculates three bands each above and below the centre of gravity line.
These bands are calculated on the basis of statistically significant values and Fibonacci numbers.

When the market price enters the third band it is considered as a significant deviation from the centre of gravity. Belkhayate argues that the probability of the market price evolving back towards the centre of gravity is 90%. When the market price deviates into the upper, red band the trader opens a short position. He expects the market to go down, towards the gravity line. When the market price deviates into the lower, green band the trader opens a long position. He expects the market to rise, towards the
gravity line.

Attention. Positions are only opened in the direction of the trend. To determine the trend simply use the gravity line itself. If the gravity line slopes upward the trend is bullish and only buy signals are acted upon. If the gravity line slopes downward the trend is bearish and only short sell signals are acted upon.

Attention. Belkhayate limits himself to stating that a position can be opened when the market price enters the third band. A trader requires a more precise rule to base his decision to open a position. One suggestion is to only open a position only after the first candle closes within the third band.


The Centre of Gravity strategy is precise regarding entry signals. The exit rules are a bit more vague. The trader can remedy this himself by using, for example, the Slow Stochastics.
 

bunti_k23

Well-Known Member
#7
Thanks leonid for the information , one tj member has built a strategy on this curve and using it for options, is there anyway to make it static.
 
#8
Thanks leonid for the information , one tj member has built a strategy on this curve and using it for options, is there anyway to make it static.
The deeper sense of what you posted is to not have it static. Not sure if you got that point. If you want it static, you use Standard deviation, but exactly that is not wished when you use polynomial curve. Take care and enjoy the day / Dan :)
 

cloudTrader

Well-Known Member
#9
The deeper sense of what you posted is to not have it static. Not sure if you got that point. If you want it static, you use Standard deviation, but exactly that is not wished when you use polynomial curve. Take care and enjoy the day / Dan :)
Exactly. When the purpose is to plot a curve , it is not meant to be static.

I gave a try to COG way back in 2012, but my experience has not been very good with it. As this curve adjusts with the price at a lag basically your entries have to be very precise incorporating other indicators in addition to COG.

Short Time Frames do not seem to be tradeable with COG. Swing Trading with higher time frames is viable but with caution.

Above lines are about my own experience . Others may differ as per their own usage tactics and rules.
 

bunti_k23

Well-Known Member
#10
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
 

Similar threads