Discussion on the implementation of councillors. - page 2

 
Georgiy Merts:

I DO NOT UNDERSTAND how it works. Moreover, this forumer himself when asked the question said that he no longer remembers, just that this code has already been tested many times and can be trusted.

Well, if I get a chance to replace these stupid "questions" with real if statements, I'll figure it out... For now...

By the way, took a look at this horror today.

Here's what it means:

ENUM_ORDER_TYPE_FILLING otfMyRes  = WRONG_VALUE;   

if(iFillingMode == 0 || (otfFilingType >= ORDER_FILLING_RETURN) || ((iFillingMode & (otfFilingType + 1)) != otfFilingType + 1))
	{
        if(steExeMode == SYMBOL_TRADE_EXECUTION_EXCHANGE || steExeMode == SYMBOL_TRADE_EXECUTION_INSTANT)
                otfMyRes = ORDER_FILLING_RETURN;
        else   
                if(iFillingMode == SYMBOL_FILLING_IOC)
                        otfMyRes = ORDER_FILLING_IOC;
                else
                        otfMyRes = ORDER_FILLING_FOK;
        }
   else      
        otfMyRes = otfFilingType;

return(otfMyRes);  

In my opinion, it's much clearer without these "questions", through if's and with indents. Although code efficiency is absolutely the same.

By the way, you can see at once that the author stuck to numerical values of iFillingMode and otfFilingType, which, in my opinion, is not good practice.

 
Georgiy Merts:

By the way, took a look at this horror today.

Here's what it means:

In my opinion, it's much clearer without these "questions", through if's and with indents. Although code efficiency is absolutely the same.

By the way, you can see at once that the author stuck to numerical values of iFillingMode and otfFilingType, which, in my opinion, is not good practice.

In my lib it's like this:

#ifdef __MQL5__
   ENUM_ORDER_TYPE_FILLING COrder::GetFilling(ENUM_FILLING_MODE mFilling){
      if (!_fillingMode) return ORDER_FILLING_RETURN;
      else if (mFilling==FILLING_AUTO||mFilling==FILLING_FOK) return !(_fillingMode&SYMBOL_FILLING_FOK)?ORDER_FILLING_IOC:ORDER_FILLING_FOK;
      else return  !(_fillingMode&SYMBOL_FILLING_IOC)?ORDER_FILLING_FOK:ORDER_FILLING_IOC;}
#endif

_fillingMode is a macro that expands into the dereferencing of this field

fillingMode=(int)SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE);
 
Georgiy Merts:

That's another thing.

Come to think of it, I sometimes look at my own code and don't understand why it is written in this particular place. That is why I try to comment on such places in great detail, trying to mention all the details. But still I regularly see that I haven't considered some things.

Moreover, I use the following code (to determine the type of execution), which was written by a very authoritative forum user:

I DO NOT UNDERSTAND how it works. Moreover, this forumer himself said when asked that he no longer remembers, it's just that this code has already been tested many times and can be trusted .

Well, if I manage to replace these stupid "questions" with real if statements, I'll figure it out... For now...

Yellow - very strange that a person can not immediately understand the trivial code that he wrote himself.

Red - I wasn't too lazy and checked again, when executing on the market, I cannot ORDER_FILLING_RETURN, it's only for stock (there's an error in docks), and this is what the respected forum owner has returned)))

 
Vladimir Simakov:

Yellow - it's very strange that a person cannot understand a trivial code, which he wrote himself.

Red - I did not feel lazy and checked again, when executing on the market, you cannot ORDER_FILLING_RETURN, it is only for exchange (there is an error in the docks), and this is what the respected forum member returns)))

I don't know, I don't know. how "trivial" this code is in such an entry. It took me at least 15 min to figure out its logic, and only through writing out the if's did it make sense to me.

And about "there's an error in the docs" - can you elaborate on that?

 
Georgiy Merts:

I don't know, I don't know how "trivial" this code is in a post like this. It took me at least 15 minutes to understand the logic of its work, and only through writing out the if's did it become clear to me.

And about "in docks error" - can you tell me more about it?

At exchange execution

SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE)

it returns 0, but at market (I checked at Alpari)

SYMBOL_FILLING_IOC | SYMBOL_FILLING_FOK

I checked with Alpari and it returns 0x3. If you try it in this way

MqlTradeRequest::filling_mode=ORDER_FILLING_RETURN

If you try it, it won't open.

 
Vladimir Simakov:

then it won't open.

Checked the original function.

#include <MT4Orders.mqh>

#define  Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

void OnTick()
{
  if (!OrdersTotal())
  {
    OrderSend(_Symbol, OP_BUY, 0.1, Ask, ORDER_FILLING_FOK, 0, 0);    
    OrderSend(_Symbol, OP_BUY, 0.1, Ask, ORDER_FILLING_IOC, 0, 0);    
    OrderSend(_Symbol, OP_BUY, 0.1, Ask, ORDER_FILLING_RETURN, 0, 0);    
  }  
}

It works.

 
fxsaber:

Checked the original function.

It works.

Try it on market execution rather than exchange execution)

UPD: correction, on immediate execution, the one that

SYMBOL_TRADE_EXECUTION_INSTANT

 
Vladimir Simakov:

Try on market execution rather than exchange execution)

UPD: correction, on immediate execution, the one that

SYMBOL_TRADE_EXECUTION_INSTANT

Test EA above. Try it out.

 
Vladimir Simakov:

Try on market execution rather than exchange execution)

UPD: correction, on immediate execution, the one that

SYMBOL_TRADE_EXECUTION_INSTANT

These are for example standard type accounts in A-ri, right?

And brokers with dealing always have this kind of execution, right?

Just to clarify.

 

Why bother?

Use standard classes and don't need to fill any structures(MqlTradeRequest) and don't need to know any Fillings and Instants:


#include<Trade\SymbolInfo.mqh>
#include<Trade\AccountInfo.mqh>
#include<Trade\Trade.mqh>

CTrade  
CAccountInfo 
CPositionInfo