Strategy MAEX – experiment with MFE & MAE
Forums › ProRealTime English forum › ProOrder support › Strategy MAEX – experiment with MFE & MAE
- This topic has 82 replies, 14 voices, and was last updated 1 year ago by Meta Signals Pro.
-
-
01/19/2021 at 8:48 PM #15857501/19/2021 at 9:05 PM #15857612345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879// mfe & maecount = 0For zz = 1 to 5 doIF range[zz]=0 THENcount= 1ENDIFnextif count=0 thenn = 4nn= 1if method=1 thenmaerec=0mferec=0for i=1 to nmaerec=maerec+(high[i]-open[i])mferec=mferec+(open[i]-low[i])nextfor j=1 to nnmaerec=maerec+(open[j]-low[j])mferec=mferec+(high[j]-open[j])nextaverecentmael=close-(maerec/nn)averecentmfel=close+(mferec/nn)averecentmaes=close+(maerec/n)averecentmfes=close-(mferec/n)avgl=(averecentmael+averecentmfel)/2avgs=(averecentmaes+averecentmfes)/2elsif method=2 thenmaerec=0mferec=0maerec2=0mferec2=0for i=1 to nmaerec=maerec+(high[i]-open[i])mferec=mferec+(open[i]-low[i])nextfor j=1 to nnmaerec2=maerec2+(open[j]-low[j])mferec2=mferec2+(high[j]-open[j])nextaverecentmael=close-(maerec2/nn)averecentmfel=close+(mferec2/nn)averecentmaes=close+(maerec/n)averecentmfes=close-(mferec/n)avgl=(averecentmael+averecentmfel)avgs=(averecentmaes+averecentmfes)endifavgmfemaes=average[25](avgs)avgmfemael=average[25](avgl)if vectorial thenperiodea = 8nbchandeliera = 3mma = average[periodea,1](totalprice)adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandelieraangle = (atan(adjasuroppo))cb1 = angle < 0cs1 = angle > 0elsecb1=1cs1=1endifENDIF01/20/2021 at 10:30 AM #158637
stopped again … zero parameter. I’m losing the will to live.
01/20/2021 at 3:16 PM #158690I get your frustration. Created a stripped down version, one last attempt.
One thing also I spotted, which doesn’t change results, and most likely will not be the cause, but there were 2 rows which were not written correct. The combination and & or at the condsell/condbuy area. It was missing ().
Anyway you could test this and then call it a day.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123defparam cumulateorders = falsedefparam preloadbars = 2000once sll = 1.2 // stoploss longonce sls = 0.6 // stoploss shortonce ptl = 1.2 // profit target longonce pts = 1.9 // profit target shortTIMEFRAME(15 minutes)count1 = 0For zz1 = 1 to 7 doIF range[zz1]=0 THENcount1= 1ENDIFnextif count1=0 thenindicator1 = SuperTrend[2,6]indicator1a = SAR[0.005,0.005,0.01]cnd1 = (close > indicator1) or (close > indicator1a)cnd2 = (close < indicator1) or (close < indicator1a)endifTIMEFRAME(5 minutes)count2 = 0For zz2 = 1 to 11 doIF range[zz2]=0 THENcount2= 1ENDIFnextif count2=0 then//Stochastic RSI | indicatorlengthRSIa = 10 //RSI periodlengthStocha = 10 //Stochastic periodsmoothKa = 4 //Smooth signal of stochastic RSIsmoothDa = 2 //Smooth signal of smoothed stochastic RSImyRSIa = RSI[lengthRSIa](close)MinRSIa = lowest[lengthStocha](myrsia)MaxRSIa = highest[lengthStocha](myrsia)if (MaxRSIa-MinRSIa)<>0 thenStochRSIa = (myRSIa-MinRSIa) / (MaxRSIa-MinRSIa)elseStochRSIa=StochRSIa[1]endifK2a = average[smoothKa](stochrsia)*100D2a = average[smoothDa](K2a)cnd3 = K2a>D2acnd4 = K2a<D2aendifTIMEFRAME(default)// mfe & maecount3 = 0For zz3 = 1 to 26 doIF range[zz3]=0 THENcount3= 1ENDIFnextif count3=0 thenn = 4nn= 1maerec=0.01mferec=0.01for i=1 to nmaerec=maerec+(high[i]-open[i])mferec=mferec+(open[i]-low[i])nextfor j=1 to nnmaerec=maerec+(open[j]-low[j])mferec=mferec+(high[j]-open[j])nextaverecentmael=close-(maerec/nn)averecentmfel=close+(mferec/nn)averecentmaes=close+(maerec/n)averecentmfes=close-(mferec/n)avgl=(averecentmael+averecentmfel)/2avgs=(averecentmaes+averecentmfes)/2avgmfemaes=average[25](avgs)avgmfemael=average[25](avgl)periodea = 8nbchandeliera = 3mma = average[periodea,1](totalprice)adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandelieraangle = (atan(adjasuroppo))cb1 = angle < 0cs1 = angle > 0cb2=close>totalpricecs2=close<totalprice// conditionscondbuy = avgmfemael crosses over avgmfemaescondbuy = condbuy and cb1 and cnd1 and cnd3condbuy = condbuy and ((high>high[1] or close>open or low>low[1]))condbuy=condbuy and cb2 and cb2>cb2[1]condsell = avgmfemael crosses under avgmfemaescondsell = condsell and cs1 and cnd2 and cnd4condsell = condsell and ((high<high[1] or close<open or low<low[1]))condsell = condsell and cs2 and cs2>cs2[1]// entryif condbuy thenbuy 1 contract at marketset stop %loss sllset target %profit ptlendifif condsell thensellshort 1 contract at marketset stop %loss slsset target %profit ptsendifendif01/20/2021 at 4:53 PM #158704hey, thanks Paul – gotta be worth a try. You think it’s better to test it without the trail?
01/20/2021 at 5:04 PM #158707I just wanted it to be light and that it opens a position. The exit criteria are not important but have no influence I think about this error. So you could add that.
The code above I’ve put in demo and will let you know if it fails or not.
1 user thanked author for this post.
01/25/2021 at 9:30 AM #159334Hi nonetheless,
Thank you for your code. Just a small suggestion to the //EXIT ZOMBIE TRADE. It helps with both the long and short avg profit/loss figures. The overall result remains more or less the same but the risk are less. The 150 represents the max profit and loss the system takes on the backtest so the logic is that if you do not get to those figures in a reasonable amount of time you might as well cover the position. We all know that small timeframes can change quickly.
EXIT ZOMBIE TRADE1234567//EXIT ZOMBIE TRADEIF longonmarket and barindex-tradeindex > 250 and close-positionprice<150 thensell at marketendifIF shortonmarket and barindex-tradeindex > 350 and positionprice-close<150 thenexitshort at marketendif1 user thanked author for this post.
01/29/2021 at 9:12 AM #159765@ Paul,
I tested your code, i copy it in @Nonetheless ea.
The EA take an position, and after 1 minute, he closed the position and give an error (the system received a negative parameter or nul )
Here are the itf
I have the same error with DJ1m Maex v4.5 atr
Have a nice day
01/29/2021 at 2:10 PM #15983602/01/2021 at 9:59 AM #16002202/02/2021 at 6:05 PM #160197too early to tell, but I tried something new and it’s working so far!… I will post more later.
1 user thanked author for this post.
02/02/2021 at 8:20 PM #160203Still no problems in both strategies. If the error occurs ONLY while in position, then don’t calculate the questionable indicators while in position. This means you can’t reverse on opposite signal, but for long/short only it should work which is fine for me.
Like this below, or include all condbuy/condsell conditions. But with mtf it could be a bitmore tricky. Actually I think it’s perhaps not programmed right below. But it’s also in the test. Anyway this is the idea.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108//-------------------------------------------------------------------------// Hoofd code : test div0//-------------------------------------------------------------------------defparam cumulateorders = falsedefparam preloadbars = 2000once sll = 0.2 // stoploss longonce sls = 0.2 // stoploss shortonce ptl = 0.5 // profit target longonce pts = 0.5 // profit target shortTIMEFRAME(15 minutes)indicator1 = SuperTrend[2,6]indicator1a = SAR[0.005,0.005,0.01]cnd1 = (close > indicator1) or (close > indicator1a)cnd2 = (close < indicator1) or (close < indicator1a)TIMEFRAME(5 minutes)//Stochastic RSI | indicatorlengthRSIa = 10 //RSI periodlengthStocha = 10 //Stochastic periodsmoothKa = 4 //Smooth signal of stochastic RSIsmoothDa = 2 //Smooth signal of smoothed stochastic RSImyRSIa = RSI[lengthRSIa](close)MinRSIa = lowest[lengthStocha](myrsia)MaxRSIa = highest[lengthStocha](myrsia)if (MaxRSIa-MinRSIa)<>0 thenStochRSIa = (myRSIa-MinRSIa) / (MaxRSIa-MinRSIa)elseStochRSIa=StochRSIa[1]endifK2a = average[smoothKa](stochrsia)*100D2a = average[smoothDa](K2a)cnd3 = K2a>D2acnd4 = K2a<D2aTIMEFRAME(default)// mfe & maeif not onmarket thenn = 4nn= 1maerec=0mferec=0for i=1 to nmaerec=maerec+(high[i]-open[i])mferec=mferec+(open[i]-low[i])nextfor j=1 to nnmaerec=maerec+(open[j]-low[j])mferec=mferec+(high[j]-open[j])nextaverecentmael=close-(maerec/nn)averecentmfel=close+(mferec/nn)averecentmaes=close+(maerec/n)averecentmfes=close-(mferec/n)avgl=(averecentmael+averecentmfel)/2avgs=(averecentmaes+averecentmfes)/2avgmfemaes=average[25](avgs)avgmfemael=average[25](avgl)periodea = 8nbchandeliera = 3mma = average[periodea,1](totalprice)adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandelieraangle = (atan(adjasuroppo))cb1 = angle < 0cs1 = angle > 0elsecb1=0cs1=0endifcb2=close>totalpricecs2=close<totalprice// conditionscondbuy = avgmfemael crosses over avgmfemaescondbuy = condbuy and cb1 and cnd1 and cnd3condbuy = condbuy and ((high>high[1] or close>open or low>low[1]))condbuy=condbuy and cb2 and cb2>cb2[1]condsell = avgmfemael crosses under avgmfemaescondsell = condsell and cs1 and cnd2 and cnd4condsell = condsell and ((high<high[1] or close<open or low<low[1]))condsell = condsell and cs2 and cs2>cs2[1]// entryif condbuy thenbuy 1 contract at marketset stop %loss sllset target %profit ptlendifif condsell thensellshort 1 contract at marketset stop %loss slsset target %profit ptsendif02/03/2021 at 9:58 AM #160223I had the stripped down version on test for a while and it worked fine, but as soon as I added the MM and the trail then I kept getting the zero parameter error. That was on 1m.
Have you been testing the above at 10sec?
If so then the upper TFs could probably be brought down to maybe 1m and 5m, but would need re-optimizing. I’ll try it later if i get the time.
02/03/2021 at 11:33 AM #160238Hello guys!
Have you thought about changing the Money Management? Maybe the problem comes from this…!
Could you try something like:
1ONCE factor = 8 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc02/03/2021 at 1:50 PM #160243 -
AuthorPosts
Find exclusive trading pro-tools on