Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 963

 
vadimvborisov:


yesatztek, I apologise for the inaccuracy in the description:

1. Because before the intersection with the MA, these were buy-stop orders and Ur1 Ur2 Ur3 are identified only after the price crosses the MA.

2. and respectively the above mentioned for-cycle searches among all buy orders (since there are 3 more sell-stop orders and they crawl on a different MA at each candlestick)

1. You said:
Советник открывает (на основании пересечения с MA ) несколько (3) рыночных ордеров

Stop orders become marketable the moment they are crossed by price, MA has nothing to do with it.
Ok, it's up to you to decide how your EA works.

2. What is the purpose - ?
 bool mod_Buy1 = OrderModify ( OrderTicket(???),OrderOpenPrice (), NULL,Ur1,0,clrNONE);
 bool mod_Buy2 = OrderModify ( OrderTicket(???),OrderOpenPrice (), NULL,Ur2,0,clrNONE);
 bool mod_Buy3 = OrderModify (OrderTicket(???),OrderOpenPrice (), NULL,Ur3,0,clrNONE);

I.e. for each cycle in the "for" you see one order, and not all three at once.
 

atztek, 1. I have already corrected my first post.

2. Assignment ofbool mod_Buy1 = Modify order (OrderTicket (the first BUY order from the previous ones), do not change the opening price, do not change the Stop Loss, TakeProfit is taken from Ur1,0,clrNONE);

"In other words, in each loop in the "for" you see one order, but not all three at the same time.

That's the thing, I can't figure out how to go through these 3 orders by ticket and set appropriate Takeprofit levels for each of them(Ur1 Ur2 Ur3).

 
vadimvborisov:

atztek, 1. I have already corrected my first post.

2. Assignment ofbool mod_Buy1 = Modify order (OrderTicket (the first BUY order from the previous ones), do not change the opening price, do not change the StopLoss, TakeProfit is taken from Ur1,0,clrNONE);

"In other words, in each loop in the "for" you see one order, but not all three at the same time.

That's the thing, I can't figure out how to go through these 3 orders by ticket and set appropriate TakeProfit levels for each of them(Ur1 Ur2 Ur3).


1. Either I don't understand you, or you don't know what you want to do (or how it works).
You even after correcting you talk about having stop orders and then "after crossing the MA" they became market orders.
- You either open market orders immediately (e.g. "after crossing the MA") or you open stop orders that automatically become market orders the moment the price crosses them.

2. I see that this is not a question of correction, but the logic of your EA
(there are many questions, for example, do you have other orders open at this time, why orders are selected based on the ticket, and not positions, etc.)
Do not start with 3 orders at once, start with a simple example with one order, and make sure that the Expert Advisor works without errors. Then complicate it by adding 3 orders.
 

1) yes exactly -"you open stop orders which automatically become market orders the moment the price crosses them. "

2) There are no other (market) orders at the moment limit orders are converted to market orders, only limit orders. Maybe you can also select by position and not by ticket - I don't mind. Ok. let's consider the situation with Two orders. because I can deal with One myself....

 
vadimvborisov:

1) yes exactly -"you open stop orders which automatically become market orders the moment the price crosses them. "

2) There are no other (market) orders at the moment limit orders are converted to market orders, only limit orders. Maybe you can also select by position and not by ticket - I don't mind. Ok. let's consider the situation with Two orders. because I can deal with One myself....

Have the limit ones come in yet?
All right, go ahead. When you've got one, then the rest will become clear.
 
vadimvborisov:

1) yes exactly -"you open stop orders which automatically become market orders the moment the price crosses them. "

2) There are no other (market) orders at the moment limit orders are converted to market orders, only limit orders. Maybe you can also select by position and not by ticket - I don't mind. Ok. let's consider the situation with Two orders. because I can deal with One myself....

That's exactly what we need.

int i, total = OrdersTotal();
for(i = 0; i < total; i++)
{
 if(OrderSelect(i, SELECT_BY_POS) && OrderType() == OP_BUY)
  {
   bool mod_Buy1 = Модифицировать ордер ( OrderTicket(i-тый BUY из перебранных )
  }
}
 

1. sorry, i meant stop orders.

2. with 1 everything works. but with two or more I can't figure out....

 

Greetings,AlexeyVik

bool mod_Buy1 = Modify Order ( OrderTicket(the i-th BUY of the fetched ones )

and for other two BUY's how? In the same way?

////////////////////////////
 int i, total = OrdersTotal();
for(i = 0; i < total; i++)
{
 if(OrderSelect(i, SELECT_BY_POS) && OrderType() == OP_BUY)
  {
   bool mod_Buy1 = Модифицировать ордер ( OrderTicket(i-тый BUY из перебранных )
   bool mod_Buy2 = Модифицировать ордер ( OrderTicket(i-тый BUY из перебранных )
   bool mod_Buy3 = Модифицировать ордер ( OrderTicket(i-тый BUY из перебранных )
  }
}
 
vadimvborisov:

Greetings,AlexeyVik

bool mod_Buy1 = Modify Order ( OrderTicket(the i-th BUY of the fetched ones )

and for other two BUY's how? In the same way?

Note the loop in my example. In the loop, all orders are checked by type, also check by symbols and magic and it would be nice to check OrderStopLoss == 0 or OrderTakeProfit == 0 depending on what is important, whether the order without stop or without takeaway order, so as not to try to modify the order unnecessarily and not to get error 1.

In this loop, the order is selected one after another, and if all conditions are met, it is sent to modify. This will modify all of the necessary orders.

The second variant: If only 3 orders have been provided for, we can declare, for example, int tick_buy_1, tick_buy_2, tick_buy_3 at the level of global variables and record the ticks into these variables when opening the order. Then we can select the order by ticket, check its type, whether the order is closed or not, and only then, without the loop.

   bool mod_Buy1 = Модифицировать ордер ( tick_buy_1 );
   bool mod_Buy2 = Модифицировать ордер ( tick_buy_2 );
   bool mod_Buy3 = Модифицировать ордер ( tick_buy_3 );
 
OK,AlexeyVik I thinkglobal variables should work - I'll try it with them. Thank you.
Reason: