Trend following strategy for Gold
Forums › ProRealTime English forum › ProOrder support › Trend following strategy for Gold
- This topic has 4 replies, 2 voices, and was last updated 6 years ago by victormork.
-
-
11/15/2017 at 12:04 PM #52825
I started a trend following strategy for gold but I’ve run out of ideas so I thought I can just post it here so anyone who wants to can come with ideas on how to improve it.
Main issues are:
- Stop loss distance is massive!
- I have not found a good way to close losing positions before the drawdown becomes too big which is visible on the equity curve buy negative spikes.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105//XAUDUSD(EUR1 Contract) - IG MARKET// TIME FRAME 1H// PROBACKTEST TICK by TICK - 100.000 bars// SPREAD 0.5 PIPDEFPARAM CumulateOrders = FALSEDEFPARAM Preloadbars = 200tradingtime = (currenttime >= 030000 and currenttime <= 180000)CP1 = 4CP2 = 4shorttrend = supertrend[4,10]longtrend = supertrend[7,24]// INDICATORS///FRACTAL INDICATORif close[cp1] >= highest[2*cp1+1](close) thenLH = 1elseLH=0endifif close[cp2] <= lowest[2*cp2+1](close) thenLL= -1elseLL=0endifif LH=1 thenHIL = close[cp1]endifif LL = -1 thenLOL=close[cp2]endif// ENTRY CONDITIONSC1 = not longonmarketC1 = C1 and (close crosses over LOL)C1 = C1 and tradingtimeC1 = C1 and close > longtrend// ENTRY CONDITIONSS1 = not shortonmarketS1 = S1 and (close crosses under HIL)S1 = S1 and tradingtimeS1 = S1 and close < shorttrend//ENTRY LONGIF C1 THENBUY 10 CONTRACT AT MARKETENDIF// ENTRY SHORTIF S1 THENSELLSHORT 10 CONTRACT AT MARKETENDIF// Exit LongIf longonmarket and close > HIL thensell at marketendif// Exit ShortIf shortonmarket and close < LOL thenexitshort at marketendif//trailing stoptrailingstop = 4//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endif//case SHORT orderif shortonmarket thenMINPRICE = MIN(MINPRICE,close) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price levelendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif// stoplossSet stop ploss 8011/15/2017 at 12:10 PM #52827Hi Victor
I am busy playing with your strategy now as I have been looking for a good gold strategy.
I have implemented a trailing stop and a donchian stop. I am busy running a walk forward now with a number of parameters will share results when done.
1 user thanked author for this post.
11/15/2017 at 12:39 PM #52834Cool! If you are looking for strategies on gold you can also check out the one I posted in the library –> https://www.prorealcode.com/prorealtime-trading-strategies/internal-bar-strength-gold-xauusd-2-hours-timeframe/
11/15/2017 at 12:40 PM #5283511/15/2017 at 1:56 PM #52839Oh alright. The one I posted here is different though.
-
AuthorPosts
Find exclusive trading pro-tools on