Wrong numerical result?

To add comments, please log in or register
Alex
37
Alex  

Dear All


I tried to calculate the pivot of last 3 years' range, ie the highest high, the lowest low of the last 3 years, and the closing price of the last year, then sum these 3 together and divided by 3.


I got the code working, but the numerical result is wrong. Using euro as example, it should be 1.1479 for 2018 (based on past 3 years' range), but the indicator shows 1.1630. 

Please can someone take a look and see why the result is wrong? 

Thanks,


 if(TimeDayOfYear(Time[i])<=10 && TimeDayOfYear(Time[i+1])>=355
   {
          PastHigh[i] = iHigh(NULL, PERIOD_MN1, iHighest( NULL, PERIOD_MN1, MODE_HIGH, 36, 0) ); // Past 3-yr high
          PastLow[i] = iLow(NULL, PERIOD_MN1, iLowest( NULL, PERIOD_MN1, MODE_LOW, 36, 0) );     // Past 3-yr low
          last_year_close=Close[i+1];
                    
          P=(PastHigh[i]+PastLow[i]+last_year_close)/3;     
Alex
37
Alex  

OK, I've done some more testing, turned out that the PastHigh[i] is wrong, it returns the highest high calculating from the current month, rather than only months in past year. I think PastLow would have the same problem.

How do I get round this? Please help?

William Roeder
20208
William Roeder  
  1. Why did you post your MT4 question in the Root / MT5 Indicators 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. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

Alex
37
Alex  

Sorry, I didn't know anything about root directory etc... I came in via the front page of Forum and got to the 'Technical indicator' .

Just an update, I got the problem sorted. I changed '0' to 'Month()', then it would calculated from the December candle of last year. 

Sorry for any wrong posting. If necessary, you can delete the thread.

To add comments, please log in or register