Simple CCI with MA Filter EA - page 3

 
RaptorUK:
Yes I think we are . . . just be careful if your use of CCI means it "repaints" . . it might be going back and forth over the 100 many times during a bar
Thankyou ;)
 

I have amended the code of the CCI custom indicator which comes with MT4 as the following

//I added this global input variable

extern int AppliedPrice = 1; //1 means open price, and 5 means typical. see https://docs.mql4.com/constants/prices


//within the start() function, I changed this

MovBuffer[i] = iMA(NULL, 0, CCIPeriod, 0, MODE_SMA, AppliedPrice, i);

When I dropped this on the chart along with the commodity channel index indicator (the one that we have no access to its code). Both gave the same value for typical, but different value for open!!

Someone has an idea?

tapo

 
tapo:

I have amended the code of the CCI custom indicator which comes with MT4 as the following

When I dropped this on the chart along with the commodity channel index indicator (the one that we have no access to its code). Both gave the same value for typical, but different value for open!!

Someone has an idea?

tapo

Do you have a screenshot of these?
 
diostar:
Do you have a screenshot of these?


http://i39.tinypic.com/2e1vvav.png

http://i41.tinypic.com/21o55e1.png

 

Hi,

I have cleaned up the code and kept only a pure CCI trigger and only a code for opening position based on the close of a candle. Can someone explain why this position was opened? Is it because the EA did not wait for a candle to close to take the CCI trigger? If yes, how can we fix that?

http://i40.tinypic.com/znmmue.png

Regards,

tapo

 

Somehow I could not get any attachment. Here is the EA.

http://www.4shared.com/folder/uzm1fNWV/_online.html

Can you please look at it and see why it behaves in this way?

 
tapo:

Somehow I could not get any attachment. Here is the EA.

http://www.4shared.com/folder/uzm1fNWV/_online.html

Can you please look at it and see why it behaves in this way?

Aren't you looking at the CCI values for bars 1 & 2 ? the candle where the order was placed was Bar 0 at the time . . it doesn't matter that its CCI value was eventually 127 . . .

else if (CCI1[ 2 ] > 100 && CCI1[ 1 ] < 100)
 
It does appear from your picture that both CCI1[1] & CCI1[2] are less than 100 so the Sell shouldn't have happened . . . add a print statement to print these out and re-run this in the Strategy Tester so you can see what is going on . . .
 
aptorUK:
It does appear from your picture that both CCI1[1] & CCI1[2] are less than 100 so the Sell shouldn't have happened . . . add a print statement to print these out and re-run this in the Strategy Tester so you can see what is going on . . .

Hi Raptor,

I added this line

Print(CCI1[2] + " | " + CCI1[1]);

I put it live and 1 short and 1 long have been triggered. The 1st position was opened after a candle was closed in which CCI crossed below 100. Whereas the 2nd position at the very candle in which CCI crossed above -100! To me I'm expecting the EA to do like the 1st one all the time, I don't know why it gets moody like that!

Here is the results of the printing

2011.11.07 06:22:09 CCI EURUSD,M1: 122.97015370 | 71.61246612

2011.11.07 06:32:07 CCI EURUSD,M1: -127.56702074 | -89.52929875 (This line does not mach the correct values!)

 

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

You code is this for Buy and Sell

if (CCI1[2] < -100 && CCI1[1] > -100)  //  for BUY
   {

if (CCI1[2] > 100 && CCI1[1] < 100)   // for 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.

Reason: