Questions from Beginners MQL5 MT5 MetaTrader 5 - page 831

 
tsd Tsepkov:

I mean the first name, it says you have to change the first name to the real name, but it doesn't work

Yes, if your status is "Seller" you cannot edit your details:

Try writing a request to servicedesk with an explanation.

 
Vladimir Karputov:

Yes, if your status is "Seller" you cannot edit your details:

Try writing an application to servicedesk with an explanation.

That's the thing, no, you have to edit to become one. It's a vicious circle...

Yourapplication for registration as a Seller has been rejected by the moderator.

Please correct the data you provided.

 
tsd Tsepkov:

***

Please correct the data you have provided.

Could this be the reason? The pictures are crooked or dark or not as required...

 
tsd Tsepkov:

That's the thing, no, you have to edit to become one. It's a vicious circle...

Yourapplication to register as a Seller has been rejected by the moderator.

Please correct the data you provided.

Well, then write to servicedesk about the problem. It's more productive than banging on the rail on the forum ;)
 
VHS:

Please advise how to use void Ignore(long value) { m_ignore=value; } method of standard CExpertSignal class in custom Trailing class when programming in MQL5? How can I access it?

I have a custom signals class that gives me methods to open and close positions. But in Trailing I wanted to maintain position by another method. If to write separately custom classes MySignal and MyTrailing, a position is closed by the condition, which triggered first. If Trailing condition was triggered earlier, everything is fine. But sometimes a new (reversal) signal comes from MySignal and the position is reversed, and I need it to be accompanied by Trailing after opening, not closing and not opening a new one. I've looked at the base classes and there is a feeling that m_ignore from the base signals class is responsible for this. If it's assigned value 1 in the appropriate filter, it seems to work as it should. I have added filter0.Ignore(0) to the Expert Advisor class in OnInit. But I'm new to OOP and don't understand how to change this value in MyTrailing class, which is not inherited from CExpertSignal class, but is its "cousin" (let's say filter0.Ignore(1) ). Please advise how to do this.

Actually, more general question: how to pass information between two classes which are not descendants? How to transfer information from trailing class to signal class? Probably, you can create a global variable and communicate through it. But this looks completely perverted with respect to logic of protected members in OOP.


Please help! I already tried to move away from build Ignore (which, of course, is not good in itself, people tried to include it in the base code) and still can not connect. I'm trying to invent for the third day (I haven't got a manual yet).

I've even tweaked class codes: I've implemented protected boolean member (m_permition) in MySignal class and created a Set method for it; I've tucked return(0) into long division and shot division if !m_permition. In MyTrailing also created a protected boolean member m_signal_permition, created Get and Set methods to it, taught CheckTrailing to control it if(position==NULL) {m_signal_permition = true; return(false);} else m_signal_permition = false;

I don't understand only one thing, where and how I should bring them together. I tried simply referring to them in OnTick, but it fails.

I read Vladimir's article "How to teach...". The idea of creating an instance of another signal in custom signal and communicating through it seems to be clear, but somewhere in my system it doesn't fit together completely: classes of signal and trailing are not inherited from each other.

Help, people of goodwill, in any way you can.

 

Hello colleagues. In addition to the protection price, MT5 quotes contain some data, such as historical spread and slippage (which is the same everywhere by default and is 10 five-digit points).

By making such a request after opening a position:

Print("Expert name: ",__FILE__,", Открыта поза Sell с магиком №: ",IntegerToString(m_trade.RequestMagic()),", Cпред ",SymbolInfoInteger(_Symbol,SYMBOL_SPREAD),
", Deviation ",IntegerToString(m_trade.RequestDeviation()));

We get this answer:

Do I understand correctly that the MT5 tester counts both spread and slippage together, exactly as in MT4 I would manually set the spread to 13 pips, for the specific example in the screenshot.

 

Hello Can someone please help me with this, how can i link an mt5 EA to a specific account number?

 
denis basuk:

Hi, can someone please help me with this, how can i link an mt5 Expert Advisor to a specific account number?

I need to check the account number. This should be done in OnInit() and OnTick(). Example:

 

Hello, I am trying to transfer indicators from MT4 to MT5. I have a simple indicator that shows the time until the next bar. This indicator uses OnTimer. I update it in OnTimer using void refreshClock() function. Is it correct to use this construction for other indicators that require the use of OnTimer? Or you can optimize the process of addressing to OnTimer?

#property description "Time"
#property indicator_chart_window
#property indicator_plots   0

                                    
                                                                                             
input int Offset_Minutes = 60;                                                                                                         
input int Font__Size = 10;                                   
input color  Font_Color = clrWhite;                         
input color  Font_No_Bar_Color = clrRed;                        
input ENUM_BASE_CORNER  Corner = CORNER_RIGHT_UPPER;        
input int Time_X = 140;                                          
input int Time_Y = 0;                                            


#define  Clock_Name "Тimer"
int selectTime;
int diff;
int offsetHour;

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

