GoldMiner
Forums › ProRealTime English forum › ProOrder support › GoldMiner
- This topic has 15 replies, 6 voices, and was last updated 4 years ago by Francesco.
-
-
02/24/2020 at 5:36 PM #120331
Noticed that there are no systems on Gold, so i tryed to develop one by myself.
Here’s what i got, simple and effectiveBased on a simple moving average and a Breakeven function, with a limit to the operative time.
Works on 4H.
3 users thanked author for this post.
02/24/2020 at 5:48 PM #120336You should also post the whole code so that some interested may take a look at it without having to import it.
Thank you. 🙂
02/24/2020 at 5:53 PM #120337Usually didn’t seen anyone doing that, but here it is 😉
GoldMiner1234567891011121314151617181920212223242526272829303132333435363738394041424344defparam cumulateorders = false// LongIf average[20] CROSSES OVER average[55] THENBUY 0.2 CONTRACTS AT MARKETENDIF// Stop and targetSET STOP pLOSS 0SET TARGET pPROFIT 25IF OnMarket AND (BarIndex - TradeIndex) >=93 THENSELL AT MARKETEXITSHORT AT MARKETENDIFStartBreakeven = 0 // How much pips/points in gain to activate the Breakeven function?PointsToKeep = 20 // How much pips/points to keep in profit above of below our entry price when the Breakeven is activated (beware of spread)// Reset the BreakevenLevel when no trade are on marketIF NOT ONMARKET THENBreakevenLevel=0ENDIF// Test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//Calculate the BreakevenLevelBreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF// Place the new stop orders on market at BreakevenLevelIF BreakevenLevel>0 THENSELL AT BreakevenLevel STOPENDIFIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//Calculate the BreakevenLevelBreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//Place the new stop orders on market at BreakevenLevelIF BreakevenLevel>0 THENEXITSHORT AT BreakevenLevel STOPENDIF1 user thanked author for this post.
02/24/2020 at 6:21 PM #120339You may have noticed code is usually not posted on large topics because people already know know what’s it all about and posting code everytime would make the topic difficult to read, but the first time it’s better to let the reader decide whether it is worthwhile or not (for him) importing it.
Thank you.
02/24/2020 at 7:10 PM #12034202/24/2020 at 7:18 PM #120343I always like to see the code in the first post as I don’t always have my platform open 24/7 and so seeing how the strategy is coded is a lot of hassle of opening the platform and importing the code and I am generally to busy to bother doing that. If the code is in the first post however then I am able to immediately check it out and see if it is of interest or if I have anything to comment that might assist.
02/25/2020 at 12:28 AM #120360Small alteration to your exit conditions:
IF OnMarket AND (BarIndex – TradeIndex) >=93 and close>positionprice THEN …
Makes a huge difference on 100k — gain/loss ratio of 370? worst trade -$4? seriously?
Probably worth re-optimizing the bar number.
02/25/2020 at 8:19 AM #120372Makes a huge difference on 100k — gain/loss ratio of 370? worst trade -$4? seriously?
Yes but one day you will open a trade at the top of the market and then the market will take a dive and you will go into massive account killing drawdown! Just because it does not happen in your backtest does not mean it can’t happen. Perhaps a robustness test would show this as perhaps the big DD trades are just not happening because of the start date and time meaning that you just so happened to be on the market and so missed those bad trades.
02/25/2020 at 9:38 AM #120386Yes, the tone of voice was meant to imply that this may well be too good to be troo and needs more testing … it’s effectively only closing if in profit. But may be worth considering …
02/25/2020 at 10:18 AM #120394added re-entry to see what it does, kind of a robustness-test
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879defparam cumulateorders = falseonce reentry =1 // close & re-entry on signal in same directioncondbuy=average[20] CROSSES OVER average[55]if condbuy thensignal=1elsesignal=0endifgraph signalctime=1// Longif ctime thenIf condbuy THENif not onmarket thenbuy 1 contract at marketendifif reentry thenif longonmarket thensell at marketendifendifendifif reentry thenif condbuy[1] thenif longonmarket[1] thenbuy 1 contract at marketendifendifendifendif// Stop and targetSET STOP pLOSS 0SET TARGET pPROFIT 25IF OnMarket AND close>positionprice and (BarIndex - TradeIndex) >=1 THENSELL AT MARKETENDIFStartBreakeven = 0 // How much pips/points in gain to activate the Breakeven function?PointsToKeep = 20 // How much pips/points to keep in profit above of below our entry price when the Breakeven is activated (beware of spread)// Reset the BreakevenLevel when no trade are on marketIF NOT ONMARKET THENBreakevenLevel=0ENDIF// Test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//Calculate the BreakevenLevelBreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF// Place the new stop orders on market at BreakevenLevelIF BreakevenLevel>0 THENSELL AT BreakevenLevel STOPENDIFIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//Calculate the BreakevenLevelBreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//Place the new stop orders on market at BreakevenLevelIF BreakevenLevel>0 THENEXITSHORT AT BreakevenLevel STOPENDIFthe breakeven though should be the other way around with it’s value’s
when reaching a gain, then move breakevenlevel to 0, however it’s a nice equitycurve this way.
02/25/2020 at 10:56 AM #120400Probably worth re-optimizing the bar number.
This is a terrible idea. Optimising on any time based idea is always going to be a great way to curve fit. As soon as I see numbers like 93 it instantly gets me worried that it is totally curve fitted.
02/25/2020 at 11:51 AM #120415As soon as I see numbers like 93 it instantly gets me worried that it is totally curve fitted.
But surely there must always be some optimal number, no? where optimal does not necessarily mean highest profit, could be lowest drawdown or %win or whatever helps you sleep at night.
I don’t think there’s a good ‘theoretical’ reason for it not to be 93 or 71 or 57, esp in a 10 year backtest with WF and all the rest. Or is there?
02/25/2020 at 12:17 PM #12041912345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879defparam cumulateorders = falseonce reentry =0// close & re-entry on signal in same directioncondbuy=average[20] CROSSES OVER average[55] and (average[55]-average[55](close[1]))/pointsize> 0.1if condbuy thensignal=1elsesignal=0endifgraph signalctime=1// Longif ctime thenIf condbuy THENif not onmarket thenbuy 1 contract at marketendifif reentry thenif longonmarket thensell at marketendifendifendifif reentry thenif condbuy[1] thenif longonmarket[1] thenbuy 1 contract at marketendifendifendifendif// Stop and targetSET STOP pLOSS 0SET TARGET pPROFIT 25IF OnMarket AND close>positionprice and (BarIndex - TradeIndex) >=1 THENSELL AT MARKETENDIFStartBreakeven =0// How much pips/points in gain to activate the Breakeven function?PointsToKeep = 20 // How much pips/points to keep in profit above of below our entry price when the Breakeven is activated (beware of spread)// Reset the BreakevenLevel when no trade are on marketIF NOT ONMARKET THENBreakevenLevel=0ENDIF// Test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//Calculate the BreakevenLevelBreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF// Place the new stop orders on market at BreakevenLevelIF BreakevenLevel>0 THENSELL AT BreakevenLevel STOPENDIFIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//Calculate the BreakevenLevelBreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//Place the new stop orders on market at BreakevenLevelIF BreakevenLevel>0 THENEXITSHORT AT BreakevenLevel STOPENDIFHello,
Or add a filter1 user thanked author for this post.
02/25/2020 at 2:00 PM #12044302/25/2020 at 3:52 PM #120469But surely there must always be some optimal number, no?
Yes – but that optimal number is your curve fit. You have looked at history and said ‘that number of bars before exiting has worked the best in the past’ but that does not mean that it will work tomorrow or ever be the best number to use ever again. Now if you had say a range of numbers from 83 to 103 that all worked pretty similarly and all returned nice equity curves then picking 93 slap bang in the middle of that range might put you in with a fighting chance that it will continue to work even if 93 was not the best result or best equity curve.
-
AuthorPosts