Simple CCI with MA Filter EA - page 4

 
RaptorUK:

I don't see anything wrong in this example . . .

You code is this for Buy and Sell

These values fall within those ranges . . .

2011.11.07 06:22:09 CCI EURUSD,M1: 122.97015370 | 71.61246612 <------- for SELL

2011.11.07 06:32:07 CCI EURUSD,M1: -127.56702074 | -89.52929875 <------ for BUY

You find an issue when you code is working . . . re-run the problem area you posted the picture from by using the Strategy Tester.

I think I've found the issue. I'll let you know when I've verified it. For the moment, just consider the fact that the printings were not the true values, as I mentioned earlier.
 
tapo:
I think I've found the issue. I'll let you know when I've verified it. For the moment, just consider the fact that the printings were not the true values, as I mentioned earlier.

It looks like the issue was with the price parameter of CCI. The price parameter of the CCI in the EA was close. That was the reason behind the discrepancy. Now as I've changed it to typical printings give exactly the same values as the one the of the plotted indicator, and a position is opened always on the 3rd candle as the following

value above 100 -----> value below 100 -----> sell

value below -100 -----> value above -100 -----> buy

:)

Do you have any idea if there is any advantage of calling CCI function at every tick vs every bar? just the call, not to trigger a trade.

 
tapo:


Do you have any idea if there is any advantage of calling CCI function at every tick vs every bar? just the call, not to trigger a trade.

Well done for finding the issue.

I don't see any benefit at all . . . also you might want to consider reducing the Array size down as well . . maybe to CCI_Period +5, this will make things run quicker in the Strategy Tester . . when you get round to using it, if you aren't already.

 
RaptorUK:

Well done for finding the issue.

I don't see any benefit at all . . . also you might want to consider reducing the Array size down as well . . maybe to CCI_Period +5, this will make things run quicker in the Strategy Tester . . when you get round to using it, if you aren't already.

Good suggestion.

I'm currently coding an MA filter of 2 MAs. Do you know what this means?

ma_shift - MA shift. Indicators line offset relate to the chart by timeframe.

source: https://docs.mql4.com/indicators/iMA

I've put 0 because it's the default value, but not got it.

 

Hi Raptor and fellow programmers,

Would you like to examine my new EA? I'd like to hear from you if the code is fine. The MA filter is self explanatory. You can straight away understand what I mean by it. A second opinion from a more experienced programmer can be invaluable.

Also, regarding the array size, is it related to the indicator's period? is it safe to be equal to or less than the indicator's period?

Cheers,

Files:
 
Is there a simple way to close a running position which was opened by an EA at the time a new order is sent by the same EA? or we have to go through a for loop to search all existing orders?
Reason: