Did you check the documentation ? Also you have to be sure that an expiration mode is allowed for your symbol.
SYMBOL_EXPIRATION_GTC |
1 |
The order is valid during the unlimited time period, until it is explicitly canceled |
Did you check the documentation ? Also you have to be sure that an expiration mode is allowed for your symbol.
SYMBOL_EXPIRATION_GTC |
1 |
The order is valid during the unlimited time period, until it is explicitly canceled |
int OnInit() { /* Check is pending orders and expiration is allowed*/ if(SymbolInfo.ExpirationTime()) Print("Pending Order Expiration is allowed on this symbol"); else { Print("Pending Order Expiration is NOT allowed on this symbol"); } }
I fixed it to : ORDER_TIME_SPECIFIED
Since I am in demo I wouldn't think that it would be a problem for testing purposes. The broker I signed up for on the Demo in question " Does not allow pending Order Expiration."
I guess I have to create some type of timer later.
I would like to test what I have built with a broker that supports this specific feature is there a list?
When I scan I only get 1 broker.
Thank you for leading me in the right direction. In the previous post.
The ORDER_TIME_SPECIFIED feature I would like to know if its okay to do so. The only information I would post would be The Broker Name and ORDER_TIME_SPECIFIED is supported and not supported. When I search the site I could not find anything on the subject matter.
I would like to post brokers who support
I fixed it to : ORDER_TIME_SPECIFIED
Since I am in demo I wouldn't think that it would be a problem for testing purposes. The broker I signed up for on the Demo in question " Does not allow pending Order Expiration."
I guess I have to create some type of timer later.
I would like to test what I have built with a broker that supports this specific feature is there a list?
When I scan I only get 1 broker.
Thank you for leading me in the right direction. In the previous post.
SymbolInfo.ExpirationTime() return a datetime, so this code isn't valid :
if(SymbolInfo.ExpirationTime())
You have to check SYMBOL_EXPIRATION_MODE.
I fixed it to : ORDER_TIME_SPECIFIED
Since I am in demo I wouldn't think that it would be a problem for testing purposes. The broker I signed up for on the Demo in question " Does not allow pending Order Expiration."
I guess I have to create some type of timer later.
I would like to test what I have built with a broker that supports this specific feature is there a list?
When I scan I only get 1 broker.
Thank you for leading me in the right direction. In the previous post.
Hi, you don't need a broker list or even a timer, just scan the list of pending orders and close the expired ones.
The problem of this solution is when your terminal is offline, since your solution is not server side.
Anyway, if this is not relevant to you, this solution must work with any broker.
SymbolInfo.ExpirationTime() return a datetime, so this code isn't valid :
You have to check SYMBOL_EXPIRATION_MODE.
I checked it out. I didn't know how to implement it until I came across
at the bottom of the page was some example code.
Implementation came later when I read an article : Trade operation in MQL5.
I ended up with. Thank you again for replying back your attention to detail an knowledge in this area is amazing.
// global variable string smbol=Symbol(); // oninit int OnInit() { /* Check is pending orders and expiration is allowed*/ int expiration=(int)SymbolInfoInteger(smbol,SYMBOL_EXPIRATION_MODE); if (expiration == true) Print("Pending Order Expiration is allowed on this symbol"); else { Print("Pending Order Expiration is NOT allowed on this symbol"); } }
Hi, you don't need a broker list or even a timer, just scan the list of pending orders and close the expired ones.
The problem of this solution is when your terminal is offline, since your solution is not server side.
Anyway, if this is not relevant to you, this solution must work with any broker.
That is an even better idea. Your also right the solution must work with any broker. So if OnInit, replies False then a way to make up for the short comings of the limitation must be introduced.
Good night,
I just review all topics about this error without success because the issue still appear in my code.
Value for SYMBOL_EXPIRATION_MODE is SYMBOL_EXPIRATION_GTC.
And the code is:
mrequest.action = TRADE_ACTION_PENDING; // Pending order execution mrequest.symbol = _Symbol; // Symbol mrequest.volume = GetLotSize(Lot); // Number of lots to trade int offset = 50; // distancia con respecto al precio actual para poner la orden, en puntos double price; // precio de activación de la orden double point=SymbolInfoDouble(_Symbol,SYMBOL_POINT); // tamaño del punto int digits=SymbolInfoInteger(_Symbol,SYMBOL_DIGITS); // número de dígitos tras la coma (precisión) price=SymbolInfoDouble(Symbol(),SYMBOL_BID)-offset*point; // precio de apertura mrequest.price=NormalizeDouble(price,_Digits); // precio de apertura normalizado mrequest.sl = NormalizeDouble(price+1300*point,_Digits); mrequest.tp = NormalizeDouble(vPrice - ((pStopLoss-vPrice) * InpTakeProfit),_Digits); // Take Profit mrequest.type= ORDER_TYPE_SELL_STOP; // Sell order mrequest.magic = 0; // Magic Number mrequest.type_filling = SYMBOL_FILLING_FOK; // Order execution type mrequest.deviation=5; // Deviation from current price mrequest.type_time = SYMBOL_EXPIRATION_GTC;
And result is:
2018.08.29 22:37:15.750 2016.01.05 06:00:00 failed sell limit 0.20 EURUSD at 1.08259 sl: 1.09559 tp: 1.06951 [Invalid expiration]
2018.08.29 22:37:15.750 2016.01.05 06:00:00 OrderSend error 4756
2018.08.29 22:37:15.750 2016.01.05 06:00:00 retcode=10022 deal=0 order=0
I'll appreciate all your support ir order to go ahead and finish this EA.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use