Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1567

 
MakarFX:

I think it should be like this

If we create a new object every time in OnTick(), the time of the previous tick will not be saved anywhere.
The whole point of creating a global object is to store the time of the previous tick, comparing it with the time of the new tick we'll know whether there's a new bar or not...

 
MakarFX:
Why do we need this variable NB_M1 ?
Its only purpose is to store the time of the last processed tick for each symbol and timeframe:
protected:
   datetime          m_TOld;        // Время хранится 
   ENUM_TIMEFRAMES   m_TimeFrame;   //    для каждого таймфрейма
   string            m_Symbol;      //    каждого символа

 
Mikhail Tkachev:
class CIsNewBar

returns true/false , what time are we talking about?

 
MakarFX:

Try it, in the tester it's ok

No, that's not it. Now it opens and closes one contract at a time.

The idea is exactly to open an additional contract when trailing and the trailing stop is pulled up by Brake even.

It does it all obediently. But I see the disadvantage in that at stop loss=150 pips and take profit=500 pips it opens up to five contracts and also often pulls in stop loss.
However, I have noticed that buying five contracts leads to decrease of market entry price and therefore the risk/margin is much higher.
Because of this I want to make it trailing one contract, and it pulls up to take profit maximum two contracts, and trailing stop loss fits up to five times.
Because of that trailingorder (additional buy and additional sell) and trailing (trailing stop loss) are in my robot
 
Eugen8519:
No, that's not it, it opens and closes one contract at a time.

The idea is for the trailing contract to open and the trailing stop to be pulled up by Brake even.

It does it all obediently. But I see a disadvantage in that at stop loss=150 pips and take Profit=500 pips it opens up to five contracts and also often draws a stop loss.
However, I have noticed that buying five contracts leads to decrease of market entry price and therefore the risk/margin is much higher.
Because of this I want to change my robot to buy only one contract, and to take profit of up to two contracts, and trailing stop loss would increase five times.
Therefore, trailingorder (additional buy and additional sell) and trailing (trailing stop loss) were added to the robot

Here, correct "0" to "2".

   if(pos_total<=0 )
      {TrailingOrder();}
   Trailing();
 

how to make this trouble automatic? ORDER_FILLING_FOK ORDER_FILLING_IOC ORDER_FILLING_RETURN

maybe someone has a ready-made one ?

 
Aleksandr Egorov:

how to make this trouble automatic? ORDER_FILLING_FOK ORDER_FILLING_IOC ORDER_FILLING_RETURN

Maybe somebody has a ready-made example?

There is a ready example in the documentation. But first you need to define a fill policy for a symbol. Search for SYMBOL_FILLING_FOK

 
Aleksandr Egorov:

how to make this trouble automatic? ORDER_FILLING_FOK ORDER_FILLING_IOC ORDER_FILLING_RETURN

Maybe somebody has a ready-made?

Filling MqlTradeRequest directly yourself ?

There are too many pitfalls !

look at CTrade::FillingCheck() - how developers recommend to define filling

 
Good afternoon everyone. Has anyone come across a similar situation? In general, there is a scalable oscillator. I need to know programmatically, what are the current extreme values of the scale of the visible window of this oscillator. I hope I understand what I am saying.) I would be grateful for help!
 
AMarkov:
Good afternoon, all. Maybe someone has encountered a similar situation? In general, there is a scalable oscillator. I need to know programmatically what are the extreme values of the scale of the visible window of this oscillator at the moment. I hope I have made myself clear). I would be grateful for help!
bool  ChartGetInteger( 
   long    chart_id,        // идентификатор графика 
   int     prop_id,         // идентификатор свойства 
   int     sub_window,      // номер подокна 
   long&   long_var         // сюда примем значение свойства 
   );

with identifiers CHART_PRICE_MIN and CHART_PRICE_MAX

Reason: