Array applied on moving average HELP

 
double fastMaV = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,[i]);
double slowMaV = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,[i]);

Hello,

I need your help guys how to make the variable ...[i].... an array variable so i dont have copy the code multiple times for each candle.

Thank You.  

 
Try this: place the cursor on iMA, press F1 and study the example in the reference.
 
Carl Schreiber:
Try this: place the cursor on iMA, press F1 and study the example in the reference.

Hi, I did that but no results can you tell me how or redirect me to any document I can study.

Thank You.

 
themasterx7:

Hi, I did that but no results can you tell me how or redirect me to any document I can study.

Thank You.

It doesn't tell me how to put it in an array . 

 
Any one help :)
 
themasterx7: I need your help guys how to make the variable ...[i].... an array variable so i dont have copy the code multiple times for each candle.
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Why would you “copy the code multiple times for each candle?” There is only one value per candle per length. Your question doesn't make sense.
  3. Where you have “[i],” is the shift value. It can't be an array. Your question doesn't make sense.
 
William Roeder:
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Why would you “copy the code multiple times for each candle?” There is only one value per candle per length. Your question doesn't make sense.
  3. Where you have “[i],” is the shift value. It can't be an array. Your question doesn't make sense.
void OnTick()
  {
  
 double fastMaV0 = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,0);
 double fastMaV1 = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,1);
 double fastMaV2 = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,2);
 double fastMaV3 = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,3);
 double fastMaV4 = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,4);
 /////////////////////////////////////////////////////////////////////////////
 double slowMaV0 = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,0);
 double slowMaV1 = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,1);
 double slowMaV2 = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,2);
 double slowMaV3 = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,3);
 double slowMaV4 = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,4);


if(fastMaV4>slowMaV4&&fastMaV3<slowMaV3&&fastMaV2<slowMaV2&&fastMaV1<slowMaV1&&fastMaV0<slowMaV0)

then i can buy or sell

what you see doesn't make sense !!! I want to calculate the price on those 4 candles or more i dont want to copy it 4 times as you see so i want to put like some kind in an array. 

 
themasterx7:

what you see doesn't make sense !!! I want to calculate the price on those 4 candles or more i dont want to copy it 4 times as you see so i want to put like some kind in an array. 

That's the way it is handled in MT4 (and that's what the reference tells you), switch to MT5 there you hand over an array to CopyBuffer to get more than one value per function call. All you need to know is mentioned in the particular reference.

 
themasterx7:

what you see doesn't make sense !!! I want to calculate the price on those 4 candles or more i dont want to copy it 4 times as you see so i want to put like some kind in an array. 

   double fastMA[5];
   double slowMA[5];
   for(int i=0; i<5; i++)
      {
      fastMA[i] = iMA(NULL,0,fastMa,fastMaShift,fastMaMode,fastMaPrice,i);
      slowMA[i] = iMA(NULL,0,slowMa,slowMaShift,slowMaMode,slowMaPrice,i);
      }
 
Keith has answered your improved question.
     How To Ask Questions The Smart Way. 2004
          Be precise and informative about your problem
 
William Roeder:
Keith has answered your improved question.

Yes it helps when the question can be understood. I didn't understand the original question.

Reason: