my Ea it's no working problem with OrderModifly
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES); OrderClose(Ticket,OrderLots(),Ask,0,0); Ticket=OrderSend(S…); OrderModify(…);
You would know why, if you Check your return codes for errors, and report them including GLE/LE. Don't look at GLE/LE. unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles -
while(Ticket==0);
Possible infinite loop. -
Sleep(500000);
After Sleep and between server calls the market will have changed. You must update your variables before using any Predefined Variables or series arrays — you must call RefreshRates. -
Ticket=OrderSend(Symbol(),OP_BUY,Lotti,Ask,0,Ask-10*SL*Point,Ask+TP*Point,0,0,0,0);
You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP is longer. Don't you want the same/specified amount for either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To
trigger at a specific
Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
- Use the debugger or print out your variables, including _LastError and find out why.
Excuse me, so it should go.
I shared the wrong code.
this is the correct one.
thanks for the very quick and fulfilling ans
void EseguiOrdineLong(){ if(iMA(Symbol(),PERIOD_M30,10,0,MODE_SMA,PRICE_CLOSE,2)<iMA(Symbol(),PERIOD_M30,30,75,MODE_SMA,PRICE_CLOSE,2) && iMA (Symbol(),PERIOD_M30,10,0,MODE_SMA,PRICE_CLOSE,0)>iMA(Symbol(),PERIOD_M30,30,75,MODE_SMA,PRICE_CLOSE,0)){ printf("aprire posizione in buy"); Alert("tick new"); OrderSelect(Ticket1,SELECT_BY_TICKET,MODE_TRADES); if(OrderCloseTime()==0 && OrderType()==OP_SELL){ OrderClose(Ticket1,OrderLots(),Ask,0,0); Ticket1=OrderSend(Symbol(),OP_BUY,LottiH4,Ask,0,Ask-10*SL*Point,Ask+10*TP*Point,0,0,0,0); } else if (OrderCloseTime()!=0){ Ticket1=OrderSend(Symbol(),OP_BUY,LottiH4,Ask,0,Ask-10*SL*Point,Ask+10*TP*Point,0,0,0,0); }} if(Ask>TP*Point) { if (OrderSelect(Ticket1,SELECT_BY_TICKET)==True) { OrderModify(OrderTicket(),Ask,Ask-SL*10*Point,Ask+TP*10*Point,0,Yellow); RefreshRates(); }}}
The boys,
my EA doesn't work anymore after entering OrderModifly. I share the code
I'll wait for an answer
thank you very much