Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 371

 

Greetings to all forum members.

Please help me get the indicator to work with a specific symbol, regardless of which chart it is set to.

I know that an external parameter is used to change the symbol

input string   Symb   ="GBPJPY";
I do not know what to do next

I am attaching the indicator

Files:
Fisher.mq4  3 kb
 

Can you please tell me how to reset the buffer when a new bar appears, but so that the previous data is not erased, but displayed on the chart. For some reason I can't reset the buffer to zero and whena new barappears, new data is overlaid on the old accumulated data. What am I wrong in my code? Thanks for the clarification.

void OnInit()
{
   IndicatorDigits(0);
   SetIndexBuffer(0,Buf_1);
   SetIndexBuffer(1,Buf_2);
   Bid1=Bid;
  
   
}
 
 
//+------------------------------------------------------------------+
//| 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[])
{
   datetime Вр=Time[0];   // Время текущего бара
   if(Вр>Время)           // Если новый бар
   {
      Время=Вр;           // Запомнить
      Buf_1[0]=0;         // и обнулить последний элемент буфера
      Buf_2[0]=0;
   }
   
      
   if(Bid > Bid1) 
   {
   V1 = iVolume(NULL, 0, 0);
   V2 = V1 + V2;
   Buf_1[0]= V2;
   }                             
   else 
   {
   V3 = iVolume(NULL, 0, 0);
   V4 = V3 + V4;
   Buf_2[0]= (V4*-1);
   }
   Bid1=Bid;
   
   
  return(rates_total);
}
 
Alekseu Fedotov:

That's the way it is


I have a question with the code, it turns out that the unclosed current candle has the Close time and until the candle closes, the indicator draws the price closure of the period, on which the indicator stands red in the screen area which should not be drawn because the hour candle is not closed , that's the compilation time and then after compilation comes the drawing of each closed candle, of course you can solve another way by finding the hour bars, but I wanted an easier way, I wrote earlier so
for(i=limit; i>0; i--)
{
yesterday_weekday = TimeHour(iTime(Symbol(),0,i+1))-TimeHour(iTime(Symbol(),0,i));
if(yesterday_weekday!=0)

any other solution to the problem? I would like to see it in the compile, but I wanted to have an easier solution.

 
MakarFX: Please help me to make the indicator work with a certain symbol, regardless of which chart it is set to.

It is necessary to write this parameter in calls Higest, Lowest - they are obsolete, better iHigest, iLowest and praised notorious Fisher immediately agreed to a draw (V.Vysotsky)

 
PokrovMT5:
I have a question with the code, it turns out that the unclosed current one-hour candle has the Close time and until the candle closes, the indicator draws the price closure of the period the indicator stands on, the red area on the screen is not supposed to be drawn because the one-hour candle is not closed , that's the moment of compilation and then after compilation comes the drawing of each closed candlestick, of course you can solve another way by finding the hour bars but I wanted an easier way, I wrote earlier so

Is there another solution to the problem? Thank you.

If I understand you correctly, you want to mark the hourly Close on the chart?

// (только для TF меньше часа) для всех свечей внутри часа поставить HourCloseBuff=цена закрытия часа

// предполагается что close индексирован как тайм-серия

for(int back=i+1;back<=limit && TimeHour(time[back]==TimeHour(time[i+1]);back++) {

  HourCloseBuff[back]=close[i+1];

}

 
STARIJ:

We should write this parameter into the Higest, Lowest calls - they are obsolete, better iHigest, iLowest and the praised notorious Fischer immediately agreed to a draw (V.Vysotsky)

#property  copyright "Copyright © 2005, Yura Prokofiev"
#property  link      "Yura.prokofiev@gmail.com"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Lime
#property  indicator_color3  Red
 
input string   Symb     ="GBPJPY";
extern int     period   =10;

double         ExtBuffer0[];
double         ExtBuffer1[];
double         ExtBuffer2[];


int init()
  {
   
   
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Lime);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+1);

   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);

   IndicatorShortName("Fisher");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);

   return(0);
  }


int start()
  {
   //int     period=10;
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current,old;
   double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
   double price;
   double MinL=0;
   double MaxH=0;  
   

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;


   for(int i=0; i<limit; i++)
    {  MaxH = High[iHighest(Symb,0,MODE_HIGH,period,i)];
       MinL = Low[iLowest(Symb,0,MODE_LOW,period,i)];
      price = (High[i]+Low[i])/2;
      Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;     
      Value=MathMin(MathMax(Value,-0.999),0.999); 
      ExtBuffer0[i]=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
      Value1=Value;
      Fish1=ExtBuffer0[i];
      
    }


   bool up=true;
   for(i=limit-2; i>=0; i--)
     {
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
           
      if (((current<0)&&(prev>0))||(current<0))   up= false;    
      if (((current>0)&&(prev<0))||(current>0))   up= true;
      
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
        
       else
         {
          ExtBuffer1[i]=current;
          ExtBuffer2[i]=0.0;
         }
     }

   return(0);
  }
I did, but that doesn't solve the issue for
price = (High[i]+Low[i])/2;
High and Low use the current symbol.
 
Maxim Kuznetsov:

If I understand you correctly, you want to mark the hourly Close on the chart?

// (только для TF меньше часа) для всех свечей внутри часа поставить HourCloseBuff=цена закрытия часа

// предполагается что close индексирован как тайм-серия

for(int back=i+1;back<=limit && TimeHour(time[back]==TimeHour(time[i+1]);back++) {

  HourCloseBuff[back]=close[i+1];

}

Maxim, good day! Thanks for the variant, mine is almost the same, it also works, butAlekseu Fedotov suggested it and I wrote that there is an idea of how to correct it?



for(i=limit; i>=0; i--)
     {
      T = iTime(NULL,0,i); 
      shift=iBarShift(NULL,60,T); 
      C=iClose(NULL,60,shift);
      CC[i]=C;
     }
 

Can you please tell me how to reset the buffer when a new bar appears, but so that the previous data is not erased and is displayed on the chart. For some reason I can't reset the buffer to zero and whena new barappears, new data is overlaid on the old accumulated data. What am I wrong in my code? Thanks for the clarification.

 datetime Вр=Time[0];   // Время текущего бара
   if(Вр>Время)           // Если новый бар
   {
      Время=Вр;           // Запомнить
      Buf_1[0]=0;         // и обнулить последний элемент буфера
      Buf_2[0]=0;
   }
   
      
   if(Bid > Bid1) 
   {
   V1 = iVolume(NULL, 0, 0);
   V2 = V1 + V2;
   Buf_1[0]= V2;
   }                             
   else 
   {
   V3 = iVolume(NULL, 0, 0);
   V4 = V3 + V4;
   Buf_2[0]= (V4*-1);
   }
   Bid1=Bid;
   
   
  return(rates_total);
 

Can no one help me?

 

Good day to you all! How do I switch to the right chart window?

I have many windows of different pairs open, each with an EA, a trade signal appears, but the currencies are up to the motherfucker, and I need to quickly activate the exact chart on which the signal came.

I know Symbol() command, but I don't know how to activate window with a specified currency pair. Maybe, who has faced with this task?

Reason: