My level of English is very basic, I need to use a translator to follow instructions in the user guide. My level of programming formulas is not very good either and I read the instructions by working through trial, trial and error.. I apologize for that.
I have prepared a formula in which I want the result to be a leading moving average. The formula is very basic if I only want the result obtained to only look back 8 days. However, my interest is to carry this result for several years and therefore it is no longer possible unless I repeat the codes hundreds of times. Amibroker surely has a function that solves that problem and I would be grateful if someone can give me instructions or program the formula for me. I apologize again for my daring, reading in a language that the entire manual is not controlled is very complicated.
I put the formula that I have programmed for your review. Thank you very much.
// First value. Output value: I have put 8 days but I need the value of 20 years ago. // moving average of 3, S&P500 Future diary // MA8 value 8 days ago = 3325.56 MA8 = 3325.56; // MA3 value 7 days ago. The result of MA7 is solved with this formula MA7 = (((MA8 * 2) + (Ref(Close,-7)))) / 3; // Result = 3339.62 // MA3 value 6 days ago. The result of MA6 is solved with this formula ....etc. MA6 = (((MA7 * 2) + (Ref(Close,-6)))) / 3; // Result = 3339.5 // MA3 value 5 days ago MA5 = (((MA6 * 2) + (Ref(Close,-5)))) / 3; // Result = 3356.25 // MA3 value 4 days ago MA4 = (((MA5 * 2) + (Ref(Close,-4)))) / 3; // Result = 3355.25 // MA3 value 3 days ago MA3 = (((MA4 * 2) + (Ref(Close,-3)))) / 3; // Result = 3372.42 // MA3 value 2 days ago MA2 = (((MA3 * 2) + (Ref(Close,-2)))) / 3; // Result = 3399.4 // MA3 value 1 days ago MA1 = (((MA2 * 2) + (Ref(Close,-1)))) / 3; // Result = 3424.02 // MA3 value today MA0 = (((MA1 * 2) + (Close))) / 3; // Result = 3441.64 Plot(MA0,"MA0", colorViolet, styleLine);