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

 
Taras Slobodyanik:

my code writes a long-ChartID to a temporary Global Variable.

Visually, if you press F3, it shows zero (or another different value).
This happens because the terminal thinks it's a double value and tries to show it, but we gave it long, which is a completely different number format.

If this value is read back as a normal double, it will be a mess.
If it's read by my code, it will be long again (the same one we saved).
If you manually click on this variable in the terminal window, it will be reset because the terminal will detect the swap.

How can I use the result in CHART_BRING_TO_TOP ?
 
Artyom Trishkin:

Remove time initialisation in OnInit()

Thank you.

Could you please tell me where the error is. When I call regular fractal, the arrow is put by condition, where it should be, when I call iFreeNumFractals, the condition is fulfilled, there should be an arrow, but there isn't. iFreeNumFractals lines are commented out, settings are set as for regular fractal. Ideally, the picture should be the same if we comment out the lines with regular fractal and uncomment iFreeNumFractals, but...

#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot UP
#property indicator_label1  "UP"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrLawnGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot DN
#property indicator_label2  "DN"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrDeepPink
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1


//--- indicator buffers
double         BufferUP[];
double         BufferDN[];

int dist=3;
string nameInd;
datetime timf=0;
int numf;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferUP);
   SetIndexBuffer(1,BufferDN);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   SetIndexArrow(0,233);
   SetIndexArrow(1,234);
  
   
//---
//---
   
   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[])
  {
  
//---
   if(rates_total<2) return(0);
     {
      int limit=rates_total-prev_calculated;
      if(limit>1) 
        {
         limit=rates_total-2;
         ArrayInitialize(BufferUP,EMPTY_VALUE);
         ArrayInitialize(BufferDN,EMPTY_VALUE);
        }
      for(int i=limit; i>=0; i--) 
        {
         
         if(fub(i))
           {
            BufferUP[i]=low[i]-dist*Point;
           }

         Comment("");
        }
      //--- return value of prev_calculated for next call

     }
   return(rates_total);
  }
//+
bool fub(int ib)//
  {
   bool bingob=false,flag_verh_f=0;
   int start_bar=0,numbarfrup=0,kfr_all=0;
   double high_old=0,prfra=0,f_up=0,f_dn=0,f=0;

     {
      for(int i_i=ib+3; i_i<Bars-2; i_i++)
        {
         if(high_old<High[i_i]) high_old=High[i_i];

        f_up=iFractals(Symbol(),0,MODE_UPPER,i_i);
        //f_up=NormalizeDouble(iCustom(Symbol(),0,"iFreeNumFractals",1,2,2,2,2,0,i_i),Digits);
         f_dn=iFractals(Symbol(),0,MODE_LOWER,i_i);
         //f_dn=NormalizeDouble(iCustom(Symbol(),0,"iFreeNumFractals",1,2,2,2,2,1,i_i),Digits);
         if(f_up>0 && f_up>iMA(NULL,0,33,0,MODE_SMMA,PRICE_CLOSE,i_i)+10*Point)//Если фрактал найден выше МА+10 pips
           {
            numbarfrup=i_i;
           }
         if(f_dn>0 && f_dn<iMA(NULL,0,33,0,MODE_SMMA,PRICE_CLOSE,i_i))
           {
            start_bar=numbarfrup;break;
           }
        }
      for(int i_i=start_bar; i_i<Bars-2; i_i++)
        {
         f=iFractals(Symbol(),0,MODE_UPPER,i_i);
         //f=NormalizeDouble(iCustom(Symbol(),0,"iFreeNumFractals",1,2,2,2,2,0,i_i),Digits);
         if(f>0)kfr_all++;
         if(f>0 && Low[ib]<f+1*_Point && Open[ib]>f //Сравнение фрактала с текущ баром
            &&
            high_old-f>=100*Point//от максимума до фрактала 100 пп
            )
           {
            bingob=true;
            prfra=f;
            timf=Time[i_i];
            break;
           }
         if(kfr_all==3)break;
        }
     }
// numfb=iBarShift(NULL,PERIOD_CURRENT,timf,true);
   if(bingob)
     {flag_verh_f=true;}
   if(bingob==false)
      flag_verh_f=false;

   return(flag_verh_f);

  }
//



 
inter78:
How do I use the result in CHART_BRING_TO_TOP ?

just like we used CHART_BRING_TO_TOP before

 
Hi guys, I have in the market three buy orders at one price the price goes up 10 pips and we have +10 pips for each order I want to lock three sell orders, now how to make these orders are no longer checked in mkl4
 
Ghabo:

Thank you.

Can you tell me where the error is. Situation is the following, when I call usual fractal, the arrow is put by condition, where it should be, when I call iFreeNumFractals, the condition is fulfilled, there should be an arrow, but it is not. iFreeNumFractals lines are commented out, settings are set as for usual fractal. In theory, the picture should be the same if I comment out the lines with the usual fractal and comment out iFreeNumFractals, but...




Are the iFreeNumFractals indicators with settings like the standard and standard Fractals on the chart?

If so, are their signals the same?

 
Aleksandr Egorov:
Hello guys, i have in the market three buy orders at one price, price goes up 10 pips, each order has +10 pips i want to lock three sell orders, now how to make these orders are not checked in mcl4 anymore

If you want to be understood - what you want, use punctuation marks in your text. Otherwise, all in one pile - go figure out what you mean...

 
Taras Slobodyanik:

just as CHART_BRING_TO_TOP was used before

Since I used it, nothing works. It probably won't be too hard for you to do the same thing, only as an indicator and bring it up to CHART_BRING_TO_TOP.
 
Artyom Trishkin:

If you want to be understood - what you want, use punctuation marks in your text. Otherwise you've lumped everything into one pile - go figure out what you mean...

We have three buy orders in the market at one price, the price goes up by 10 pips, we have +10 pips for each order, I want to lock three sell orders, now how to make sure that these orders are no longer checked in mcl4

 

Forum on trading, automated trading systems & strategy testing

Any questions for newbies on MQL4, help and discussion on algorithms and codes

Taras Slobodyanik, 2018.10.07 22:12

GlobalVariableCheck()- checks if this variable already exists, if not, then
GlobalVariableTemp()- creates temporary variable, which will be deleted by itself at next startup.

This point is clear, question why if there is no GP created only temporary and not permanent throughGlobalVariableSet?

 
Artyom Trishkin:

Are the iFreeNumFractals indicators with settings like the standard and standard Fractals on the chart?

If there are, do their signals match?

The fractals match completely.

The arrows on the standard fractals on the screenshot

iFreeNumFractals puts the first and the last one, the middle three are absent.

aqz