Newbie scripter needs help scripting MT4 LWMA indicator
I'm using a strategy that uses the 2 period LWMA to get into trades as price will oscillate around this band. I want to make an indicator that plots the 4 hour LWMA on the 15 minute chart. There are 16 15 minute candles in 1 4 hour candle, therefore, 2 periods would make it 32 candles. Because it's LWMA (Linear Weighted), I can't just change the period to 32 as it will look different.
LMWA Calculation from investopedia
"For example, in a 15-day linearly-weighted moving average, today's closing price is multiplied by 15, yesterday's by 14, and so on until day 1 in the period's range is reached. These results are then added together and divided by the sum of the multipliers (15 + 14 + 13 + ... + 3 + 2 + 1 = 120)."
So a 2-four hour linearly-weighted moving average would be:
([close the 32nd candle] * 2) + ([close of the 16th candle] * 1) / (2+1))
EDIT: I want to use the LOW and HIGH instead of the close. So it would be the low of every block of X candles.
I would need a command that returns the low or high of every block of X candles.
I would also need a way to plot the return value on the chart.
Below is the moving average coding for LWMA. I figure I could take the plotting part from that as it would be easiest. And then make changes for the high and lows of every block of x candles. Any assistance would be appreciated as I have no MT4 coding experience. I'll work on breaking down the code for now. Hopefully someone can lend me a hand.
Last edited by kashix; April 27th, 2012 at 03:57 PM.