RSI Trend lines drawing problem ! - page 2

To add comments, please log in or register
Marco vd Heijden
Moderator
8167
Marco vd Heijden  
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_LINE
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_LINE
  • www.mql5.com
//|                                                    DRAW_LINE.mq5 | //|                        Copyright 2011, MetaQuotes Software Corp. | //|                                              https://www.mql5.com | //| Custom indicator initialization function                         |...
siemsons
97
siemsons  
pls keep me posted :)
Stanislav Ivanov
1947
Stanislav Ivanov  
Yes, I know how to build indicators and objects, this is not the problem. I think you may have misunderstood me in the beginning- I posted my code and the result of the code - the lines drawn were wrong for some reason, I posted a pic. I simply don’t know why it works this way
Marco vd Heijden
Moderator
8167
Marco vd Heijden  

It depends on how you draw these lines / objects.

Indicators count up from zero.

In a loop you could also count down.

This has its effect on the objects because you swap the beginning and the end points of these objects, so you have to know up front increments or decrements, and start point / end points of these objects.

You only have to swap values until it plots correctly.

Ernst Van Der Merwe
5752
Ernst Van Der Merwe  
Stanislav Ivanov:
Yes, I know how to build indicators and objects, this is not the problem. I think you may have misunderstood me in the beginning- I posted my code and the result of the code - the lines drawn were wrong for some reason, I posted a pic. I simply don’t know why it works this way

Populate the RSI buffer first, then use a different loop to analyse it.

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if(rates_total<RSIPeriod+RSIDirectionPeriod)
      return(0);
   datetime time1,time2;
   double point1,point2;
//---
   int limit=!prev_calculated?rates_total-RSIPeriod-1:rates_total-prev_calculated;
//---
   for(int i=limit; i>=0; i--)
      ExtRsiBuffer[i]=iRSI(NULL,0,RSIPeriod,PRICE_TYPICAL,i);
//---
   limit=!prev_calculated?rates_total-RSIPeriod-RSIDirectionPeriod-2:rates_total-prev_calculated+1;
//---
   for(int i=limit; i>0; i--)
     { 
      double highest=ExtRsiBuffer[ArrayMaximum(ExtRsiBuffer,RSIDirectionPeriod,i)];
      double lowest=ExtRsiBuffer[ArrayMinimum(ExtRsiBuffer,RSIDirectionPeriod,i)];
      //----------------------------------------------------------------------------------------------------+
Stanislav Ivanov
1947
Stanislav Ivanov  
Ernst Van Der Merwe:

Populate the RSI buffer first, then use a different loop to analyse it.

Thanks
siemsons
97
siemsons  
How is your project going ?
Stanislav Ivanov
1947
Stanislav Ivanov  
siemsons:
How is your project going ?

 I had problems with the array indices, however i have found another way to calculate what i need, its just i didnt have the time to set it up the last few day, when i do and if eventually works as desired, ill post an update

12
To add comments, please log in or register