Download MetaTrader 5

Indicator Values for yesterday

To add comments, please log in or register
gkintl66
15
gkintl66  
Hi, I am new to coding. I wish to know how to write a code to get  the RSI indicator's high, low and close values for YESTERDAY in a M15 time frame. Can anybody help me?
whroeder1
16086
whroeder1  
gkintl66 Can anybody help me?
Help you with what? You've stated no question, posed no problem, posted no code.
  1. learn to code it, or pay (Freelance) 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.
  2. There may be no "YESTERDAY" if yesterday was the weekend,
  3. Find the start of today and the start of the previous day. https://www.mql5.com/en/forum/159840#comment_3816236
  4. Get the RSI values, find the high. What's the problem?
gkintl66
15
gkintl66  
datetime yesterday = iTime(NULL, PERIOD_D1, 1);
         int iYesterday= iBarShift(NULL, 0, yesterday);
         double Stoch[25];
         for(int j=iYesterday;j<=25;j++)
         Stoch[j]=iStochastic(NULL,PERIOD_M15,32,3,3,MODE_EMA,1,MODE_MAIN,j);

whroeder1
:


Help you with what? You've stated no question, posed no problem, posted no code.
  1. learn to code it, or pay (Freelance) 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.
  2. There may be no "YESTERDAY" if yesterday was the weekend,
  3. Find the start of today and the start of the previous day. https://www.mql5.com/en/forum/159840#comment_3816236
  4. Get the RSI values, find the high. What's the problem?
I included the code provided above

To check the output, initially, i tried the following:
         Alert ("the bar is ", iYesterday);   
I then counted the bars manually and there was a match (showed how many bars to go back to reach the first bar of previous day).

So, now I changed the Alert as Alert("the stochastics value is  ", Stoch[j]);

it continues to show only zero instead of showing all the stoch values. Can you tell me where I have gone wrong? There are 25 bars every day in M15 time frame. I trade in equity market.
whroeder1
16086
whroeder1  
gkintl66: I included the code provided above There are 25 bars every day in M15 time frame. I trade in equity market.
  1. Don't post things inside of a quote block. MQL4 Forum editor problem - MQL4 forum
  2. There may or may not be 25 bars, weekend, market holiday, no volume. No tick, no new bar. "Free-of-Holes" Charts - MQL4 Articles Do not assume. Find the last bar of the day.
  3. for(int j=iYesterday;j<=25;j++)
    If its the middle of today, beginning of the day is like 10, iYesterday will be like 25+10. Your loop only runs for 10. You need the beginning (of yesterday), the last/end to loop, and another variable to fill your array - you can't use j = [35..11] to fill an array [0 .. 24].
gkintl66
15
gkintl66  
whroeder1:
  1. Don't post things inside of a quote block. MQL4 Forum editor problem - MQL4 forum
  2. There may or may not be 25 bars, weekend, market holiday, no volume. No tick, no new bar. "Free-of-Holes" Charts - MQL4 Articles Do not assume. Find the last bar of the day.
  3. for(int j=iYesterday;j<=25;j++)
    If its the middle of today, beginning of the day is like 10, iYesterday will be like 25+10. Your loop only runs for 10. You need the beginning (of yesterday), the last/end to loop, and another variable to fill your array - you can't use j = [35..11] to fill an array [0 .. 24].
double Trac[];
      datetime yesterday = iTime(NULL, PERIOD_D1, 1);
      datetime today = iTime(NULL, PERIOD_D1,0);
      int iYesterday= iBarShift(NULL, PERIOD_M15, yesterday);
      int itoday = iBarShift(NULL,PERIOD_M15,today);
      int iYesterdayclose = itoday-1;
      int X = iYesterday-itoday-1;
      ArrayResize(Trac, X);
      for(j=iYesterdayclose;j<=iYesterday;j++)
     Trac[X] = iStochastic(NULL,PERIOD_M15,32,3,3,MODE_EMA,1,MODE_MAIN,j);
     double YC;
     YC = iStochastic(NULL,PERIOD_M15,32,3,3,MODE_EMA,1,MODE_MAIN,iYesterdayclose);
     int maxval = ArrayMaximum(Trac,WHOLE_ARRAY,0);
     int minval = ArrayMinimum(Trac,WHOLE_ARRAY,0);
     double YAVG;
     double highval = Trac[maxval];
     double lowval = Trac[minval];
Can you pls., check and tell me where I am going wrong. I still do not get the high and low values of yesterday.
whroeder1
16086
whroeder1  
      int X = iYesterday-itoday-1;
      ArrayResize(Trac, X);
      for(j=iYesterdayclose;j<=iYesterday;j++)
         Trac[X] = iStochastic(NULL,PERIOD_M15,32,3,3,MODE_EMA,1,MODE_MAIN,j);
  1. How many items (inclusively) are between [6 .. 8]? By your calculation: X = 8 - 6 - 1 = one. I don't think so I count three, 6, 7, 8.
  2. You resize the array to X values. They are indexed [0 .. X-1]. But you try to store something at X. ERR_ARRAY_INDEX_OUT_OF_RANGE. You would know this had you set #property strict.
  3. Where do you ever change the value of X?

To add comments, please log in or register