error 4756 - page 3

 
BHC:

 My EA is bringing u weird errors with build 778. The volume of 0.1 is normalized and clearly not invalid.

Can you check the symbol properties for Silver and let us know what the SYMBOL_VOLUME_MIN  and  SYMBOL_VOLUME_STEP  are please.  It's not always enough just to Normalize,  for example if your Volume Step were 0.5 then Normalize wouldn't help you.
 
RaptorUK:
Can you check the symbol properties for Silver and let us know what the SYMBOL_VOLUME_MIN  and  SYMBOL_VOLUME_STEP  are please.  It's not always enough just to Normalize,  for example if your Volume Step were 0.5 then Normalize wouldn't help you.

 

This source

Print(" volume step: ",SymbolInfoDouble(_trade_symbol,SYMBOL_VOLUME_STEP),", volume minimum: ",", ",SymbolInfoDouble(_trade_symbol,SYMBOL_VOLUME_MIN)); return;
         

 

 Gives this in the tester logs...

2013.03.12 12:46:01 Core 1 2013.01.23 13:32:59    volume step: 0.1, volume minimum: , 0.1

 
BHC:

 

This source

 

 Gives this in the tester logs...

2013.03.12 12:46:01 Core 1 2013.01.23 13:32:59    volume step: 0.1, volume minimum: , 0.1

The issue might be in your error reporting,  I've not checked with mql5 but this will not work with mql4 . . .

if(_result.retcode != ( 0 || TRADE_RETCODE_PLACED || TRADE_RETCODE_DONE))

 instead try this . . 

if( _result.retcode != 0 && _result.retcode != TRADE_RETCODE_PLACED && _result.retcode != TRADE_RETCODE_DONE )
 
That got rid of the errors! Thx
 
BHC:
That got rid of the errors! Thx
if(_result.retcode != ( 0 || TRADE_RETCODE_PLACED || TRADE_RETCODE_DONE))

Is there any language where this syntax is valid ?

 
I had never come across it actually as well... I think I got this from somebody's implementation of ordercheck. It was on this site...
 
angevoyageur:

Is there any language where this syntax is valid ?

Perhaps, if the variables were of type bool it could make some sense. I have seen a few people do similar things on the mql4 forum,  its a simple mistake to make.
 
RaptorUK:
Was this the thread you found ?  https://www.mql5.com/en/forum/10850  it reports the same issue as I am having

I didn't see this thread.

Solution is as I said you, with OnTradeTransaction() event handler (DON'T USE THIS CODE AS IS, IT'S FOR TRIAL & TEST):

void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
                        {

    if (trans.type == TRADE_TRANSACTION_DEAL_ADD) {

        if (execution == SYMBOL_TRADE_EXECUTION_MARKET) {
            if (!trade.PositionModify(_Symbol, _sl, _tp))
                if (debugMode) {
                    Print("Modify SL & TP failed. Return code=", trade.ResultRetcode(), ". Code description: ", trade.ResultRetcodeDescription());
                    Print("Deal ticket : ", trans.deal);
                }
            else
                if (debugMode) Print("Modify SL & TP executed successfully. Return code=", trade.ResultRetcode(), " (", trade.ResultRetcodeDescription(),")");
        }

    }
}   

That's working. _sl and _tp are global variables, it's surely better to process localy. trade is of CTrade class type. I suppose you can do the same with OrderSend().

 
angevoyageur:

I didn't see this thread.

Solution is as I said you, with OnTradeTransaction() event handler (DON'T USE THIS CODE AS IS, IT'S FOR TRIAL & TEST):

That's working. _sl and _tp are global variables, it's surely better to process localy. trade is of CTrade class type. I suppose you can do the same with OrderSend().

I'm staying away from the CTrade class in an attempt to learn the basics,  I've never used OOP so classes, structures, etc are all part of my learning curve with mql5.

 

I'm sure  OnTradeTransaction()  would offer a workaround,  but it seems like a fairly horrible one for me to use even for the simple EA I'm working on,  there is also no mention of the need to use it in the documentation for OrderSend()  and I think,  I will confirm,  that I have seen the same issue in the Strategy Tester,  not sure how exactly this could happen,  I'll try it again with some more error reporting added to make sure.

 
RaptorUK:

I'm staying away from the CTrade class in an attempt to learn the basics,  I've never used OOP so classes, structures, etc are all part of my learning curve with mql5.

 

I'm sure  OnTradeTransaction()  would offer a workaround,  but it seems like a fairly horrible one for me to use even for the simple EA I'm working on,  there is also no mention of the need to use it in the documentation for OrderSend()  and I think,  I will confirm,  that I have seen the same issue in the Strategy Tester,  not sure how exactly this could happen,  I'll try it again with some more error reporting added to make sure.

I understand your position about OOP. It always takes more time than "tradional" approach and is realy useful for large (or medium) project.

I am very interested to know if it exist a "classic" solution for our problem.