Errors, bugs, questions - page 771

 
maryan.dirtyn:

That's what I'm doing))... 6th hour... and I can't figure out where the error is

the reluctance to use standard libraries is due to the fact that flags and global variables are used within functions, and it doesn't seem reasonable to take apart trade.mqh and other parts

And what error is returned? )))
 
maryan.dirtyn:

MetaQuotes-Demo

Login: 1219233

EURUSD

I have just tried it on the pound, same story. no stops. i do everything in the tester

Build 655 (if it helps)

Write an explicit initialisation of the structures:

   MqlTradeRequest request={0};
   MqlTradeResult  result={0};

Without it, the structure fields are left with rubbish and you are not filling all the fields.

 

Thank you...

that's the way I let go:

void OnTick(){ if(PositionsTotal()<1)OPEN(); }

bool OPEN(){
             MqlTradeRequest request={0};  ZeroMemory(request);
             MqlTradeResult  result={0};   ZeroMemory(result);
             

             request.symbol       = _Symbol;
             request.action       = TRADE_ACTION_DEAL;
             request.type_filling = ORDER_FILLING_FOK;
             request.deviation    = 100;
             request.volume       = NormalizeDouble(2,2);
             request.type         = ORDER_TYPE_BUY;
             request.price        = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
             request.tp           = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK) + 500*_Point,_Digits);
             request.sl           = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK) - 500*_Point,_Digits);

             OrderSend(request,result);     
                        
             if(result.retcode==10009 || result.retcode==10008)  Print("Succsesful open");
             else                                               Print("Error open: ",DoubleToString(GetLastError(),0),"  response code: ",result.retcode);
    
   return(true);}
 
ZeroMemory() is already superfluous, as a more economical and simple zeroing over ={0} stands before;
 

how do I check this in any other way? this design refuses to work correctly

if(PositionGetDouble(POSITION_PRICE_OPEN)!=PositionGetDouble(POSITION_SL)){ ... }
 

When will there be parameters in OnTrade? We have to make such a mess...

At least know what parameters will be there. Otherwise I'll have to redo a lot of them by the time of the Championship((.

 
pronych:

When will there be parameters in OnTrade? We have to make such a mess...

At least know what parameters will be there. Otherwise I'll have to redo a lot of them by the time of the Championship((.

Will be in today's build tomorrow. Added another entry point:

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

It is clear what should be: instrument, price, lot, type of trade, etc.

But it is not clear how to find out the price of the trade.

Maybe I missed something, I was away for a while...

 
Renat:

Will be already in today's build. Another entry point has been added:

Thank you very much. Finally)))

Really looking forward to it.

 

Dear developers! Since the terminal has no Ask history, would it make sense to bind the stop orders (Buy stop, Sell stop) to the Bid price? Or to make a user select at which price an order should be triggered (Bid or Ask). I mean forex.

Reason: