Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1563

 
statist247 #:
double max_balance=0;
string name="MaxBalance";

int OnInit()
   {
   if(MQLInfoInteger(MQL_TESTER)==0 && GlobalVariableCheck(name))
      {
      max_balance=GlobalVariableGet(name);
      }
   return(INIT_SUCCEEDED);
   }
   
void OnTick()
   {
   if(условие)
      {
      if(AccountInfoDouble(ACCOUNT_BALANCE)-max_balance>0)
         {
         max_balance=AccountInfoDouble(ACCOUNT_BALANCE);
         if(MQLInfoInteger(MQL_TESTER)==0)
            {
            GlobalVariableSet(name,max_balance);
            }
         }
      }
   ...
   }
 
Aleksei Stepanenko #:

Why GV if a variable at the global level is enough? Or even just static

 
statist247 #:
...variable is saved and it can be compared with the current balance...
FileWrite
Documentation on MQL5: File Functions
Documentation on MQL5: File Functions
  • www.mql5.com
This is a group of functions for working with files. For security reasons, work with files is strictly controlled in the MQL5 language. Files with...
 
Alexey Viktorov #:

Why GV if a variable at the global level is enough? Or even just static

This is for real work, after reinitialisation we will lose the maximum balance that was achieved before. Lights out, all that)

 
statist247 #:
 ...need to throw the current balance into some variable before each check of the conditions for entering a position...

If I were to do it for myself for real trading, then instead of saving the balance, I would check the history (HistoryDealsTotal()) and calculate the previous balance.

 

Good day everyone!

I have never thought about this topic, but today something prompted me. The question is actually this: I understand how bars and candlesticks are drawn in MT5 terminal. But how a broken line is drawn, I don't understand at all. Maybe someone knows the formula for calculating the inflection point (actually the price) of this line on each bar?

Regards, Vladimir.

 
MrBrooklin #:

Good day, everyone!

I have never thought about this topic, but today something prompted me. The question is actually this: I understand how bars and candlesticks are drawn in MT5 terminal. But I don't understand how a broken line is drawn. Maybe someone knows the formula for calculating the inflection point (actually the price) of this line on each bar?

Regards, Vladimir.

At the closing price of the candle\bar.

 
Alexey Viktorov #:

At the closing prices of the candle bar.

Hi, Alexey, a big THANK YOU.

Regards, Vladimir.

 
Aleksei Stepanenko #:
Thanks for the help, I googled how to use GV but didn't fully understand how it worked, now it's all great
 
I have a dynamic Magic that is set with m_trade.SetExpertMagicNumber() . I need to enter this Magic in the position comment. How can you find out what Magic is set in environment?