MA Crossover shown in price Chart

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin


MA Equilibrium

Postby Apprentice » Tue Feb 06, 2018 5:15 pm

EURUSD m1 (02-06-2018 2156).png

My implementation.
Will give the price for which, the two moving average will be equalized.
MA Equilibrium.bin
(1.49 KiB) Downloaded 429 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA Crossover shown in price Chart

Postby Apprentice » Tue Feb 06, 2018 6:00 pm

MA Equilibrium.bin update.
Please re-download.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA Crossover shown in price Chart

Postby robbieyoung » Tue Feb 06, 2018 7:37 pm

Thanks for all the hard work.

Apologies, my initial calculations were completely wrong.

The first equilibrium file was very close but I noticed the equilibrium price in the current open bar moved as the price moved which it shouldn't do.

The second Equilibrium bin file gives me results very similar to mine ie prices way too high and low.

The correct formula seems to be:

(Period2*SUM(Period1-1)-Period1*SUM(Period2-1))/(Period1-Period2)

(20*SUM(10-1))-10*SUM(20-1))/(10-20)

Where Sum(Period1-1) ie Sum(10-1) is the sum of the previous 9 closes
and Sum(Period2-1) ie Sum(20-1) is the sum of the previous 19 closes

I can send an excel spreadsheet showing the calculations if you require further information.

Many thanks for all your efforts.
robbieyoung
 
Posts: 32
Joined: Tue Apr 21, 2015 3:12 am

Re: MA Crossover shown in price Chart

Postby robbieyoung » Wed Feb 07, 2018 7:23 am

Hi,

I have looked again at the updated MA Equilibrium bin.

This is very close but I notice the MA Equilibrium price for the latest (Open) bar still varies as the current price varies, it should be fixed.

The attached spreadsheet gives the calculated equilibrium price using the formula given in the last post for H4 EURUSD Prices.

Substituting the equilibrium price for the close price on the same bar does equate the 2 MA's.

I hope this helps,

Thanks again.
Attachments
Equal MA's.xlsb
(886.47 KiB) Downloaded 365 times
robbieyoung
 
Posts: 32
Joined: Tue Apr 21, 2015 3:12 am

Re: MA Crossover shown in price Chart

Postby Apprentice » Thu Feb 08, 2018 6:29 am

Based on / Modified
(Period2*SUM(Period1-1)-Period1*SUM(Period2-1))/(Period1-Period2)

Is calculated as
Price[-1] + (Period2* (Period-1)SUM[-1]-Period1*(Period-2)SUM[-1])/(Period1-Period2)
Modified MA Crossover shown in price Chart.lua
(3.39 KiB) Downloaded 415 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: MA Crossover shown in price Chart

Postby robbieyoung » Thu Feb 08, 2018 10:24 am

Many thanks for the update but I get the following error:

C:/Program Files (x86)/Candleworks/FXTS2/Indicators/Custon/Modified MA Crossover shown in price Chart.lua:65: attempt to concatenate upvalue 'Method2' (a nil value)

Sorry to be a pain but this indicator will really help me.

Thanks again.
robbieyoung
 
Posts: 32
Joined: Tue Apr 21, 2015 3:12 am

Re: MA Crossover shown in price Chart

Postby robbieyoung » Thu Feb 08, 2018 12:18 pm

I managed to get the code to work by removing Method1 & Method2 from the name as they were returning nul.

The calculations are working perfectly but the results and the plotted line seems to be shifted 1 period to the right.

I tried changing the calculation to:

Line[period-1]=source[period-1]+(Period2*Sum1-Period1*Sum2)/(Period1-Period2);

This shifts the results back 1 period but then there is no value showing the MA equilibrium price in the current open bar.

Ill try some other things to fix it but your help would be greatly appreciated (again!)

Thanks
robbieyoung
 
Posts: 32
Joined: Tue Apr 21, 2015 3:12 am

Re: MA Crossover shown in price Chart

Postby robbieyoung » Thu Feb 08, 2018 12:49 pm

I changed the code to:

local name = profile:id() .. "(" .. instance.source:name() .. ", " .. Period1 .. ", " .. Period2 .. ")";

and:

local Sum1=mathex.sum(source, period-Period1+1, period);
local Sum2=mathex.sum(source, period-Period2+1, period);
Line[period]=source[period]+(Period2*Sum1-Period1*Sum2)/(Period1-Period2);

and this seems to have done shifted the graph back 1 period and also provides a calculation for the final open bar.

I cannot thank you enough for all your work in creating this indicator.

It will be a massive help to me monitoring for potential upcoming trades.
robbieyoung
 
Posts: 32
Joined: Tue Apr 21, 2015 3:12 am



Return to Custom Indicators

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 51 guests