Do you want Bid minus Pricegap times Pipvalue times Point ?
Is that
(Bid minus Pricegap) times Pipvalue times Point ?
or is it
(Bid minus Pricegap times Pipvalue) times Point ?
or maybe
Bid minus (Pricegap times Pipvalue) times Point ?
or
Bid minus Pricegap times (Pipvalue times Point) ?
Obviously you need to separate it into smaller chunks before you Normalize the outcome.
Here's an example:
Do you want Bid minus Pricegap times Pipvalue times Point ?
Is that
(Bid minus Pricegap) times Pipvalue times Point ?
or is it
(Bid minus Pricegap times Pipvalue) times Point ?
or maybe
Bid minus (Pricegap times Pipvalue) times Point ?
or
Bid minus Pricegap times (Pipvalue times Point) ?
Obviously you need to separate it into smaller chunks before you Normalize the outcome.
Here's an example:
Yes in the case of a pending order thats correct.
This one was to modify stoploss but the principle is the same.Print("OrderModify() error - ", ErrorDescription (GetLastError()));
- You are modifying the open price of an order to zero -- invalid price -- that is "what's wrong." Perhaps you want to use OrderOpenPrice()?
- This is why I say:You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled. Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.If you read the documentation, you would know that 1 converts to true. You look to see if the modify succeeds and complain that it failed -- that is "what's wrong."
- You can't modify orders if the pending price is closer to market price than the max of StopLevel or FreezeLevel. Requirements and
Limitations in Making Trades - Appendixes - MQL4 Tutorial As news approaches, FreezeLevel will stop you from getting close and if the market gaps, you SL will not protect you.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
i can't make updating my pending orders on every price changing, moving following price until 3 sec before news relaese (yeah another news trading ea). I wrote an ordermodify but seems to work just once.
i saw many ea on youtube that create moving pending order until news relaese, but i can't do this on my own.
attach my code.
Hope in your help
p.s.
"AAAAA.." and "ordine modificato" return to me just once.
{
while(true)
{
int error=GetLastError();
int Slip=Slippage*(int)PipValue;
double price=NormalizeDouble(Bid,NDigits)-PriceGap*PipValue*Point;
double SL=price+StopLoss*PipValue*Point;
if(StopLoss==0) SL=0;
double TP=price-TakeProfit*PipValue*Point;
if(TakeProfit == 0) TP = 0;
int ticket= OrderSend(Symbol(),OP_SELLSTOP,Lots,price,Slip,SL,TP,"NewsTime!!",MagicNumberSell,0,Red);
if(ticket == -1)
{
Print("OrderSend() error - ",ErrorDescription(GetLastError()));
Print("errore "+error+"") ;
if(error==136) break;
Sleep(1000);
RefreshRates();
Print("REFRESHHHHHHHHHH");
break;
}
else
{
OrderSelect(ticket,SELECT_BY_TICKET);
OrderPrint();
UpdateSell();
break;
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void UpdateSell()
{
int datetime800=(int)TimeCurrent();
int hour0=TimeHour(datetime800);
int minute0=TimeMinute(datetime800);
int second0=TimeSeconds(datetime800);
int secpart=StartSecond;
double price=NormalizeDouble(Bid,NDigits)-PriceGap*PipValue*Point;
double SL=price+StopLoss*PipValue*Point;
if(StopLoss==0) SL=0;
double TP=price-TakeProfit*PipValue*Point;
if(TakeProfit == 0) TP = 0;
if(hour0==StartHour && minute0==StartMinute && second0<=secpart)
{
//---
for(int i=OrdersTotal()-1; i>=0; i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumberSell && OrderType()==OP_SELLSTOP)
{
bool res=OrderModify(OrderTicket(),price,SL,TP,0,Blue);
Print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
if(res==1)
Print("OrderModify() error - ", ErrorDescription (GetLastError()));
else
Print("Ordine modificato");
checkshortstop();
}
}
}
}