Help coding ea

 

Hi,

I want to include the indicator to ea. The logic is: if price close above the red line then op buy and if price close below the green line op sell.

Can anybody help me..? Sorry about my english.

Files:
dynamicrs.mq4  3 kb
 
 
johanesvi: I want to include the indicator to ea.
  1. Why? You don't include an indicator in a EA, you get the indicator's value. Detailed explanation of iCustom - MQL4 forum
  2. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 

I'd include the indicator but I think there's an error at this code:


int i_ma() {
   double ima_high = iCustom(NULL,0,"DynamicRS",5,25,MODE_HIGH,0);
   double ima_low = iCustom(NULL,0,"DynamicRS",5,25,MODE_LOW,1);
   if (Close[1] < (ima_high + 5)) return (-2);
   if (Close[1] > (ima_low - 5)) return (2);
   return (0);
}
 
johanesvi:

I'd include the indicator but I think there's an error at this code:

double ima_high = iCustom(NULL,0,"DynamicRS",5,25,MODE_HIGH,0);     //    bar number to calculate buffervalue 'mode' from indicator "DynamicRS"
   double ima_low = iCustom(NULL,0,"DynamicRS",5,25,MODE_LOW,1);   //wrong

mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.

looks like the name mode is confussing you

an indicator can have 8 buffers maximum you can read with using iCustom

mode stands for the buffer of the indicator you wanna read

it has nothing to do with mode_high mode_low mode_open or ........

the last parameter is for the bar you want the value from

 
deVries:

mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.

looks like the name mode is confussing you

an indicator can have 8 buffers maximum you can read with using iCustom

mode stands for the buffer of the indicator you wanna read

it has nothing to do with mode_high mode_low mode_open or ........

the last parameter is for the bar you want the value from


OK, I got it... thanks for your explanation.
Reason: