Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1078

 
Fast235:

this Vladimir K. unit, what more do you need?

it's the easiest one using ctrade, if i give you my code, it will pull the library i'm using
I asked for an example from the base, okay, forget it
 
Sprut112:
I asked for an example from the base, okay, forget it.

this is the basic, simplest example

 
What is the closing condition? Can you explain it in Russian words?
 
Vladimir Karputov:
What is the closing condition? Can you explain it in Russian words?
This block is from MACD Sample. Are there similar ones in kodobase ?
/+------------------------------------------------------------------+
//| Проверка условий закрытия длинной позиции                        |
//+------------------------------------------------------------------+
bool CSampleExpert::LongClosed(void)
  {
   bool res=false;
//--- нужно ли закрывать позицию?
   if(m_macd_current>0)
      if(m_macd_current<m_signal_current && m_macd_previous>m_signal_previous)
         if(m_macd_current>m_macd_close_level)
           {
            //--- закрытие позиции
            if(m_trade.PositionClose(Symbol()))
               printf("Long position by %s to be closed",Symbol());
            else
               printf("Error closing position by %s : '%s'",Symbol(),m_trade.ResultComment());
            res=true;
           }
//--- возвращаем результат
   return(res);
  }
 
Sprut112:
This is the block from the MACD Sample. Are there similar ones in kodobase ?

You can't say so straight away. Personally, I rarely write such things - I like clear behaviour: a signal to open SELL is a signal to close BUY.

 
Vladimir Karputov:

You can't say so straight away. Personally, I rarely write such things - I like clear behaviour: a signal to open SELL is a signal to close BUY.

Yes, I understand that and see it often. But it's not always like that, as you said. So there are no examples yet, ok
 
asked Rashid to ban his account for a month.
 
Sprut112:
Yes, I understand that and I often see it. But it is not always like that, as you say. So there are no examples yet, OK.

I've been following your question and can't figure out what you want....

if(условие на открытие) открываем позицию;

if(условие на закрытие) закрываем позицию;

There are a lot of examples of closing a position.

And the conditions are your own grief :)

 
Сергей Таболин:

I've been following your question and can't figure out what you want....

There are a lot of examples of closing a position.

And the conditions are your own grief :)

I know how to do it in mt4, and it works, but not here.
 
Sprut112:
In mt4 I know how, and everything works, here it doesn't

No one will be able to answer you until you have clearly formulated your question. So far you have not asked the question. There have been scraps of thought, nothing more.

Any program works according to an algorithm, and in order to write an algorithm, you must first clearly construct your thoughts. Try to describe what you want in more detail.