Array

 

When I input RSI60PO, RSI60P1, RSI60P2, RSI60P3 in my script, the correct value appears. However, when I input RSI60[0] in the script, the value returned is 0, instead of the value of RSI60P0. This happens with all four values and I'm not sure why. Thanks for the help in advance 

   double RSI60P0 = iRSI(NULL, PERIOD_H1, RSIPeriod, PRICE_CLOSE, 0);
   double RSI60P1 = iRSI(NULL, PERIOD_H1, RSIPeriod, PRICE_CLOSE, 1);
   double RSI60P2 = iRSI(NULL, PERIOD_H1, RSIPeriod, PRICE_CLOSE, 2);
   double RSI60P3 = iRSI(NULL, PERIOD_H1, RSIPeriod, PRICE_CLOSE, 3);
   double RSI60[4] = {"RSI60P0", "RSI60P1","RSI60P2", "RSI60P3"};
 
  1. Why did you post your MT4 question in the MT5 EA 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. Of course, RSI60[0] is zero. You initialized it with a non-numeric string.

 
William Roeder #:
  1. Why did you post your MT4 question in the MT5 EA 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. Of course, RSI60[0] is zero. You initialized it with a non-numeric string.

Apologies I'll do it properly next time

I do not understand what is meant by your second comment. Changing the double to a string before will RSI60[] only returns RSI60P0 or RSI60P1 or RSI60P2 or RSI60P3 instead of their numerical values

 
luxecapital #: Changing the double to a string before will RSI60[] only ret

You did not change a double to a string. You changed a string (“RSI60P0”) to a double; the result is zero.

double RSI60[4] = {"RSI60P0", "RSI60P1","RSI60P2", "RSI60P3"};
 
William Roeder #:

You did not change a double to a string. You changed a string (“RSI60P0”) to a double; the result is zero.

Don't understand what you mean. This is what I did:

I did RSI60[0] in the script and it returned RSI60P0

string RSI60[4] = {"RSI60P0", "RSI60P1","RSI60P2", "RSI60P3"};
 
You did not! You did double RSI60[0]="RSI60P0"; double RSI60[1]="RSI60p1; etc. All result in zero.