I would like too put a moving average on my equity curve and only initiate trades if the equity curve is above the moving average. I’ve tried the coding posted in another article on this forum but didn’t have much luck with it, can anyone help please?
CKWParticipant
Veteran
Sorry. Allow me to track this email if anyone have the answer. i am interested to know “How” as well..
@Daniel
Please update your country flag in your profile, thank you 🙂
Do this code work for you?
myequity = (((close-positionprice)*pointvalue)*countofposition)/pipsize + strategyprofit
avg = average[20](myequity)
It should calculate a moving average of 20 periods of the current opened orders gain plus the already made profit (strategyprofit).
Thanks Nicolas, i’ll give it a go!
WingParticipant
Veteran
I think you will need to make your own equity curve, if you want to include simulated trades that occur while the equity curve is below the moving average.
You do this by initiating some trades as fake, and some as both fake and real. For fake trades, you calculate the profit or loss based on your sell/stop conditions. You do this in an indicator for example, and then call it in a moving average function, allowing you to make real trades based on the value.
Thanks Wing! That’s sort of what is was thinking of …is it possible too simulate trades in an indicator though?
WingParticipant
Veteran
Yes, you can, or in a trading system. You simply add a variable for when you are initiating and holding a fake trade, size of that position, initial price etc., then when reaching sell conditions, you “sell” the fake position and look at the new close compared to what you bought the fake positon at, and add this win/loss to a equity variable you create.
Thanks Wing! Good idea, I will give it a go.
For your information, recently someone ask PRT about my blog article for this purpose (
trading the equity curve), and why it doesn’t work with IG accounts. He got answers and another way to implement it with this account type:
IG account equity curve trading code
Hope it will help you.