You could try with something like:
MFIperiod = 14
if (summation[MFIperiod](volume>0)=MFIperiod) then
myMFI = moneyflowindex[MFIperiod]
endif
This will prevent the code to call the MFI if no volumes at all were present during the last needed periods of calculation (not tested).
@kkkok288 did you try below so that the EA only tries to execute during normal trading hours … so substitute 080000 and 180000 with your normal trading for HS50 in your Timezone?
starttime=080000
endtime=180000
tcondition=time>=starttime and time<endtime
if tcondition then
etc etc
Nicolas snippet using ‘summation’ added to here as Log 193
Snippet Link Library
Thanks GraHal, that’s the first idea I proposed, but if there were no Volumes in the last X periods prior to starttime, then the problem is the same. I think that my last code snippet is the best workaround.
@kkkok288 how did you go on with the HS50 Systems?
I am currently having a go … surprising how the results change when using Nicolas suggestion?
Hi, GraHal
Just came back form the Christmas holiday. I apologise for the late reply.
As I said last time, I am not good in coding.
Hence, I replace the MFI with Stochastic and CCI indicators in order for the EA to run smoothly.
Of course, the result will change after the replacement.
For those timeframe >=30m, I can continue using MFI.
Hey I just had an idea I will try later …
if (summation[14](volume>0)=14) then
myMFI = moneyflowindex[14]
Else
if (summation[13](volume>0)=13) then
myMFI = moneyflowindex[13]
Else
if (summation[12](volume>0)=12) then
myMFI = moneyflowindex[12]
Else
etc etc
Problem is that Backtest (BT) will probably show … (summation[14](volume>0)=14) = 1 … whereas that is often not the case in Live Forward Test (FT) which is why we get such disparity of results between BT and FT.
How can BT calculate MFI with no volume whereas FT doesn’t??
It’s as if BT uses a different calculation and ignores periods with no volume and moves onto the next period until if finds the most recent 14 periods with volume?? However, those most recent 14 periods with volume may extend over 20 to 30 elapsed periods + (with several of the 30 elapsed periods containing no volume)??
Anyway above was an idea / thoughts that just came to me while cleaning my teeth! Good to get the brain going again after all the booze and food!!?? 🙂
Hi GraHal
Thank you for your effort.
I am also wondering why MFI can work in BT and not FT.
This is very confusing to the traders. Is there any way we can highlight this problem to the ProRealTime team directly?
I always got rejected from IG help centre by asking me to add ProLoadBars = 20000 or saying the problem was already forwarded to relevant department and waiting for the feedback.
@kkkok288 I have been doing some work on another System which was getting randomly stopped, see here
https://www.prorealcode.com/topic/trading-system-automatically-stopped/
We are not 100% sure yet, but it is looking like it might be a divide by zero problem due to there being no bars / phantom bars and so calculations cannot be performed as expected.
I can’t help think that maybe the Issue with your Systems getting stopped might be of similar origin?
Have you got any nearer to a solution or have you abandoned the Systems??
This is very confusing to the traders. Is there any way we can highlight this problem to the ProRealTime team directly?
PRT/ITF is actually working to add more precise error messages for each specific case. It will help us a lot finding why some issues arise sometimes!
Hi GraHal
As I told you last time, I just modified my EA by replacing the MFI with other indicators e.g. CCI, stochastic as well as RSI. I am still able to maintain 80% gain as compared to using MFI previously.
Hi Nicolas
I never directly deal with PRT before.
My bad experience is only with the help centre from IG. They said they have forwarded my problem to PRT. Till now, I do not receive any feedback from them.
So far, the error message is just keep on asking me to add PRELOADBARS = 20000 only.