int  OnInit()
{   
   EventSetMillisecondTimer(1000); 
   return(0); 
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

void OnDeinit(const int reason) 
{ 
   if(reason==REASON_REMOVE      || 
      reason==REASON_CHARTCHANGE || 
      reason==REASON_RECOMPILE   || 
      reason==REASON_CHARTCLOSE  || 
      reason==REASON_CLOSE       || 
      reason==REASON_PARAMETERS)    
   { 
     ObjectDelete(0, "Тimer");
     EventKillTimer(); 
   }
  ChartRedraw();
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

void OnTimer( )                 
{ 
   refreshClock();  
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

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[])
{
   refreshClock();
   return(rates_total);
}
void refreshClock()
{
   static bool inRefresh = false;
           if (inRefresh) return;
               inRefresh = true;
                              ShowClock(); ChartRedraw();
               inRefresh=false;
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

void ShowClock()
{
   int periodMinutes     = periodToMinutes(Period());
   int currentTime       = (int)TimeCurrent();
   int localTime         = (int)TimeLocal();
   int barTime           = (int)iTime();
   
   diff = (int)MathMax(round((currentTime-localTime)/60.0)*60,-24*3600);
   offsetHour = (int)-Offset_Minutes*60; // сдвиг в минутах
   
   
   int currentTimeReal   = localTime+offsetHour;
   int sel_localTime     = localTime+diff;
   selectTime = sel_localTime;
   
     
      color  theColor;
      string time = getTime(barTime+periodMinutes*60-selectTime,theColor);
      int times = barTime+periodMinutes*60-selectTime;
      if(times < -60 || TerminalInfoInteger(TERMINAL_CONNECTED) == false || 
      currentTimeReal-currentTime > 60 || currentTime-currentTimeReal > 60)
      time = "Time Off";
             
   if(ObjectFind(0, Clock_Name) < 0)   
   ObjectCreate(0, Clock_Name, OBJ_LABEL, 0, 0, 0);
   ObjectSetString(0, Clock_Name, OBJPROP_TEXT, "Time: " + time);
   ObjectSetString(0, Clock_Name, OBJPROP_FONT, "Verdana");
   ObjectSetInteger(0, Clock_Name, OBJPROP_FONTSIZE, Font__Size);
   ObjectSetInteger(0, Clock_Name, OBJPROP_COLOR, theColor);
        ObjectSetInteger(0, Clock_Name, OBJPROP_CORNER, Corner);
        ObjectSetInteger(0, Clock_Name, OBJPROP_XDISTANCE, Time_X);
   ObjectSetInteger(0, Clock_Name, OBJPROP_YDISTANCE, Time_Y);
      
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

string getTime(int times, color& theColor)
{
   string stime = "";
   int    seconds;
   int    minutes;
   int    hours;
   int currentTime       = (int)TimeCurrent();
   int localTime         = (int)TimeLocal();
   
   
   offsetHour = (int)-Offset_Minutes*60;
   
   int currentTimeReal   = localTime+offsetHour;
  
   if (times < 0 || TerminalInfoInteger(TERMINAL_CONNECTED) == false || 
   currentTimeReal-currentTime > 60 || currentTime-currentTimeReal > 60) {
         theColor = Font_No_Bar_Color; times = (int)fabs(times); }
   else  theColor = Font_Color;
   
   seconds = (times%60);
   hours   = (times-times%3600)/3600;
   minutes = (times-seconds)/60-hours*60;

   if (hours>0)
   if (minutes < 10)
         stime = stime+(string)hours+":0";
   else  stime = stime+(string)hours+":";
         stime = stime+(string)minutes;
   if (seconds < 10)
         stime = stime+":0"+(string)seconds;
   else  stime = stime+":" +(string)seconds;
   return(stime);
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+
  
datetime iTime(ENUM_TIMEFRAMES forPeriod=PERIOD_CURRENT)
{
   datetime times[]; if (CopyTime(Symbol(),forPeriod,0,1,times)<=0) return(TimeLocal());
   return(times[0]);
}

//+------------------------------------------------------------------+  
  
//+------------------------------------------------------------------+

int periodToMinutes(int period)
{
   int i;
   static int _per[]={1,2,3,4,5,6,10,12,15,20,30,0x4001,0x4002,0x4003,0x4004,0x4006,0x4008,0x400c,0x4018,0x8001,0xc001};
   static int _min[]={1,2,3,4,5,6,10,12,15,20,30,60,120,180,240,360,480,720,1440,10080,43200};

   if (period==PERIOD_CURRENT)
       period = Period();  
            for(i=0;i<20;i++) if(period==_per[i]) break;
   return(_min[i]);  
}
 
VHS:

Can someone please help! Already tried to move away from the built-in Ignore (which, of course, is not good in itself, people tried to include it in the base code) and still can not connect. I'm trying to invent for the third day (I haven't got a manual yet).

I've even tweaked class codes: I've implemented protected boolean member (m_permition) in MySignal class and created a Set method for it; I've tucked return(0) into long division and shot division if !m_permition. In MyTrailing also created a protected boolean member m_signal_permition, created Get and Set methods to it, taught CheckTrailing to control it if(position==NULL) {m_signal_permition = true; return(false);} else m_signal_permition = false;

I don't understand only one thing, where and how I should bring them together. I tried simply referring to them in OnTick, it fails.

I read Vladimir's article "How to teach...". The idea of creating an instance of another signal in custom signal and communicating through it seems to be clear, but somewhere in my system it doesn't fit together completely: classes of signal and trailing are not inherited from each other.

Help me, people of goodwill, in any way you can.

I've made progress in a week! Found Signal method in CExpert class. Inserted code into OnTick.

CExpertSignal *my_signal = ExtExpert.Signal(); my_signal.Ignore(0);

Now, if I change "1" in brackets manually, the Ingnore method works - the Expert Advisor performs no trades by the signal.

It only remains to understand how to get information about the trailing object in OnTick. Unfortunately, there is no method ExtExpert.Trailing() to get reference to trailing object and, hence, the compiler doesn't understand which object I want to apply my implemented in trailing method GetPermition to. Maybe someone can tell me what to do?

Reason: