COG & MBFX Timing v2
Forums › ProRealTime English forum › ProOrder support › COG & MBFX Timing v2
- This topic has 13 replies, 7 voices, and was last updated 4 years ago by
keewee.
-
-
05/10/2020 at 6:29 PM #130987
Hi,
Im testing a strategy based on Center of Gravity by Belkhayate and MBFX Timing 2.
Indicators found here:
https://www.prorealcode.com/topic/center-of-gravity/#post-19219
https://www.prorealcode.com/prorealtime-indicators/mbfx-timing-v2/Instead of calling the indicators I’ve included them in the code for easier optimisation and faster loading. But I have an issue with the GRAPHONPRICE function for the COG indicator. The lines are not plotted the same as if I were to add the indicator on price chart settings manually. In the screenshot I have included COG both in code and Price Chart settings.
I’m a bit stuck and would be grateful for some help, also any thoughts or suggestions regarding the strategy is very much appreciated.
My sauna is warm and beer is cold…I’ll be right back…
COG & MBFX Timin v2123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257// COG & MBFX Timin v2// EUR/USD 1h/10m/15m (need to test)// https://www.prorealcode.com/topic/center-of-gravity/// https://www.prorealcode.com/prorealtime-indicators/mbfx-timing-v2/DEFPARAM CUMULATEORDERS = falseDEFPARAM PRELOADBARS = 200//==== Center of Gravity Belkhayatep3= 5k=p3 // Variable p3= 65de48=DPO[k*2] (close)if de48=de48[1] and de48[1]=de48[ 2] and de48[2]<>de48[ 3] thenflag=1endifn=(k*2)-4p=(n/2)-1d100=DPO[n]( close)moy100=close- d100co=(moy100-moy100[ 1]+(close[ p])/n)*nif flag[1]=1 and flag[2]=0 thenhh=co[1]endifif flag[1]=1 thenco=hhendifn=p3 mod 2p=(p3-n)/2p3=(2*p)+1once x=0w=abs((p-x)/ p)w=w*w*ww=(1-w)w=w*w*wx=x+1if barindex=p3 thena=0b=0e=0for i=1 to p3z=barindex-i+ 1a=a+w[z]b=b+w[z]*(i)e=e+(i)*(i)* w[z]nextendifif barindex>p3 thenc=0d=0for i=1 to p3z=barindex-i+ 1c=c+co[p3+p- i]*w[z]d=d+co[p3+p- i]*w[z]*( i)nextendifalpha=(a*d-b* c)/(a*e-b* b)beta=(c*e-b* d)/(a*e-b* b)lowess=alpha* (p+1)+betaif barindex < p3*2 thenlowess=undefinedendifzz = close - lowesszzsigma = STD[p3](zz)bb1 = lowess + zzsigmabb2 = lowess +1.618* zzsigmabb3 = lowess +2* zzsigmabl1 = lowess - zzsigmabl2 = lowess - 1.618* zzsigmabl3 = lowess - 2* zzsigmagraphonprice lowess coloured (0,0,255)graphonprice bb1 coloured (200,200,0)graphonprice bb2 coloured (255,0,0)graphonprice bb3 coloured (255,0,0)graphonprice bl1 coloured (200,200,0)graphonprice bl2 coloured (255,0,0)graphonprice bl3 coloured (255,0,0)//===========================================================//=== RC_MBFX timing 2 | indicator ==========================//06.05.2020//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//converted from MT4 version// --- settingsLen = 21 //7Filter = 0.0// --- end of settingsli224=0if (ld8 = 0.0) thenld8 = 1.0ld16 = 0.0if (Len - 1 >= 5) thenld0 = Len - 1.0elseld0 = 5.0endifld80 = 100.0 * ((High[li224] + Low[li224] + Close[li224]) / 3.0)ld96 = 3.0 / (Len + 2.0)ld104 = 1.0 - ld96elseif (ld0 <= ld8) thenld8 = ld0 + 1.0elseld8 = ld8+1.0endifld88 = ld80ld80 = 100.0 * ((High[li224] + Low[li224] + Close[li224]) / 3.0)ld32 = ld80 - ld88ld112 = ld104 * ld112 + ld96 * ld32ld120 = ld96 * ld112 + ld104 * ld120ld40 = 1.5 * ld112 - ld120 / 2.0ld128 = ld104 * ld128 + ld96 * ld40ld208 = ld96 * ld128 + ld104 * ld208ld48 = 1.5 * ld128 - ld208 / 2.0ld136 = ld104 * ld136 + ld96 * ld48ld152 = ld96 * ld136 + ld104 * ld152ld56 = 1.5 * ld136 - ld152 / 2.0ld160 = ld104 * ld160 + ld96 * Abs(ld32)ld168 = ld96 * ld160 + ld104 * ld168ld64 = 1.5 * ld160 - ld168 / 2.0ld176 = ld104 * ld176 + ld96 * ld64ld184 = ld96 * ld176 + ld104 * ld184ld144 = 1.5 * ld176 - ld184 / 2.0ld192 = ld104 * ld192 + ld96 * ld144ld200 = ld96 * ld192 + ld104 * ld200ld72 = 1.5 * ld192 - ld200 / 2.0if (ld0 >= ld8 and ld80 <> ld88) thenld16 = 1.0endifif (ld0 = ld8 and ld16 = 0.0) thenld8 = 0.0endifendifif (ld0 < ld8 and ld72 > 0.0000000001) thenld24 = 50.0 * (ld56 / ld72 + 1.0)if (ld24 > 100.0) thenld24 = 100.0endifif (ld24 < 0.0) thenld24 = 0.0endifelseld24 = 50.0endifif (ld24>ld24[1]- Filter) thendirbar=1r=0g=128endifif (ld24<ld24[1]+Filter) thendirbar=-1r=255g=165endifif (ld24=ld24[1]+Filter) thendirbar=0endifif dirbar<>dirbar[1] thenr=255g=255endifgraph ld24 coloured(r,g,0) as "MBFX timing"graph 70 coloured(168,168,168)graph 30 coloured(168,168,168)graph 50 coloured(168,168,168)// Conditions to enter long positionsIF (close crosses over bl3) AND (ld24<30) THENBUY 1 CONTRACTS AT MARKETENDIF// Conditions to enter short positionsIF (close crosses under bb3) AND (ld24>70) THENSELLSHORT 1 CONTRACTS AT MARKETENDIF// Stops and targets//SET STOP PLOSS//SET TARGET PPROFIT// trailing stop atronce trailingstoptype = 1 // trailing stop - 0 off, 1 ononce trailingstoplong = 3 // trailing stop atr relative distanceonce trailingstopshort = 3 // trailing stop atr relative distanceonce atrtrailingperiod = 16 // atr parameter valueonce minstop = 7 // minimum trailing stop distance//----------------------------------------------atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000//atrtrail=averagetruerange[atrtrailingperiod]((close/1)*pipsize) (forex)tgl = round(atrtrail*trailingstoplong)tgs = round(atrtrail*trailingstopshort)if trailingstoptype = 1 then//if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxprice = 0minprice = closenewsl = 0endif//if longonmarket thenmaxprice = max(maxprice,close)if maxprice-tradeprice(1)>=tgl*pointsize thenif maxprice-tradeprice(1)>=minstop thennewsl = maxprice-tgl*pointsizeelsenewsl = maxprice - minstop*pointsizeendifendifendif//if shortonmarket thenminprice = min(minprice,close)if tradeprice(1)-minprice>=tgs*pointsize thenif tradeprice(1)-minprice>=minstop thennewsl = minprice+tgs*pointsizeelsenewsl = minprice + minstop*pointsizeendifendifendif//if longonmarket thenif newsl>0 thensell at newsl stopendifif newsl>0 thenif low < newsl thensell at marketendifendifendif//if shortonmarket thenif newsl>0 thenexitshort at newsl stopendifif newsl>0 thenif high > newsl thenexitshort at marketendifendifendif//graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"endif05/10/2020 at 6:34 PM #130992Here is the screenshot (forgot to add in first post).
The coloured lines are from the code. The white lines are from Price settings. The lines should look the same because they are same indicator…or am I missing something?
…off to sauna…and cold beer…
05/10/2020 at 9:01 PM #131027Isn’t CoG one of those classic indicators that changes its value afterwards (swe: i efterhand) kind of like the ZigZag also does? It’s fantastic when backtesting but impossible to use on demo/live. If so, avoid it 🙂
1 user thanked author for this post.
05/10/2020 at 9:10 PM #13102805/11/2020 at 8:21 AM #131049Indeed the COG change its value afterwards. By the way the DPO indicator cannot be used in real live trading because it knows the future of the bars which is obviously not possible in real time, while it is possible with a complete data history.
1 user thanked author for this post.
05/11/2020 at 9:14 AM #131065Thanks Nicolas, I did read more about COG and your explanation makes sense and was vey helpful.
I will continue to examine the new MBFX Timing 2. Has anyone tested it with other indicators and wants to share their thoughts? I know that Bard has a topic also about MBFX.
05/11/2020 at 12:04 PM #131117how do you manage thoses 2 errors?
05/11/2020 at 12:23 PM #131121how do you manage thoses 2 errors?
As indicated you can’t use DPO and Graph instructions in your code
1 user thanked author for this post.
05/11/2020 at 6:55 PM #13119105/11/2020 at 9:20 PM #13121005/11/2020 at 9:30 PM #13121205/11/2020 at 9:49 PM #131214Beware of snake oil salesmen with mystery liquid in their bottles that they can’t tell you the ingredients of but that they can tell you works miracles for all ailments – particularly ailments such as being poor but wanting to be rich at only $100 dollars a bottle. Someone will get rich but it most likely won’t be you!
05/13/2020 at 12:24 PM #131488Maybe I did not express myself clearly enough, or the link immediately triggered certain thinking patterns.
It was my intention to develop the setup further regardless of whether the salesman is fraudulent or not. (Use GoG in live trades)Perhaps the following could be used for this in addition?
https://www.prorealcode.com/prorealtime-indicators/average-true-range-support-resistance-bands/
https://www.prorealcode.com/prorealtime-indicators/voodoo-lines-fibgrid/
https://www.prorealcode.com/prorealtime-indicators/pivot-support-resistance-bands/
https://www.prorealcode.com/prorealtime-indicators/1-2-3-pivots-support-and-resistance-lines/
BR
05/13/2020 at 1:35 PM #131498@Fabian , when you write “COG” do you acutally mean “MBFX Timing 2”? That is, you want to develope a strategy based by MBFX Timin 2 indicator? In that case it would be interesting to try.
BUT if you are still trying to build an automated algo out of the above mentioned “COG”, we can not because how the indicator works.
-
AuthorPosts
Find exclusive trading pro-tools on