why not open a sell ??

 

Hi guys  i am in MT5 i try to open inthe same time one order in NZDJPY in buy and  one order  SELL in NZDUSD  i have create an expert i place over NZDJPY and push the button , the button call some function and  open only a BUY NZDJPY and not openNZDUSD

this is my part of code

  string _Apri_Correlato(string oPen,double lott, int slipp,double STp,double TKp,string Commento){
       int Result=0;
       
      if (oPen=="BUY"){
             Result = OrderSend(Cross_Correlato,OP_BUY,lott,MarketInfo(_Symbol, MODE_ASK),slipp,STp,TKp,IntegerToString(Magik)+Commento+IntegerToString(Enteglement),Magik,0,clrGreen);
               if ( Result ==-1){
               Print("op_BUY "+Commento ,GetLastError());
               }
         }else if (oPen=="SELL"){
             Result = OrderSend(Cross_Correlato,OP_SELL,lott,MarketInfo(_Symbol, MODE_BID),slipp,STp,TKp,IntegerToString(Magik)+Commento+IntegerToString(Enteglement),Magik,0,clrGreen);
               Print("RISULTATO "+Result+"_"+Cross_Correlato);
               if ( Result ==-1){
               Print("op_SELL "+Commento ,GetLastError());
               }
          }                       
         return IntegerToString( Result);
   }

the variable result  return  2024.10.24 17:51:36.558    SPREAD_ROBOT (NZDJPY+,H1)    RISULTATO -1_NZDUSD+

but  why  not return GetLastError  ? anyone can help me  thanks


,GetLastError()
 

you have not shown any calculations or definitions of any of the function inputs so do not expect any other responses until you do add those to the thread.

But i do recommend that you reset error at start of the function, and the result line, change it to if(OrderSend()<0) This might be all you need.

The above will not show errors because it will only show if error is -1 but there are many error codes below 0.

 
Michael Charles Schefe #:

you have not shown any calculations or definitions of any of the function inputs so do not expect any other responses until you do add those to the thread.

But i do recommend that you reset error at start of the function, and the result line, change it to if(OrderSend()<0) This might be all you need.

The above will not show errors because it will only show if error is -1 but there are many error codes below 0.

My friend, it's not that I don't want to include the program, but the program consists of many external parts, and it would be really huge. My only problem is why GetLastError() doesn't give me any additional error even though I call it and it returns -1 from order send