Hi,
Proreal does not have by default an indicator to calculate distance in % from price to a moving average, as this one…How Can I Measure the Distance Between Price and a Moving Average? | MailBag | StockCharts.com
Can we please have it, and also can you please show me the code for a strategy where I can automate to buy or sell when price is at a certain % from 200 moving average?
Thanks
Wolf
Hi,
Proreal does not have this indicator, How Can I Measure the Distance Between Price and a Moving Average? | MailBag | StockCharts.com
Can we please have it, and also can you please show me the code for a strategy where I can automate to buy or sell when price is at a certain % from 200 moving average
Thanks
Ivan
JSParticipant
Senior
Hi @Wolf,
Hereby a simple trading system based on %difference between Close and MA200…
DefParam CumulateOrders = False
Once PercLong = 2 //If difference >= PercLong then go LONG
Once PercShort = -2 //If difference <= PercShort then go SHORT
MA200 = Average[200](Close) // 200 units Moving Average
PercDiff = (Close - MA200) / MA200 * 100 // % Difference between Close and MA200
If PercDiff >= PercLong then // If % Diffence >= PercLong then go LONG
Buy 1 Contract at Market
EndIf
If PercDiff <= PercShort then // If % Diffence <= PercShort then go SHORT
SellShort 1 contract at Market
EndIf
//Graph PercDiff