Hello
I trade the top 40 share index in South Africa and I like to shift horizontally the faster moving average to the left by -1. This seems to give me better entry signals. On the chart one can offset the moving average horizontally easily. So I wanted to write a automated strategy using this but as soon as I try to use the horizontally shifted moving average it does not exist as a usable option. Does anyone know if it is possible to shift the moving average horizontally to the left by -1 in an automated strategy and if yes could you share the code with me please.
Thanks
Ian
Hello IGOSNELL
Shifting moving average into the past is easy. If I understand well what you want to draw, here is the code : (just use the past value of the moving average you wish to shift)
normal = average[10](close)
shifted = normal[12]
RETURN normal, shifted
See screenshot attached below.
Thank you Nicolas
I will try the code tonight when I get home, thanks once again.
Regards
Ian
Hello Nicolas
I tried what you said but it will only allow a positive integer within the brackets which actuals shifts the moving average curve to the right I wanted to move the moving average horizontally to the left but it will not accept a negative number within the []. One can shift the moving average horizontally to the left on the normal chart but how does one code it I am not sure.
Any other ideas?
Regards
Ian
Sorry, but I dont understand. What i’m doing in my example is the right manner to draw at each bar the value that were at N period before this bar.
Maybe you want to draw something like the Chikou of Ichimoku? If so, maybe there is something I can do, tell me then.
Ok maybe I am not explaining my self properly : I would like to shift the moving average horizontally to the left as per the screen shot attached, but just don’t know how to code it.
I believe the screen shot attached will help explain.
Regards
Ian
KitParticipant
Junior
Hi Ian (and Nicolas), I think the problem is what is known as future leak, that is trying to use something that is properly only available in the future. By shifting an MA to the left, no value is available on the current bar- this may work in backtesting by hand, but can’t in real time!
Cheers, Kit
It is not possible to achieve this, because PRT doesn’t make loop back in the past. Only indicator built in can do it. Sorry.
Thanks makes sense. To bad, its a pity since it does seem to work well for trading entry signals whilst trading in real time.
TJMParticipant
New
Hi, I just came across this discussion, because I’m looking to use an MA, shifted to the right (projected in the future).
Does anyone know how to code this?
Thanks
T