Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1509

 
Aleksandr Slavskii #:

It's funny, but okay.

The easiest option is to add this code to OnTick().

thanks

 

Hello. The indicator finds a signal. Is it possible to write a code so that the indicator can put arrows on those bars, the high of which was not broken, where the first arrow will be the main signal, and the next arrows will be put if the high of the main signal (bar) was not broken? If it is possible, could you share the code

Bars

I would like it to look like this

 

Could you tell me how to make a line behind a rectangle not to be captured by the mouse?

Or at least how to know the name of this line before it is released.

Also, maybe someone knows why when hiding a rectangle with subsequent display, the highlighting of the line disappears.

And it happens once.

//+------------------------------------------------------------------+
int OnInit()
  {
   ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true);

   ObjectCreate(0, "_Rectangle", OBJ_RECTANGLE_LABEL, 0, 0, 0);
   ObjectSetInteger(0, "_Rectangle", OBJPROP_XDISTANCE, 150);
   ObjectSetInteger(0, "_Rectangle", OBJPROP_YDISTANCE, 50);
   ObjectSetInteger(0, "_Rectangle", OBJPROP_XSIZE, 200);
   ObjectSetInteger(0, "_Rectangle", OBJPROP_YSIZE, 200);
   ObjectSetInteger(0, "_Rectangle", OBJPROP_ZORDER, 1);

   ObjectCreate(0, "_Button", OBJ_BUTTON, 0, 0, 0);
   ObjectSetInteger(0, "_Button", OBJPROP_XDISTANCE, 200);
   ObjectSetInteger(0, "_Button", OBJPROP_YDISTANCE, 135);
   ObjectSetInteger(0, "_Button", OBJPROP_XSIZE, 100);
   ObjectSetInteger(0, "_Button", OBJPROP_YSIZE, 30);
   ObjectSetInteger(0, "_Button", OBJPROP_ZORDER, 2);

   ChartRedraw();
   EventSetMillisecondTimer(100);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0, "_");
   EventKillTimer();
  }
//+------------------------------------------------------------------+
void OnTimer()
  {
// выводим прямоугольник и кнопку на передний план
   ObjectSetInteger(0, "_Rectangle", OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);
   ObjectSetInteger(0, "_Button", OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);
   ObjectSetInteger(0, "_Rectangle", OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
   ObjectSetInteger(0, "_Button", OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
  }
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   if(id == CHARTEVENT_MOUSE_MOVE && sparam == "1")
     {
      int X = (int)lparam;
      int Y = (int)dparam;
      if(X >= 150 && X <= 150 + 200 && Y >= 50 && Y <= 50 + 200)// мыша в районе прямоугольника
        {
         //Print("Rectangle");
        }
     }
  }
//+------------------------------------------------------------------+
 

Good afternoon, can you tell me how to write in mql5 the code for closing the profit of each currency pair separately as a percentage of the balance, if there are several pairs working on the account simultaneously.

In the example below, the closing is tied to the total account balance, but it is necessary to close each pair separately independently of each other, for example, at +1% of the balance, even if the other pairs are in the minus.

if(m_account.Equity()>=m_account.Balance()*equity_percent_from_balances_profit)
for(int i=PositionsTotal()-1;i>=0;i--)
if(m_position.SelectByIndex(i))
{
m_trade.SetExpertMagicNumber(m_position.Magic());
m_trade.PositionClose(m_position.Ticket());
}


 
R3008 account balance, but it is necessary to close each pair separately independently of each other, for example, at +1% of the balance, even if the other pairs are in the minus. if(m_account.Equity()>=m_account.Balance()*equity_percent_from_balances_profit)
for(int i=PositionsTotal()-1;i>=0;i--)
if(m_position.SelectByIndex(i))
{
m_trade.SetExpertMagicNumber(m_position.Magic());
m_trade.PositionClose(m_position.Ticket());
}


The question is not correct.

Do you need to write the code into the multicurrency EA that trades or is it a separate EA that monitors the balance?

 

Does anyone know a good library for temporal filters? Dynamic filters for every day (news).

The second day I'm looking on the site, everything is wrong. The closest concept is in the article Cross-platform Expert Advisor: Temporary Filters. But there's too much to drag in with it.

 
R3008 account balance, but it is necessary to close each pair separately independently of each other, for example, at +1% of the balance, even if the other pairs are in the minus. if(m_account.Equity()>=m_account.Balance()*equity_percent_from_balances_profit)
for(int i=PositionsTotal()-1;i>=0;i--)
if(m_position.SelectByIndex(i))
{
m_trade.SetExpertMagicNumber(m_position.Magic());
m_trade.PositionClose(m_position.Ticket());
}


You calculate the "profit on open positions on symbol and magic", for example in total now $10 on eurobucks. balance 1100.

If the percentage > 1, close all positions on symbol.

 
Denis Karavaev #:

You calculate "profit on open positions on symbol and majic", for example in total now 10$ on eurobucks. balance 1100.

If the percentage > 1, close all positions on the symbol.

From what deposit size 1%

 
Hello!
Is it possible to colour a panel created with <Controls\Dialog.mgh>?
Could you share an example code how it can be done? (If it is possible of course).
 
Alexey Viktorov #:

From what size of deposit 1%

Balance = 1100 = Deposit

1% of deposit 1100 = 1100\100*1 = $11.

which means that in the example above, the closing condition has not yet been fulfilled.

Reason: