hi all, i need some help to improvise this strategy. The following moving average needs improvements as there are positions being opened in a fluctuating market resulting in heavy loss as shown in the picture attached. Can someone help to modify it ?
Required improvements
1. BUY only if current price is more than previous close
Problems
1. Positions opened in fluctuating markets
2. Position open on par with open rate resulting in ZERO / Loss senarios
3. Strategy only useful in a trending upwards market
=========================================================================
// Définition des paramètres du code
DEFPARAM CumulateOrders = TRUE // Cumul des positions activé
indicator1 = close
indicator2 = Average[5](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 5 CONTRACT AT MARKET
ENDIF
// Conditions pour fermer une position acheteuse
indicator3 = close
indicator4 = Average[14](close)
c2 = (indicator3 CROSSES OVER indicator4)
IF c2 THEN
SELL AT MARKET
ENDIF
Hi,
> For clarity of messages on ProRealCode’s forums, please use the “insert PRT code” button to separate the text of the code part! Thank you! <<
(PRT code has been edited above, and this is how it should look like when using the “insert PRT code” button)
About your first request, you could replace your c1 condition with this one instead:
c1 = (indicator1 CROSSES OVER indicator2) and close>close[1]
Concerning the “problems” you mentioned, this is indeed what you have to face with a strategy build upon criteria of trend following.