Features of the mql5 language, subtleties and tricks - page 17

 
Combinator:
Why do you need it if you can not see it anyway?

You don't have to set these parameters if you don't want to display the indicator.

And compatibility with the old code will not be broken. During testing, the indicator is always displayed.

 
Slawa:

Because you cannot set the display properties (the drawing part) through the indicator handle (through the calculation part). A bug is when something is written in one way, but works in another way.

A different approach is needed here. Access to the indicator by short name, as in the ChartIndicatorXXX function group. Something like ChartIndicatorSetInteger(chart_id,sub_window,indicator_name,PROP_COLOR,mod,value)

We already thought about it, but have not got around to it yet.

If it is intended for indicators set programmatically, wouldn't it be better to replace the highlighted with the indicator handle?
 

Forum on trading, automated trading systems and trading strategies testing

Peculiarities of mql5 language, tips and tricks

fxsaber, 2017.02.25 16:02

  static bool HistoryDealSelect( MqlTradeResult &Result )
  {
    if ((Result.deal == 0) && (Result.order != 0))
    {
      if (::HistorySelectByPosition(::HistoryOrderGetInteger(Result.order, ORDER_POSITION_ID)))
        for (int i = ::HistoryDealsTotal() - 1; i >= 0; i--)
        {
          const ulong DealTicket = ::HistoryDealGetTicket(i);

          if (Result.order == ::HistoryDealGetInteger(DealTicket, DEAL_ORDER))
          {
            Result.deal = DealTicket;

            break;
          }
        }
    }

    return(::HistoryDealSelect(Result.deal));
  }
  // Учтены MT5-нюансы: Result.deal == 0
  static bool OrderSendSync( const MqlTradeRequest &Request, MqlTradeResult &Result )
Synchronicity is no longer relevant. Only the piece responsible for Result.deal correction is highlighted.
 
fxsaber:
Synchronization is no longer relevant. I only highlighted the piece responsible for the Result.deal correction.
what is the "Result.deal correction" ?
 
Alexey Viktorov:
If this is intended for indicators set by software, isn't it better to replace the highlighted with the indicator handle?
It's not better. You can't do it without changing the architecture. I described why in great detail.
 
Artyom Trishkin:
What is the "Result.deal correction" ?

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

fxsaber, 2017.02.23 15:34

From the BOD.

Completion of the resulting trade ticket is not guaranteed. Whether or not it fills depends on the execution mode of the instrument and the settings of the particular server.

Who laid down for a non-zero Result.deal - take action.

 
Roffild:

You don't have to set these parameters if you don't want to display the indicator.

If you want to display it, you can put these settings in the parameters.
 
fxsaber:

Well ... I see that you can't count on a non-zero Result.deal. Then what does this line say?

// Учтены MT5-нюансы: Result.deal == 0

Where are they accounted for?

 
Artyom Trishkin:

Well ... I see that you can't count on a non-zero Result.deal. Then what does this line say?

Where are they accounted for?


The overloaded (see above) HistoryDealSelect is called in OrderSendSync.
 

fxsaber:

static bool OrderSendSync( const MqlTradeRequest &Request, MqlTradeResult &Result )

Synchronization is no longer relevant. I only highlighted the piece responsible for Result.deal correction.

And let me ask why static?
Reason: