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?
- Accurate Yesterday's High, Low, Open, Close Prices
- How to get high and low value from an custom indicator in code?
- How to get previous value of an indicator
gkintl66: Can anybody help me?
| Help you with what? You've stated no question, posed no problem, posted no code.
|
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: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);
| Help you with what? You've stated no question, posed no problem, posted no code.
|
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.
gkintl66: I included the code provided above There are 25 bars every day in M15 time frame. I trade in equity market.
- Don't post things inside of a quote block. MQL4 Forum editor problem - MQL4 forum
- 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.
- 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].
whroeder1:
- Don't post things inside of a quote block. MQL4 Forum editor problem - MQL4 forum
- 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.
- 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.
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];
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);
ArrayResize(Trac, X);
for(j=iYesterdayclose;j<=iYesterday;j++)
Trac[X] = iStochastic(NULL,PERIOD_M15,32,3,3,MODE_EMA,1,MODE_MAIN,j);
- 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.
- 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.
- Where do you ever change the value of X?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register