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

 
Artyom Trishkin:

I've honestly never used these SB resources. But what prevents you from looking in the SB where there, by what methods, the colours are set. What you have shown in the listing:

- are object names - CPanel, CEdit, CBmpButton and CWndClient classes.

And you need to find names of members of these classes where colours are stored and use which methods they can be initialized or changed.

And you'll probably have to initialize them first and then build the object itself.

The colours are defined in Defines, and then the objects are colored through ObjectSetInteger(). For now I'm also painting directly with this method. But I'd like to try it through OOP. As I see, if there isn't a separate public method to modify, there's no way to get through to the private member. I'm just not that well versed in inheritance and virtual methods, I'm still "swimming" and studying the subject. Ok, I'll try to ask the service-desk to make a public method for coloring, and if it's possible to do it in another way, maybe they'll tell me how.
 
LRA:
Click on the error message. The cursor will indicate the variable name. It needs to be declared
Thank you!
 
Kedrov:
Thank you!

You should not post decompiled code on this forum. I understand that you haven't posted code, just a picture. But it means that you are working with stolen software products. This is strongly discouraged here - this is... how shall I put it... a violation of community ethics. Here on the forum and resource lion's share of forum users are programmers - we write our own code or use public works of our colleagues. But you use and remake someone else's stolen code (maybe someone else's here too). In general, it is not a good idea to start your activities here.

 
Vasiliy Pushkaryov:
Colours are defined in Defines, then objects are colored using ObjectSetInteger() functions. At the moment I'm also painting directly with this method. But I'd like to try it through OOP. As I see, if there isn't a separate public method to modify, there's no way to get through to the private member. I'm just not that well versed in inheritance and virtual methods, I'm still "swimming" and studying the subject. Okay, I'll try to ask in service-desk to make a public method for coloring, and if it's possible in another way, maybe they will tell me how.

Temporarily, copy this class to your Include\your_folder and put in theclass member variables you need to store the colours and public methods to set and return them.

Plus - you will be able to do as you already need. Minus - when you update the SB in the original class, there may be refinements, and you do not have them and have to copy and paste the methods you need into the updated class again.

... Well it's strange that there is no possibility to change the colour quietly - without defines ...

 

Please help - how can I quickly get and information on the volume (number of lots total) of all open positions on all instruments? Please share the function.

 
Aleksey Vyazmikin:

Please help - how can I quickly get and information on the volume (number of lots total) of all open positions on all instruments? Please share the function.


Function GetAmountLotFromOpenPos().

This function returns the amount of lots of the open positions. More accurate selection of counted positions is specified by external parameters:

  • sy- Name of market instrument. If this parameter is set, the function will consider only positions of the specified symbol. The default value -"" means any market instrument.NULL means the current instrument.
  • op- Trade operation, position type. Valid values:OP_BUY,OP_SELL or-1. The default value-1 means any position.
  • mn- Position identifier, MagicNumber. Default value-1 means any identifier.

 
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает сумму лотов открытых позиций                        |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ( ""  - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - торговая операция          ( -1  - любая позиция)                  |
//|    mn - MagicNumber                ( -1  - любой магик)                    |
//+----------------------------------------------------------------------------+
double GetAmountLotFromOpenPos(string sy="", int op=-1, int mn=-1) {
  double l=0;
  int    i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              l+=OrderLots();
            }
          }
        }
      }
    }
  }
  return(l);
}
 
Vladimir Zubov:

Thank you.

 

Please advise the following question: Zig-zag by threshold(depth(in points, High(Low) are formed after passing n-points, depth=Depth*Point). There is a chain of points (ArrUp(ArrDn)) that shows addition drawing of the zigzag, i.e. the last point was ArrUp, then the depth is dropped down and the first point ArrDn is formed, after it a series of ArrDn points, as the price went down (addition drawing). We have to build the algorithm in such a way that there is an indentation of depth. Maybe a for loop, I can't figure it out.

//+------------------------------------------------------------------+
//|                                                       FastZZ.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Yurich"
#property link      "https://login.mql5.com/ru/users/Yurich"
//---
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Gold
#property indicator_color4 DodgerBlue
#property indicator_width3 3
#property indicator_width4 3

//--- input parameters
extern int  Depth=10;
//---
double zzH[],zzL[];
double depth;
int last,direction,pbars;
datetime lastbar;
double ArrUp[];
double ArrDn[];
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,zzH);
   SetIndexBuffer(1,zzL);
   SetIndexBuffer(2,ArrUp);
   SetIndexBuffer(3,ArrDn);
   SetIndexStyle(0,DRAW_ZIGZAG);
   SetIndexStyle(1,DRAW_ZIGZAG);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(2,159);
   SetIndexArrow(3,159);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   IndicatorDigits(Digits);
//----
   depth=Depth*Point;
   direction=1;
   last=0;
   pbars=0;
   lastbar=0;
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   int limit=Bars-IndicatorCounted()-1;
   if(lastbar!=Time[0])
     {
      lastbar=Time[0];
      last++;
     }
   if(MathAbs(Bars-pbars)>1) { last=Bars-1; limit=last;}
   pbars=Bars;
//---
   for(int i=limit; i>0; i--)
     {
      bool set=false;
      zzL[i]=0;
      zzH[i]=0;
      ArrUp[i]=EMPTY_VALUE;
      ArrDn[i]=EMPTY_VALUE;
      //---
      if(direction>0)
        {
         if(High[i]>zzH[last])
           {
            zzH[last]=0;
            zzH[i]=High[i];
            ArrUp[i]=High[i];
            if(Low[i]<High[last]-depth)
              {
               if(Open[i]<Close[i])
                 {
                  zzH[last]=High[last];
                  ArrUp[last]=High[last];
                 }
               else direction=-1;
               zzL[i]=Low[i];
               ArrDn[i]=Low[i];
              }
            last=i;
            set=true;
           }
         if(Low[i]<zzH[last]-depth && (!set || Open[i]>Close[i]))
           {
            zzL[i]=Low[i];
            ArrDn[i]=Low[i];
            if(High[i]>zzL[i]+depth && Open[i]<Close[i])
              {
               zzH[i]=High[i];
               ArrUp[i]=High[i];
              }
            else direction=-1;
            last=i;
           }
        }
      else //direction<0
        {
         if(Low[i]<zzL[last])
           {
            zzL[last]=0;
            zzL[i]=Low[i];
            ArrDn[i]=Low[i];
            if(High[i]>Low[last]+depth)
              {
               if(Open[i]>Close[i])
                 {
                  zzL[last]=Low[last];
                  ArrDn[last]=Low[last];
                 }
               else direction=1;
               zzH[i]=High[i];
               ArrUp[i]=High[i];
              }
            last=i;
            set=true;
           }
         if(High[i]>zzL[last]+depth && (!set || Open[i]<Close[i]))
           {
            zzH[i]=High[i];
            ArrUp[i]=High[i];
            if(Low[i]<zzH[i]-depth && Open[i]>Close[i])
              {
               zzL[i]=Low[i];
               ArrDn[i]=Low[i];
              }
            else direction=1;
            last=i;
           }
        }
     }
//----
   zzH[0]=0;
   zzL[0]=0;
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

Hi all.

Teach me how to stop the EA and start when a new candle appears.