When you do this . . .
//Manage open orders //move Real.TrailingStop if profit>TS if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>Real.TrailingStop*Point && OrderStopLoss()>Ask+Real.TrailingStop*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Real.TrailingStop*Point,0,0, Red); } }
. . . what order have you selected ?
maybe it explains this ?
2011.08.05 17:06:46 2011.08.04 23:59 David v001 EURUSD,H1: OrderModify error 4108
4108 -> ERR_INVALID_TICKET 4108 Invalid ticket.
When you do this . . .
. . . what order have you selected ?
maybe it explains this ?
2011.08.05 17:06:46 2011.08.04 23:59 David v001 EURUSD,H1: OrderModify error 4108
4108 -> ERR_INVALID_TICKET 4108 Invalid ticket.
EUR/USD 1 HOUR
When you use OrderType(), OrderOpenPrice(), etc. you first need to use OrderSelect()
https://docs.mql4.com/trading/OrderType https://docs.mql4.com/trading/OrderOpenPrice
int OrderTicket()
"Returns ticket number for the currently selected order.
Note: The order must be previously selected by the OrderSelect() function."
When you use OrderType(), OrderOpenPrice(), etc. you first need to use OrderSelect()
https://docs.mql4.com/trading/OrderType https://docs.mql4.com/trading/OrderOpenPrice
int OrderTicket()
"Returns ticket number for the currently selected order.
Note: The order must be previously selected by the OrderSelect() function."
Can give me some example of the code ??
Can give me some example of the code ??
Have a read of stuff here: http://crum.be/trailsl
and here: https://forum.mql4.com/23384
if you are a programmer please help . Trailing stop not working
int start(){ HandleDigits();
Only needs to be done once in init()if(TimeHour(TimeCurrent())>=FridayCloseHour) { CloseAllBuyOrders(magic); CloseAllSellOrders(magic); } if((TimeHour(TimeCurrent())>TradeTime)) cantrade=true;
First you close all orders at the end of the week and then continue and open more. Missing a return?if (DayOfWeek()==5) if(TimeHour(TimeCurrent())>=FridayCloseHour)
for (i=iTotalOrders; i>=0; i--) // Rosh line { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderMagicNumber()==MN) if (OrderSymbol()== Symbol()) {
Each of these should be one statement not four. You mean 'select my orders' one thoughtfor (i=iTotalOrders; i>=0; i--) if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == MN && OrderSymbol() == Symbol() ){
On the OrderClose(... Bid/Ask) If you are closing multiple orders, you must RefreshRates() between server calls. Also Bid/Ask is unnecessary you can use OrderClosePrice() for either direction.if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) { return(0); }
Why select it if you're not going to do anything with it.//Manage open orders //move Real.TrailingStop if profit>TS if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>Real.TrailingStop*Point && OrderStopLoss()>Ask+Real.TrailingStop*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Real.TrailingStop*Point,0,0, Red); } }
You haven't selected anything, so OrderTicket, etc is bogus. Only valid just after opening the order due to #3.- No trailing stops for BUYs?
if(MaxOpenTime>0) { for(cnt=0;cnt<total;cnt++)
You MUST count down when closing/modify/deleting in the presence of multiple orders (multiple charts) You already have to closing functions, use them.
// if (OrderType()==OP_BUY) // closeprice=Bid; // else // closeprice=Ask; closeprice = OrderClosePrice();
- Only needs to be done once in init()
- First you close all orders at the end of the week and then continue and open more. Missing a return?
- Each of these should be one statement not four. You mean 'select my orders' one thought
On the OrderClose(... Bid/Ask) If you are closing multiple orders, you must RefreshRates() between server calls. Also Bid/Ask is unnecessary you can use OrderClosePrice() for either direction.
- Why select it if you're not going to do anything with it.
- You haven't selected anything, so OrderTicket, etc is bogus. Only valid just after opening the order due to #3.
- No trailing stops for BUYs?
- You MUST count down when closing/modify/deleting in the presence of multiple orders (multiple charts) You already have to closing functions, use them.
ok . Thanks
Forex EA (Expert Adviser) Forex Robot Programmer Developer
Hi,By Profession Im Software Engineer. But from
last 7 years Im in Forex Trading. I 've developed many more Forex Robots EA
Expert Advisers, and distributed to client as per given criteria. There are so
many satisfied clients.
If any one wants to automate their own strategy,
or wants their own Forex Robot / EA Expert Adviser: contact immediately:forex.eamaster@gmail.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is a Good Auto EA ( MT4 ), if you are a programmer please help ( August 2011 Year )
To Use just change the Trade Time will do .
This is a Good Auto EA (MT 4 ), But need to have Some Fine tune,
if you are a programmer please help . Trailing stop not working . and journal report :
2011.08.05 17:06:46 2011.08.04 23:59 David v001 EURUSD,H1: OrderModify error 4108
2011.08.05 17:06:46 2011.08.04 23:59 David v001 EURUSD,H1: unknown ticket 107 for OrderModify function
2011.08.05 17:06:46 2011.08.04 23:59 David v001 EURUSD,H1: OrderModify error 4108
2011.08.05 17:06:46 2011.08.04 23:59 David v001 EURUSD,H1: unknown ticket 107 for OrderModify function