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/18/2021 at 6:34 PM #158345
Anyone else get the dreaded div by zero for this? Apart from the indicators, the only lines I can see with division by anything are
12345averecentmael=close-(maerec/nn)averecentmfel=close+(mferec/nn)averecentmaes=close+(maerec/n)averecentmfes=close-(mferec/n)but n and nn have permanent values.
🤔🤔🤔???
01/18/2021 at 7:28 PM #158368always that error!
It’s either in that section or in the vectorial part.
How about adding before
1if range[0]>0 and range[1]>0 and range[2]>0 and range[3]>0 and range[4]>0 and range[5]>0 thenmaybe up to 8/9/10, to include vectorial. Not very nice but it makes sure when the calculation starts every bar has a range.
Otherwise use min(x,x) for certain parts?
01/18/2021 at 7:39 PM #158370So, where would i add that line exactly? at the top of the //mfe & mae section?
01/18/2021 at 10:48 PM #158408Something like this,
I thought I tried it in the past and in that situation it didn’t work, but I’ve got no other solution.
vectorial seems ok and also Stochastic RSI
ps you get check the time of the error and see if in the chart test=1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566TIMEFRAME(default)// mfe & maeif range[0]>0 and range[1]>0 and range[2]>0 and range[3]>0 and range[4]>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)endifendifif range[0]=0 or range[1]=0 or range[2]=0 or range[3]=0 or range[4]=0 thentest=1elsetest=0endifgraph test01/19/2021 at 10:55 AM #15844801/19/2021 at 11:34 AM #158458it doesn’t show up in backtest, that is what’s so infuriating. Just when you think you’ve done the hard work and everything is sweet, you launch it but it wont run live because ‘division by zero’. They don’t tell you where the problem is and it’s almost never apparent in the code because the values are changing all the time. Try doing a search, there’s dozens of threads on the subject but I don’t think anyone’s found a cure.
For me it is definitely worse in v11. Algos that ran fine in 10.3 are now getting stopped for this regularly.
01/19/2021 at 12:33 PM #158473Yeah, ive had a bunch of div 0 and similar errors recently. Very frustrating but a bit of hard work and help from the forum has solved them all.
Fact is there will be something attempting to div/0 and a well placed MAX(<something above zero that doesn’t break your system>, <offending code>) will fix most of them.
graph all your variables/returning values, find the zero and it should be possible to fix.
You can also try using If variable <> 0 then <do dodgy code> Endifs also.
its a pain but it is what it is.
01/19/2021 at 2:56 PM #158513I don’t think it’s the solution above/below works though in my post, because it only solves to have a value before dividing it. And the error appears to be the other way around.
Problem is a zero is never used as far I can tell.
Anyway another way to have it programmed, instead testing and coding each bar individually, like this below. Should only take trades if the last xx bars have range and not have open=close=high=low.
12345678910111213// mfe & maecount = 0For zz = 1 to xx doIF range[zz]=0 THENcount= 1ENDIFnextif count=0 thenn = 4nn= 1wild guess, but what if with live data feed i.e. there’s no tick/bar data is not the same as the backtest data?
Something like backtestdata has open=low=high=close and running live the bar is simply skipped or the other way around.
Maybe such bar is processed another way but not visible and maybe the error is broader then the error message itself gives indication.
01/19/2021 at 4:00 PM #158522Thanks Paul, I’ll try that and see if it runs 🤞
01/19/2021 at 5:48 PM #158536@nonetheless, can you please upload a .itf file? As I don’t see the error I’d like to see what’s the difference… thanks 😉
01/19/2021 at 5:53 PM #15853901/19/2021 at 6:31 PM #15855101/19/2021 at 6:46 PM #158553at the moment I have it in demo with Paul’s suggestion above but hasn’t taken a trade yet. When you say, ‘I don’t see the error’, do you mean you dont get division by zero rejection?
01/19/2021 at 7:29 PM #15855801/19/2021 at 7:41 PM #158559it’s in my demo account that’s not open just now. but it’s exactly the same as v4.5 atr but add
12345678count = 0For zz = 1 to 5 doIF range[zz]=0 THENcount= 1ENDIFnextif count=0 thenunder the // mfe & mae section, with another endif at the bottom. There’s no other changes.
-
AuthorPosts
Find exclusive trading pro-tools on