Questions from Beginners MQL5 MT5 MetaTrader 5 - page 906

 

Thank you.

Everything works.

I tweaked it a bit though)

Changed it and it works.

if(!RefreshRates())
      return;
   if(MA1_buf[1]>Close_buf[1] && MA1_buf[0]<Close_buf[0]) //если значение индикатора были выше цены закрытия и стали ниже
     {
      if(m_Position.Select(Symbol())) //если уже существует позиция по этому символу
        {
         return;
           }
        
      else
         m_Trade.Buy(1,Symbol()); //если дошли сюда, значит позиции нет, открываем ее
     }
     if(m_Position.Select(Symbol())) //если уже существует позиция по этому символу
        {
        if(m_Position.PositionType()==POSITION_TYPE_BUY && (m_symbol.Bid()-m_Position.PriceOpen())/m_Position.PriceOpen()>=0.2)
           {
            m_Trade.PositionClose(Symbol());   //и тип этой позиции Buy, то закрываем ее            
           }
         return;
         }
     
 
ISL:

Thank you.

Everything works.

I tweaked it a bit though)

Changed and it works.

I recommend to use code styler in the editor - the code will look neat and easy to read.

 
Hello guys all because the thread for beginners dropped in here as myself a beginner so the problem is how to calculate profits and losses together on six pairs of hedging account mt5 or show me where it has already been implemented
 
TYRBO:
i got here because i am a beginner and i know how to calculate profit and loss on six pairs in hedge mt5 account or show me may be it has been done already

Example:

"....Often it is necessary to calculate a profit for a position which has been opened by an EA.In most cases, the EA works only with the symbol on the chart, and the EA always has its own unique identifier - magic.

In this case, the problem is solved as follows: You need to bypass all positions (only positions forthe symbol of the EA and only with the ID of the EA are taken into account). The bypassing of all positions is implemented in functionCalculateAllProfit: . "

 
Artyom Trishkin: All that's left to do is think about it.

Thank you, it worked.

 
Vladimir Karputov:

Example:

"....Often it is necessary to calculate a profit for a position which has been opened by an EA.In most cases, the EA works only with the symbol on the chart, and the EA always has its own unique identifier - magic.

In this case, the problem is solved as follows: You need to bypass all positions (only positions forthe symbol of the EA and only with the ID of the EA are taken into account). The bypassing of all positions is implemented in functionCalculateAllProfit: . "

thanks a lot

 

Good afternoon.

Once again, I'm asking for help from the community.

I am implementing a strategy.

There is a signal coming from the indicator, which is based on calculations from n pairs(EURUSD,GBPUSD,...) and even from created currency pairs, which were not in the terminal.

What an Expert Advisor does:

-I divide the deposit equally between n pairs, we have 5 pairs. At 20% of the deposit.

-Further, when I receive a signal on one of the pairs, I close a part of the remaining 4 by the given percentage and enter the pair, from which the signal came from the indicator.

Thus, I trade several pairs in one EA.

Can I work in such a way in one EA or there is no such possibility?

 
ISL:

Good afternoon.

Once again, I'm asking for help from the community.

I am implementing a strategy.

There is a signal coming from the indicator, which is based on calculations from n pairs(EURUSD,GBPUSD,...) and even from created currency pairs, which were not in the terminal.

What an Expert Advisor does:

-I divide the deposit equally between n pairs, we have 5 of them. At 20% of the deposit.

-Further, when I receive a signal on one of the pairs, I close a part of the remaining 4 by the given percentage and enter the pair, from which the signal came from the indicator.

Thus, I trade several pairs in one EA.

Can I work in such a way in one EA or it is not possible?

Of course you can. Moreover, you can thoroughly test multicurrency Expert Advisors in MetaTrader 5.

 
Vladimir Karputov:

Of course it is possible. Especially in MetaTrader 5 you can fully test multicurrency EAs.

I've already started reading, it's a bit slow(((.

Can you give me a direction?)

 
ISL:

Already started reading, it's a bit slow(((.

Can you give me a direction?)

If a question is asked, then I'll answer it. I'm not a telepath.

Reason: