The Endif at the bottom of wich section? sorry Nonetheless but I try to understand the code…!
// mfe & mae
count = 0
For zz = 1 to 5 do
IF range[zz]=0 THEN
count= 1
ENDIF
next
if count=0 then
n = 4
nn= 1
if method=1 then
maerec=0
mferec=0
for i=1 to n
maerec=maerec+(high[i]-open[i])
mferec=mferec+(open[i]-low[i])
next
for j=1 to nn
maerec=maerec+(open[j]-low[j])
mferec=mferec+(high[j]-open[j])
next
averecentmael=close-(maerec/nn)
averecentmfel=close+(mferec/nn)
averecentmaes=close+(maerec/n)
averecentmfes=close-(mferec/n)
avgl=(averecentmael+averecentmfel)/2
avgs=(averecentmaes+averecentmfes)/2
elsif method=2 then
maerec=0
mferec=0
maerec2=0
mferec2=0
for i=1 to n
maerec=maerec+(high[i]-open[i])
mferec=mferec+(open[i]-low[i])
next
for j=1 to nn
maerec2=maerec2+(open[j]-low[j])
mferec2=mferec2+(high[j]-open[j])
next
averecentmael=close-(maerec2/nn)
averecentmfel=close+(mferec2/nn)
averecentmaes=close+(maerec/n)
averecentmfes=close-(mferec/n)
avgl=(averecentmael+averecentmfel)
avgs=(averecentmaes+averecentmfes)
endif
avgmfemaes=average[25](avgs)
avgmfemael=average[25](avgl)
if vectorial then
periodea = 8
nbchandeliera = 3
mma = average[periodea,1](totalprice)
adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandeliera
angle = (atan(adjasuroppo))
cb1 = angle < 0
cs1 = angle > 0
else
cb1=1
cs1=1
endif
ENDIF
stopped again … zero parameter. I’m losing the will to live.
PaulParticipant
Master
I 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.
defparam cumulateorders = false
defparam preloadbars = 2000
once sll = 1.2 // stoploss long
once sls = 0.6 // stoploss short
once ptl = 1.2 // profit target long
once pts = 1.9 // profit target short
TIMEFRAME(15 minutes)
count1 = 0
For zz1 = 1 to 7 do
IF range[zz1]=0 THEN
count1= 1
ENDIF
next
if count1=0 then
indicator1 = SuperTrend[2,6]
indicator1a = SAR[0.005,0.005,0.01]
cnd1 = (close > indicator1) or (close > indicator1a)
cnd2 = (close < indicator1) or (close < indicator1a)
endif
TIMEFRAME(5 minutes)
count2 = 0
For zz2 = 1 to 11 do
IF range[zz2]=0 THEN
count2= 1
ENDIF
next
if count2=0 then
//Stochastic RSI | indicator
lengthRSIa = 10 //RSI period
lengthStocha = 10 //Stochastic period
smoothKa = 4 //Smooth signal of stochastic RSI
smoothDa = 2 //Smooth signal of smoothed stochastic RSI
myRSIa = RSI[lengthRSIa](close)
MinRSIa = lowest[lengthStocha](myrsia)
MaxRSIa = highest[lengthStocha](myrsia)
if (MaxRSIa-MinRSIa)<>0 then
StochRSIa = (myRSIa-MinRSIa) / (MaxRSIa-MinRSIa)
else
StochRSIa=StochRSIa[1]
endif
K2a = average[smoothKa](stochrsia)*100
D2a = average[smoothDa](K2a)
cnd3 = K2a>D2a
cnd4 = K2a<D2a
endif
TIMEFRAME(default)
// mfe & mae
count3 = 0
For zz3 = 1 to 26 do
IF range[zz3]=0 THEN
count3= 1
ENDIF
next
if count3=0 then
n = 4
nn= 1
maerec=0.01
mferec=0.01
for i=1 to n
maerec=maerec+(high[i]-open[i])
mferec=mferec+(open[i]-low[i])
next
for j=1 to nn
maerec=maerec+(open[j]-low[j])
mferec=mferec+(high[j]-open[j])
next
averecentmael=close-(maerec/nn)
averecentmfel=close+(mferec/nn)
averecentmaes=close+(maerec/n)
averecentmfes=close-(mferec/n)
avgl=(averecentmael+averecentmfel)/2
avgs=(averecentmaes+averecentmfes)/2
avgmfemaes=average[25](avgs)
avgmfemael=average[25](avgl)
periodea = 8
nbchandeliera = 3
mma = average[periodea,1](totalprice)
adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandeliera
angle = (atan(adjasuroppo))
cb1 = angle < 0
cs1 = angle > 0
cb2=close>totalprice
cs2=close<totalprice
// conditions
condbuy = avgmfemael crosses over avgmfemaes
condbuy = condbuy and cb1 and cnd1 and cnd3
condbuy = condbuy and ((high>high[1] or close>open or low>low[1]))
condbuy=condbuy and cb2 and cb2>cb2[1]
condsell = avgmfemael crosses under avgmfemaes
condsell = condsell and cs1 and cnd2 and cnd4
condsell = condsell and ((high<high[1] or close<open or low<low[1]))
condsell = condsell and cs2 and cs2>cs2[1]
// entry
if condbuy then
buy 1 contract at market
set stop %loss sll
set target %profit ptl
endif
if condsell then
sellshort 1 contract at market
set stop %loss sls
set target %profit pts
endif
endif
hey, thanks Paul – gotta be worth a try. You think it’s better to test it without the trail?
PaulParticipant
Master
I 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.
Hi 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 TRADE
IF longonmarket and barindex-tradeindex > 250 and close-positionprice<150 then
sell at market
endif
IF shortonmarket and barindex-tradeindex > 350 and positionprice-close<150 then
exitshort at market
endif
@ 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
PaulParticipant
Master
Thnx for testing cgassfr67. There was never had a proper solution for this problem and likely it’s something which just isn’t fixable.
So we can’t use this strategy…?
PaulParticipant
Master
too early to tell, but I tried something new and it’s working so far!… I will post more later.
PaulParticipant
Master
Still 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.
//-------------------------------------------------------------------------
// Hoofd code : test div0
//-------------------------------------------------------------------------
defparam cumulateorders = false
defparam preloadbars = 2000
once sll = 0.2 // stoploss long
once sls = 0.2 // stoploss short
once ptl = 0.5 // profit target long
once pts = 0.5 // profit target short
TIMEFRAME(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 | indicator
lengthRSIa = 10 //RSI period
lengthStocha = 10 //Stochastic period
smoothKa = 4 //Smooth signal of stochastic RSI
smoothDa = 2 //Smooth signal of smoothed stochastic RSI
myRSIa = RSI[lengthRSIa](close)
MinRSIa = lowest[lengthStocha](myrsia)
MaxRSIa = highest[lengthStocha](myrsia)
if (MaxRSIa-MinRSIa)<>0 then
StochRSIa = (myRSIa-MinRSIa) / (MaxRSIa-MinRSIa)
else
StochRSIa=StochRSIa[1]
endif
K2a = average[smoothKa](stochrsia)*100
D2a = average[smoothDa](K2a)
cnd3 = K2a>D2a
cnd4 = K2a<D2a
TIMEFRAME(default)
// mfe & mae
if not onmarket then
n = 4
nn= 1
maerec=0
mferec=0
for i=1 to n
maerec=maerec+(high[i]-open[i])
mferec=mferec+(open[i]-low[i])
next
for j=1 to nn
maerec=maerec+(open[j]-low[j])
mferec=mferec+(high[j]-open[j])
next
averecentmael=close-(maerec/nn)
averecentmfel=close+(mferec/nn)
averecentmaes=close+(maerec/n)
averecentmfes=close-(mferec/n)
avgl=(averecentmael+averecentmfel)/2
avgs=(averecentmaes+averecentmfes)/2
avgmfemaes=average[25](avgs)
avgmfemael=average[25](avgl)
periodea = 8
nbchandeliera = 3
mma = average[periodea,1](totalprice)
adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandeliera
angle = (atan(adjasuroppo))
cb1 = angle < 0
cs1 = angle > 0
else
cb1=0
cs1=0
endif
cb2=close>totalprice
cs2=close<totalprice
// conditions
condbuy = avgmfemael crosses over avgmfemaes
condbuy = condbuy and cb1 and cnd1 and cnd3
condbuy = condbuy and ((high>high[1] or close>open or low>low[1]))
condbuy=condbuy and cb2 and cb2>cb2[1]
condsell = avgmfemael crosses under avgmfemaes
condsell = condsell and cs1 and cnd2 and cnd4
condsell = condsell and ((high<high[1] or close<open or low<low[1]))
condsell = condsell and cs2 and cs2>cs2[1]
// entry
if condbuy then
buy 1 contract at market
set stop %loss sll
set target %profit ptl
endif
if condsell then
sellshort 1 contract at market
set stop %loss sls
set target %profit pts
endif
I 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.
Hello guys!
Have you thought about changing the Money Management? Maybe the problem comes from this…!
Could you try something like:
ONCE factor = 8 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
@Paul, could you upload your two .itf?