Please help me with this code

 
I want my ea to open buy with iccI indicator.for example i want the code to be like this

if icci indicator is above 100 and less than -100 then greater than or equal to 100     ( OPEN BUY)

Please can someone help me.

Below is the image of what I want the code to perform.
 

You'd better start to read the docs and the book.

Otherwise you wouldn't have written:

cclose1=iccI(NULL,0,14,PRICE_TYPICAL,0)
cclose2=iccI(NULL,0,14,PRICE_TYPICAL,0)

will cclose1 and cclose 2 ever become different?

and

If(cclose1 >100 && cclose1<-100&&

(despite the gramm. error) this will never become true - why?

 
please see the pics of what i mean
 
pics of what i mean the ea should be doing
 
i have all rest of the code all i need is just the  mql4 logic to perform buys at this point of icci indicator.
 

I know what he wants. The problem is, he don't know how to use it properly.

Basically to open buy, cclose1 must be at -100 or smaller and cclose2 at least bigger than cclose1 so that it will go into upward direction.

To open sell, cclose1 must be at 100 or bigger and cclose2 at least smaller than cclose1 so that it will go into downward direction.

I bet it is something like that.

 
deysmacro:

I know what he wants. The problem is, he don't know how to use it properly.

Basically to open buy, cclose1 must be at -100 or smaller and cclose2 at least bigger than cclose1 so that it will go into upward direction.

To open sell, cclose1 must be at 100 or bigger and cclose2 at least smaller than cclose1 so that it will go into downward direction.

I bet it is something like that.

Deysmacro your right but not actually what I want.just as describe in the pic I want cclose1 to start from 100 down to -100 then move up again to 100 level before buy order is opened. I know how to write trading logics once it explain properly like you did above though not actually what i need, or better still if you can help me code it, that's fine. All am trying to archive is for logic as describe on the picture to suit my trading ea system logic.
 
dan100: Deysmacro your right but not actually what I want.just as describe in the pic I want cclose1 to start from 100 down to -100 then move up again to 100 level before buy order is opened.
Then that is exactly what you need to code. You can't do it in 1-3 lines. You have to remember as in a state machine.
Not compiled, not tested.
cclose1=iccI(NULL,0,14,PRICE_TYPICAL,0);

static bool wasP100 = false;
static bool wasM100 = false;

if(cclose1 > 100){
   wasP100 = true;
   if(!wasM100) return;               // No -100 yet.
   wasM100 = false;                   // Reset for next time.
   OpenOrder();
   return;
}
if(!wasP100) return;                  // Waiting for +100.
if(cclose1 <= -100) wasM100 = true;   // Saw -100 wait for next +100.
return;                               // Waiting for -100 and/or +100.
Not compiled, not tested.
If you just want to alternate buys and sells, you can simplify:
Not compiled, not tested.
cclose1=iccI(NULL,0,14,PRICE_TYPICAL,0);

static bool buyEnabled  = true;
static bool sellEnabled = true;

if(cclose1 > 100 && buyEnabled){
   BuyEnabled  = false;
   SellEnabled = true;
   OpenOrder(OP_BUY);
   return;
}
if(cclose1 < 100 && sellEnabled){
   BuyEnabled  = true;
   SellEnabled = false;
   OpenOrder(OP_SELL);
   return;
}
return; // Waiting.
Not compiled, not tested.
 
dan100:

dan100:
Deysmacro your right but not actually what I want.just as describe in the pic I want cclose1 to start from 100 down to -100 then move up again to 100 level before buy order is opened. I know how to write trading logics once it explain properly like you did above though not actually what i need, or better still if you can help me code it, that's fine. All am trying to archive is for logic as describe on the picture to suit my trading ea system logic.

double cci[20];

for(i=0;i<20;i++)
   cci[i]=iCCI(NULL,0,14,PRICE_CLOSE,i);
   
for(i=1;i<20;i++)
  {
   for(j=i+1;j<20;j++)
      if(cci[0] >  100 && cci[1]   <= 100 && 
         cci[i] > -100 && cci[i+1] <=-100 &&
         cci[j] <  100 && cci[j+1] >= 100)

 
ok thank you very much for you suggestions and code,i appreciate it, i will try to implement it.thanks again.
 

please one more thing please what code to add to an ea to only open 1buy order in an uptrend and one order in a selling trend. i mean after one buy the ea stops and wait for sell signal to complete before opening another order. just one trade per uptrend and one trade per down trending.


or time value to make the ea wait 1HR before another trade.pls help

Reason: