Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1229

 
Elena Baranova:

Dear Professionals, could you please advise if it is possible to get the values of RSI for a week timeframe in the code of advisor, but to calculate the values for the week, which does not start on Monday, but for example from Wednesday (that is the week from Wednesday to next Wednesday). As far as I know it cannot be done with iRSI?

So far I can only see a way to write the code myself to calculate. Is there a simpler solution or a ready-made solution?

If you create an indicator handle on the W1 timeframe, it means that the indicator will be calculated on W1 bars: one bar, one week.

You need to create an indicator handle on the D1 timeframe (daily timeframe).


In general, the meaning of the phrase "(that is, one week from Wednesday until next Wednesday)" is not clear. It makes no difference which day of the week starts - the indicator is calculated on bars.

 
Vladimir Karputov:

If you create an indicator handle on the W1 timeframe, it means that the indicator will be calculated on W1 bars: one bar, then one week.

You need to create an indicator handle on the D1 timeframe (daily timeframe).


In general, the meaning of the phrase "(that is, one week from Wednesday until next Wednesday)" is not clear. It doesn't matter which day starts the week - the indicator is calculated using bars.

I understand everything about the bars. But all the weekly bars start on Monday. Therefore, in order to get, for example, a week from Wednesday to Wednesday, I think I should write my own code based on daily bars.

I also do not fully understand the meaning of this calculation, but the customer asked.

 
Elena Baranova:

I understand all about the bars. But all the weekly bars start on Monday. So in order to get the week from Wednesday to Wednesday for example, I guess I have to write my own code based on the daily bars.

I do not fully understand the meaning of this calculation either, but my client has asked me to do it.

The Expert Advisor opens trades based on RSI values. I don't understand the whole point of this calculation, but the client requested it and the EA opens orders on Mondays only with opening of a new weekly bar.

 
Elena Baranova:

I understand all about the bars. But all the weekly bars start on Monday. So in order to get the week from Wednesday to Wednesday for example, I guess I have to write my own code based on the daily bars.

I also do not fully understand the meaning of such calculation, but the customer has asked me to do it.

I cannot understand the physical meaning. Therefore I am leaving.

 

Help solve the problem with displaying charts in MT5. The chart keeps updating and dragging to the left. And this is on all instruments.

Further on it keeps shifting to maximum history. In general it can't display the last week's information properly. the last day's candles constantly disappear, it blinks and moves to the left. How to fix it?

 
Александр:

Help solve the problem with the chart display in MT5. The chart keeps updating and dragging to the left. And this is on all instruments.

It keeps on shifting to the maximum history. In general, it cannot display information for the last week normally. The candlesticks of the last day constantly disappear, it blinks and moves to the left. How to fix it?

It's just a time machine :)

Maybe you have some scripts/advisors/indicators running - they can shift the chart.

 
Александр:

Help solve the problem with the chart display in MT5. The chart keeps updating and dragging to the left. And this is on all instruments.

It keeps on shifting to the maximum history. In general, it cannot display information for the last week normally. The candlesticks of the last day constantly disappear, it blinks and moves to the left. How to fix it?

Remove running indicators and EAs. Remove the cat from the keyboard. Clean any spilled coffee from the keyboard.

 
Vladimir Karputov:

Remove running indicators and advisers. Remove the cat from the keypad. Clean any spilt coffee from the keyboard.

Thanks for the advice. Problem solved, just had to choose a server with a high ping.

 

Please explain why the blue area is not shaded? And how to fix it?
Is it even possible to produce two histograms in one indicator?

#property indicator_chart_window                   
#property indicator_buffers   8                    
#property indicator_plots     8                    

#property indicator_color1    clrRed                
#property indicator_style1    STYLE_SOLID          
#property indicator_color2    clrRed               
#property indicator_style2    STYLE_SOLID          
#property indicator_color3    clrRed               
#property indicator_style3    STYLE_DOT            

#property indicator_color5    clrDodgerBlue        
#property indicator_style5    STYLE_SOLID          
#property indicator_color6    clrDodgerBlue        
#property indicator_style6    STYLE_SOLID          
#property indicator_color7    clrDodgerBlue        
#property indicator_style7    STYLE_DOT            

double
   Line_High_Up[], Line_High_Dn[], Hist_High_Up[], Hist_High_Dn[],
   Line_Low_Up[],  Line_Low_Dn[],  Hist_Low_Up[],  Hist_Low_Dn[];
   

void OnInit() 
   { 
   SetIndexBuffer     (0, Line_High_Up,      INDICATOR_DATA); 
   PlotIndexSetInteger(0, PLOT_DRAW_TYPE,    DRAW_LINE);      
   SetIndexBuffer     (1, Line_High_Dn,      INDICATOR_DATA); 
   PlotIndexSetInteger(1, PLOT_DRAW_TYPE,    DRAW_LINE);      
   SetIndexBuffer     (2, Hist_High_Up,      INDICATOR_DATA); 
   PlotIndexSetInteger(2, PLOT_DRAW_TYPE,    DRAW_HISTOGRAM2);
   SetIndexBuffer     (3, Hist_High_Dn,      INDICATOR_DATA);

   SetIndexBuffer     (4, Line_Low_Up,       INDICATOR_DATA);
   PlotIndexSetInteger(4, PLOT_DRAW_TYPE,    DRAW_LINE);     
   SetIndexBuffer     (5, Line_Low_Dn,       INDICATOR_DATA);
   PlotIndexSetInteger(5, PLOT_DRAW_TYPE,    DRAW_LINE);     
   SetIndexBuffer     (6, Hist_Low_Up,       INDICATOR_DATA);
   PlotIndexSetInteger(6, PLOT_DRAW_TYPE,    DRAW_HISTOGRAM2);
   SetIndexBuffer     (7, Hist_Low_Dn,       INDICATOR_DATA);
   }


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[]   )                   
   {  
   int i;
   for(i=prev_calculated; i<=rates_total-1; i++)      
      {
      Line_High_Dn[i] = Hist_High_Dn[i] = high[i];
      Line_High_Up[i] = Hist_High_Up[i] = Line_High_Dn[i] + 20*_Point;

      Line_Low_Up[i]  = Hist_Low_Up[i]  = low[i];
      Line_Low_Dn[i]  = Hist_Low_Dn[i]  = Line_Low_Up[i] - 20*_Point;
      }
   return(i-1);
   }           
 
User_mt5:

Please explain why the blue area is not shaded? And how to fix it?
Is it even possible to output two histograms in one indicator?

If the thickness for both histograms is set to '3'

//+------------------------------------------------------------------+
//|                                                            2.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   2
//--- plot Hist_High
#property indicator_label1  "Hist_High"
#property indicator_type1   DRAW_HISTOGRAM2
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Hist_Low
#property indicator_label2  "Hist_Low"
#property indicator_type2   DRAW_HISTOGRAM2
#property indicator_color2  clrBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- input parameters
input int      Input1=9;
//--- indicator buffers
double         Hist_HighBuffer1[];
double         Hist_HighBuffer2[];
double         Hist_LowBuffer1[];
double         Hist_LowBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Hist_HighBuffer1,INDICATOR_DATA);
   SetIndexBuffer(1,Hist_HighBuffer2,INDICATOR_DATA);
   SetIndexBuffer(2,Hist_LowBuffer1,INDICATOR_DATA);
   SetIndexBuffer(3,Hist_LowBuffer2,INDICATOR_DATA);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   int limit=prev_calculated-1;
   if(prev_calculated==0)
      limit=0;
   for(int i=limit; i<rates_total; i++)
     {
      Hist_HighBuffer1[i]=high[i]+20.0*Point();
      Hist_HighBuffer2[i]=high[i];
      Hist_LowBuffer1[i]=low[i];
      Hist_LowBuffer2[i]=low[i]-20.0*Point();
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+



Files:
2.mq5  3 kb
Reason: