I am coming back to you with a question. I avoided it for a long time due to my lack of understanding of pending orders in EAs, but finally I got stuck. I do not understand how to set price in pending order. What should I add instead of BID and ASK? Can I use any variable calculated before that? Then, how should I set this price so that it would pass later, when placing an order? I get a lot of errors saying that there is no such a price and so on.....
If you do not mind, you may explain your answer in code... All I searched so much, but it says so sideways...(((
In the quality of values Ask and Bid on idea should act the current values of Ask and Bid, or variables calculated earlier.
There is one peculiarity here: you can take these values as real ones only for Buy and Sell orders.
The best thing is to make the opening of all orders in the form of at least 6 procedures, i.e: OrderSendBuy, OrderSendSell, OrderSendLimitBuy, OrderSendLimitSell, OrderSendStopBuy and OrderSendStopSell.
PS
It should be noted that limit orders are opened at the best price (with an indent from the current price by a certain number of points), and stop orders are placed in the opposite direction above or below the current price.
Example of an opening code from the market:
//Procedure OrderSendBuyvoid OrderSendBuy(string WorkSymbol,double LotsSize=0,int Slippage=3,int SizeSL=0,int SizeTP=100,
string Text=NULL,int MN=0,datetime Expiration=0,color OrdrtColor=CLR_NONE){//----------------------------------------------------------------------------//// Служебные переменныеdouble RealAsk, RealBid;//Текущие Ask и Bid инструментаdouble SymbolPoint;//Размер пункта текущего инструментаdouble SL, TP;// StopLoss и TakeProfit будущей позицииint TicketNew;//Тикер новой позиции (в случае удачи, иначе -1)//----------------------------------------------------------------------------////Зашита от дуракаif( LotsSize<MarketInfo( WorkSymbol,MODE_MINLOT)){ LotsSize =MarketInfo( WorkSymbol,MODE_MINLOT);}//Расчет параметров для новой позиции
SymbolPoint =MarketInfo( WorkSymbol,MODE_POINT);//Определяем размер пункта
RealAsk =MarketInfo( WorkSymbol,MODE_ASK);//Определяем Ask
RealBid =MarketInfo( WorkSymbol,MODE_BID);//Определяем Bidif( SizeTP>0){ TP = RealAsk+ SizeTP* SymbolPoint;}else{ TP = RealAsk+100* SymbolPoint;}if( SizeSL>0){ SL = RealBid- SizeSL* SymbolPoint;}else{ SL =0;}//Попытка открыть позицию с рынка
TicketNew =OrderSend( WorkSymbol,OP_BUY, LotsSize, RealAsk, Slippage, SL, TP, Text, MN, Expiration, OrdrtColor);//Проверка ошибок возникших при открытии новой позицииif( TicketNew==-1)//При открытии произошла ошибка{Print("Попытка открыть Market-Buy позицию по паре ", WorkSymbol," окончилась неудачно. Код ошибки #",GetLastError())
;}else//Позиция успешно установлена{Print("Успешно создана позиция Market-Buy по паре ", WorkSymbol," Тикер новой позиции #", TicketNow);Alert("Open market-Buy, ticket ", TicketNew," Open price ", RealAsk," Profit ", TP," SL ", SL);}//----------------------------------------------------------------------------//}
//Procedure OrderSendLimitBuyvoid OrderSendLimitBuy(string WorkSymbol,double LotsSize=0,int Slippage=3,int LimitStep=50,int SizeSL=0,int SizeTP=100,string Text=NULL,int MN=0,datetime Expiration=0,color OrdrtColor=CLR_NONE){//----------------------------------------------------------------------------//// Служебные переменныеdouble RealAsk, RealBid;//Текущие Ask и Bid инструментаdouble OpenPrice;//Цена на которую будет установлен отложникdouble SymbolPoint;//Размер пункта текущего инструментаdouble SL, TP;// StopLoss и TakeProfit будущей позицииint TicketNew;//Тикер новой позиции (в случае удачи, иначе -1)//----------------------------------------------------------------------------////Зашита от дуракаif( LotsSize<MarketInfo( WorkSymbol,MODE_MINLOT)){ LotsSize =MarketInfo( WorkSymbol,MODE_MINLOT);}//Расчет параметров для новой позиции
SymbolPoint =MarketInfo( WorkSymbol,MODE_POINT);//Определяем размер пункта
RealAsk =MarketInfo( WorkSymbol,MODE_ASK);//Определяем Ask
RealBid =MarketInfo( WorkSymbol,MODE_BID);//Определяем Bid
OpenPrice = RealAsk- LimitStep* SymbolPoint;//Цена на которую будет установлен отложникif( SizeTP>0){ TP = OpenPrice+ SizeTP* SymbolPoint;}else{ TP = OpenPrice+100* SymbolPoint;}if( SizeSL>0){ SL = RealBid-( SizeSL+ LimitStep)* SymbolPoint;}else{ SL =0;}//Попытка открыть позицию с рынка
TicketNew =OrderSend( WorkSymbol,OP_BUYLIMIT, LotsSize, OpenPrice, Slippage, SL, TP, Text, MN, Expiration, OrdrtColor);//Проверка ошибок возникших при открытии новой позицииif( TicketNew==-1)//При открытии произошла ошибка{Print("Попытка создать Limit-Buy по паре ", WorkSymbol," окончилась неудачно. Код ошибки #",GetLastError());}else//Позиция успешно установлена{Print("Успешно создан ордер Limit-Buy по паре ", WorkSymbol," Тикер ордера #", TicketNow);Alert("Create Limit-Buy, ticket ", TicketNew," Open price ", OpenPrice," Profit ", TP," SL ", SL);}//----------------------------------------------------------------------------//}
Day (D1) 2008.09.01 00:00 - 2009.08.31 00:00 (2008.09.01 - 2009.09.01)
Model
All ticks (the most accurate method based on all smallest available timeframes)
Bars in history
1259
Modelled ticks
8769661
Modeling quality
n/a
Chart mismatch errors
225
I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?
Maybe I shouldn't even pay attention, I just don't understand ...
Day (D1) 2008.09.01 00:00 - 2009.08.31 00:00 (2008.09.01 - 2009.09.01)
Model
All ticks (the most accurate method based on all smallest available timeframes)
Bars in history
1259
Modelled ticks
8769661
Modeling quality
n/a
Chart mismatch errors
225
I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?
Maybe I shouldn't even pay attention, I just don't understand ...
Thanks in advance.
I don't know I personally never bother with such things (as I almost always test strategies without visualization).
Here is what I got on Jew D1 with a similar testing period
Attempt #1: bars in history - 1302 ticks simulated - 4313293 Quality of simulation - 50.00%
Attempt #2: Bars in history - 1303 Modelled ticks - 4323442 Modelling quality - 50.00% Chart mismatch errors - 0.
I am thinking now that MT automatically fills the last 512 bars and fills the rest .... I don't know how to say it exactly. My Expert Advisor is a trend one and the distance is important to me. 512 bars is not too much.
As for the other symbols, it can be downloaded from a separate site and downloaded later?
Can you please tell me how to declare a one-dimensional array (in an indicator), if the number of elements of the array is set by an external variable.
Day (D1) 2008.09.01 00:00 - 2009.08.31 00:00 (2008.09.01 - 2009.09.01)
Model
All ticks (the most accurate method based on all smallest available timeframes)
Bars in history
1259
Modelled ticks
8769661
Modeling quality
n/a
Chart mismatch errors
225
I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?
Maybe I shouldn't even pay attention, I just don't understand ...
Thanks in advance.
My below IMHO, but being quotes- please correct me if I'm wrong:
The point is that Close 59th minute, Close 45th minute on M15, Close 30th minute on M30 and Close on H1 may NOT coincide.
To coincide, you need to kill your own history, by downloading the history from the server of quotes for a smaller period
Can you please tell me how to declare a one-dimensional array (in an indicator), if the number of elements of the array is set by an external variable.
My below IMHO, but being quotes, please correct me if I'm wrong:
The fact is that Close 59th minute, Close 45th on M15, Close 30th on M30 and Close on H1 may NOT match.
To coincide, you need to kill your own history, by downloading history from the server of quotes for a smaller period
and recalculate all timeframes using the downloaded history.
In this case, the real Close on different timeframes may also not coincide.
That is, in a good way, you should take the smaller timeframe and read the values of the larger timeframe.
О! Hands!!!
Thanks for the answer. But judging from the first part, I understand that the errors are not critical for me. Thanks a lot for explaining the mechanism of these errors.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Dmido писал(а) >>
Good day)
I am coming back to you with a question. I avoided it for a long time due to my lack of understanding of pending orders in EAs, but finally I got stuck. I do not understand how to set price in pending order. What should I add instead of BID and ASK? Can I use any variable calculated before that? Then, how should I set this price so that it would pass later, when placing an order? I get a lot of errors saying that there is no such a price and so on.....
If you do not mind, you may explain your answer in code... All I searched so much, but it says so sideways...(((
In the quality of values Ask and Bid on idea should act the current values of Ask and Bid, or variables calculated earlier.
There is one peculiarity here: you can take these values as real ones only for Buy and Sell orders.
The best thing is to make the opening of all orders in the form of at least 6 procedures, i.e: OrderSendBuy, OrderSendSell, OrderSendLimitBuy, OrderSendLimitSell, OrderSendStopBuy and OrderSendStopSell.
PS
It should be noted that limit orders are opened at the best price (with an indent from the current price by a certain number of points), and stop orders are placed in the opposite direction above or below the current price.
Example of an opening code from the market:
Example code for setting a pending order:
Hello.
I am testing an EA.
I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?
Maybe I shouldn't even pay attention, I just don't understand ...
Thanks in advance.
Hello.
I am testing an EA.
I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?
Maybe I shouldn't even pay attention, I just don't understand ...
Thanks in advance.
I don't know I personally never bother with such things (as I almost always test strategies without visualization).
Here is what I got on Jew D1 with a similar testing period
Attempt #1: bars in history - 1302 ticks simulated - 4313293 Quality of simulation - 50.00%
Attempt #2: Bars in history - 1303 Modelled ticks - 4323442 Modelling quality - 50.00%
Chart mismatch errors - 0.
Don't know I personally never bother with such things (as I almost always test strategies without visualisation).
Here is what I got on Jew D1 with a similar testing period
Attempt #1: bars in history - 1302 ticks simulated - 4313293 Quality of simulation - 50.00%
Try #2: History: 1303 bars - 1303 ticks simulated - 4323442 Modeling quality - 50.00%
Error of chart mismatch - 0.
Thank you.
I am thinking now that MT automatically fills the last 512 bars and fills the rest .... I don't know how to say it exactly. My Expert Advisor is a trend one and the distance is important to me. 512 bars is not too much.
As for the other symbols, it can be downloaded from a separate site and downloaded later?
I thank you.
Good afternoon, dear friends.
I've been dumb lately, maybe it's the weather.
Can you please tell me how to declare a one-dimensional array (in an indicator), if the number of elements of the array is set by an external variable.
Thank you.
Hello.
I am testing an EA.
I am getting mismatch errors. Is there any way to avoid them? I don't understand if this is a large or small number of errors. The scale is predominantly green and dark green, but only about 20% full. And the simulation quality is n/a - is that a problem?
Maybe I shouldn't even pay attention, I just don't understand ...
Thanks in advance.
My below IMHO, but being quotes- please correct me if I'm wrong:
The point is that Close 59th minute, Close 45th minute on M15, Close 30th minute on M30 and Close on H1 may NOT coincide.
To coincide, you need to kill your own history, by downloading the history from the server of quotes for a smaller period
and recalculate all timeframes using the downloaded history.
In this case, the real Close on different timeframes may also not coincide.
In other words, you should take the smaller timeframe and read the values of the larger timeframe with your HAND.
Good afternoon, dear friends.
I've been dumb lately, maybe it's the weather.
Can you please tell me how to declare a one-dimensional array (in an indicator), if the number of elements of the array is set by an external variable.
Thank you.
int y[];
extern int blah-blah = 100;
init() {
ArrayResize(y, blah-blah);
}
My below IMHO, but being quotes, please correct me if I'm wrong:
The fact is that Close 59th minute, Close 45th on M15, Close 30th on M30 and Close on H1 may NOT match.
To coincide, you need to kill your own history, by downloading history from the server of quotes for a smaller period
and recalculate all timeframes using the downloaded history.
In this case, the real Close on different timeframes may also not coincide.
That is, in a good way, you should take the smaller timeframe and read the values of the larger timeframe.
О! Hands!!!
Thanks for the answer. But judging from the first part, I understand that the errors are not critical for me. Thanks a lot for explaining the mechanism of these errors.
at the very top:
I'm struggling specifically with these flags, can anyone take a fresh look?
-----------------
and there's also a problem with the EA code:
it's not trading! Maybe someone will have a fresh look at it.
decided to stupid as soon as the 100 (-100) goes to trade!
I attach EA!