SnakeCharmer 4h US500 – simplicity in the code
Forums › ProRealTime English forum › ProOrder support › SnakeCharmer 4h US500 – simplicity in the code
- This topic has 10 replies, 4 voices, and was last updated 3 years ago by Paul.
-
-
03/11/2019 at 11:26 AM #93325
Hello all, as im starting towards finding super-simple codes and i came across this. Surprised to see it beat buy and hold with only 1 line for entry and 1 for exit. (plus a tiny bit money management)
Im 100% sure this could become alot better with some filters and better setups, just wondering what your take would be on this code. This is just a code trying to find simple ways to beat buy and hold.
Optimized variables:
Stop loss X pips
Exit after X bars
MFE trailing stop.
For entry and sell signal i used just the standard variables for bollinger band (boll mid = average 20 + boll up = 20
Picture is with 0.4 spread and on 250$ contracts (i got tons of trades open in the 1€ contract market. but i wanted to just show that it beats buy and hold (by alot if u take risk/reward into the picture. buy and hold has a huge drawdown in 2008 period vs this code.
So my whole idea behind this code was just if i buy every time close moves above MA 20, i would catch 100% all trends going up. And i wanted to sell when the momentum is changing from “trending up” to “trend might be done” without giving up too much.
Things that would improve it greatly:
- Reduce bad trades by adding filters to avoid choppy areas
- Increase avg win by adding filters/rules to get better entries
- Better money management
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859// Definition of code parameters// SnakeCharmer V 1 - by user JEBUS89 ProRealCode 11.03.2019DEFPARAM CumulateOrders = False // Cumulating positions deactivatedif onmarket and BARINDEX-TRADEINDEX(1)>=20 thenSELL AT MARKETEXITSHORT AT MARKETendifset stop ploss 100// Conditions to enter long positionsbuysignal = (close CROSSES OVER Average[20](close))IF buysignal THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionssellsignal = (close CROSSES under BollingerUp[20](close))IF sellsignal THENSELL AT MARKETENDIF//************************************************************************// MFE trailing stop function//************************************************************************///trailing stoptrailingstop = 12StartTrailingStopValue = 10//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0priceexit = 0endif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif close-tradeprice(1) > StartTrailingStopValue*pointsize thenif 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 levelendifendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif03/11/2019 at 2:01 PM #93340Nice and simple but I always get concerned when I see time based exits so I thought I would see how your strategy worked if the time based exit was anything from 1 to 100 bars long. Here are the results:
It can be seen that there is a strong potential for curve fitting with the value 20 and in fact 17 would give even better results but there is a definite band between 16 and 20 that just happens to have given nice results in the past. The good news is that across a wide range of timed exits it is still profitable. The last bar on the right shows the strategy gain with no timed exits at all. Personally I would remove the timed exit as it only seems to add some curve fitted exits and there is no guarantee that exiting after 16 to 20 bars in the future will add the same gains. It could in fact just happen to result in losses as time is rarely a good reason to exit a trade.
03/11/2019 at 2:16 PM #93343Hi Vonasi!
I Agree, every rule added is another way to curvefit! I added the timebased exit because the entry isnt good enough to always ensure that there will be enough momentum to reach the upper bollinger band.
Originally i used this rule for exit: “High crosses over bollup 20” which gave a lot smaller trades, but i got better avg gain with close crosses under, which is more biased towards “indexes always moving up in the long run” which of course might be a very dangerous thought.
I think with the correct filters in place and probably a better exit, one could see much better results! be sure to share if u got something 😀
Btw check out this, removed all money management except stop loss and used another exit
n1 = 3
n2 = 80
1234567891011121314151617181920// Definition of code parameters// SnakeCharmer V 1 - by user JEBUS89 ProRealCode 11.03.2019DEFPARAM CumulateOrders = false // Cumulating positions deactivated// Conditions to enter long positionsbuysignal = (close CROSSES over Average[20](close))IF buysignal THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionssellsignal = rsi[n1](close) crosses under n2 //(close CROSSES over BollingerUp[20](close))IF sellsignal THENSELL AT MARKETENDIF03/11/2019 at 2:39 PM #93344The last code looks OK for wall st 4 h as well, maybe more.. just re-optimize stop loss roughly and it dosnt look to shabby.
Again im looking for super simple non curvefitted systems that have 90%+ green years. Run enough of them and watch the profits come.. at least thats the gameplan hehe
I keep the “set stop ploss n1” and check for 20-200 with intervals 20. Looks OK on wall st 4h, US 500 4h, italy 4h.
And in the other markets it dosnt seem to completly break, like for example in spain when market dropped almost 60% in 2008, it didnt go broke.. which at least to me tells me that running this in for example US 500 shouldnt break your account within 1-2 months 😛
03/11/2019 at 4:02 PM #9335303/11/2019 at 8:15 PM #9339105/02/2019 at 3:40 PM #9755208/11/2020 at 8:28 AM #141359Hi,
I cam across this post as I was researching a similar idea and was curious to see how it was going? Has anyone committed this into production since?
Thanks very much,
S
08/11/2020 at 6:05 PM #141425Hi,
a nice code to curve-fit a bit more. This from MOD works well with it, on default timeframe or higher. I use it in range 2-4 for all 4 values.
123456789101112timeframe (4 hours,updateonclose) // default 4 or 24//Stochastic RSI | indicatorlengthRSI = aa //RSI periodlengthStoch = bb //Stochastic periodsmoothK = cc //Smooth signal of stochastic RSIsmoothD = dd //Smooth signal of smoothed stochastic RSImyRSI = RSI[lengthRSI](totalprice)MinRSI = lowest[lengthStoch](myrsi)MaxRSI = highest[lengthStoch](myrsi)StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)K = average[smoothK](stochrsi)*100D = average[smoothD](K)1 user thanked author for this post.
08/26/2020 at 3:34 PM #14261809/11/2020 at 11:31 PM #143982 -
AuthorPosts
Find exclusive trading pro-tools on