Shifted MAE2

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

Shifted MAE2

Postby Apprentice » Fri May 01, 2020 9:24 am

USDCNH H1 (05-01-2020 1433).png

Based on request.
viewtopic.php?f=17&t=658
Shifted MAE2.lua
(5.11 KiB) Downloaded 397 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Shifted MAE2

Postby fortcentral » Mon May 04, 2020 6:33 am

Dear Apprentice,
Thank you so much for this and also for the quick response on the request! Would it be possible please to include the following options:
1) Increase in number of decimal points used in MA and band calculations from 4 to 8, to further reduce rounding error?
2) Option to change thickness (weight) and style (dash, dotted, etc.) of "MA Line" and "Band lines"?
3) "Shift in period" parameter input - option to shift by decimal "0.5" or "1/2 time-periods", such that calculated moving average point is plotted between two price bars?

Regards,
Fortcentral
fortcentral
 
Posts: 47
Joined: Wed Oct 17, 2018 9:34 am

Re: Shifted MAE2

Postby Apprentice » Mon May 04, 2020 7:25 am

1)
2)
Added.

About 3)
Capture.PNG

Try to use these options.
If your logic is applied, what will be current value of lines?
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Shifted MAE2

Postby fortcentral » Mon May 04, 2020 10:16 am

Thank you again!

About 3) - the logic would be for example that in the calculation of a 10-period Simple-Moving-Average (SMA), which is shifted "-4.5" periods. The calculated SMA-value of the last 10-periods (inclusive of the current period), will be plotted between the 5-th and the 6-th bar of the period used for calculation of the SMA.

Similarly, in a 4-period SMA shifted "-1.5" periods, the calculated value will be plotted between the 2-nd and the 3-rd bar. Hope example below makes it clearer.

Example (Closing price of each bar being used in calculation):
Bar 1: 10
Bar 2: 12
Bar 3: 8
Bar 4: 6 (current bar - yet to close but current "bid" price is 6)

4-period SMA(current) = (10+12+8+6)/4 = 9 shifted "-1.5" periods will be plotted in the space between "Bar 2" and "Bar 3".

Regards,
Fortcentral
fortcentral
 
Posts: 47
Joined: Wed Oct 17, 2018 9:34 am

Re: Shifted MAE2

Postby Apprentice » Tue May 05, 2020 4:27 am

Your request is added to the development list.
Development reference 1221.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Shifted MAE2

Postby fortcentral » Tue May 05, 2020 5:36 am

Dear Apprentice,
Further to my "logic description" yesterday, which was very basic, please see the following clarifications. The plot of the "1/2 period shift" will require some type of interpolation to estimate the shifted curve position. I hope the following description and picture makes the idea for the shift clearer.

Whole period shifts either forward or backward in time are relatively easy as per the current functionality of the indicator. This is the best outcome for most shifted envelopes. However under certain circumstances, 1/2 period shifts are recommended and hence the request for this additional functionality.

For half-period (0.5) shifts in time, you may be able to use a 2-period SMA of the "Moving Average Calculation" shifted by the next-whole-number up from the "input half-period", i.e. if "-1.5" period shift is required then a 2-period SMA of the moving average (or average of the last two moving-average values), each shifted by -2.0 periods in time.

Please see worked example in attached picture.

Regards,
Fortcentral
Attachments
0.5 period shift logic example.jpg
fortcentral
 
Posts: 47
Joined: Wed Oct 17, 2018 9:34 am

Re: Shifted MAE2

Postby Apprentice » Sun May 10, 2020 3:59 am

Try this version.
Shifted MAE2.lua
(6.3 KiB) Downloaded 338 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Shifted MAE2

Postby fortcentral » Wed May 13, 2020 12:19 am

Dear Apprentice,
Thank you for the last update. The calculations are working well. Two change requests please to finalise this one:

1) This change applies only to the "half-shift" calculation. The calculated values for the "half-shift" plot are accurate. But for correct display, the "half-shift" plot needs to be displaced an extra period over the input "Shift-in-period" parameter value.

So for example, if we enable "half-shift" and input parameter "+1 period shift" then calculated "half-shift" curve should be displaced "+2 periods" to display correctly. Similarly for example, with "half-shift" enabled and input of "-3 period shift", the calculated "half-shift" curve should be displaced "-4 periods" in the plot instead of the current "-3 period shift", to display correctly.

2) Option to "switch-off" display for "MAE band", similar to the option available for the "moving-average line". This will help to simplify screen when displaying nested bands for example.

Regards,
Fortcentral
fortcentral
 
Posts: 47
Joined: Wed Oct 17, 2018 9:34 am

Re: Shifted MAE2

Postby fortcentral » Wed May 27, 2020 8:59 am

Dear Apprentice,
Any chance for you to have a look at the two modifications requested in my earlier reply (Wed May 13, 2020 3:19 pm)? Would be great to finalise the indicator.

Thanks,
Forcentral
fortcentral
 
Posts: 47
Joined: Wed Oct 17, 2018 9:34 am

Re: Shifted MAE2

Postby Apprentice » Wed May 27, 2020 3:59 pm

Your request is added to the development list.
Development reference 1379.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Custom Indicators

Who is online

Users browsing this forum: Baidu [Spider] and 40 guests