orderselect orderselect

 

hey all..... please don't spend undue time on this, but perhaps someone might know offhand.....

a trade management ea manages all trades on all pairs.... sometimes the orders per pair might reach a hundred.... think of like grid trading..... the number of trades roughly correlates to the recent move in the market..... my goal is to lower the trailing stop value as the number of trades increases......

i've tried to think it out and code it out to no avail....... yet.....

in the trailallorders function i need to count the orders for the current pair selected in order to determine the stop value..... i've tried to count a pair first and secondly select those for potiental modification, a dual orderselect.....

does anyone have expierence doing such........ orderselect following orderselect within a single function.....

and again, please don't spend nonspare time ...... i'll eventually see my error and get it.......thanks......h

 

hey,

you could probably loop through all the orders once and count them by pairs separately (for example in array with counter for every pair)...

another way could be to select an order, then do the count you need selecting all the orders you need one-by-one and finally again select the first (the original) order...

hope the above helps

thank you

Automated ( )

--

 

my goal is to lower the trailing stop value as the number of trades increases......

extern M = 1;
extern B = 10;
//...
int SL=M * OrdersTotal() + B;
for(int index = OrdersTotal() - 1; index >= 0; index--) if (
   OrderSelect(index, SELECT_BY_POS)			// Only my orders w/
&& OrderMagicNumber()	== MagicNumber + Period.index	// my magic number
&& OrderSymbol()	== Symbol() ) {			// and period and symbol
   ordermodify ( ... Bid-SL*pips2dbl ...);
      
 

hey automated...... thanks for the reply....... that is similar to what i have been trying but have yet to get it to work.... what i'm doing now is to prespecify the symbol and the count of orders of that symbol ......but that requires 20 lines of code....no biggie of course, i was just trying to get it to one line...... example below.....h

  TrailAllOrders(TrailingStopStart,TrailingStop,"EURUSDm",Count("EURUSDm"));
  TrailAllOrders(TrailingStopStart,TrailingStop,"AUDUSDm",Count("AUDUSDm"));
  TrailAllOrders(TrailingStopStart,TrailingStop,"USDJPYm",Count("USDJPYm"));
  TrailAllOrders(TrailingStopStart,TrailingStop,"GBPUSDm",Count("GBPUSDm"));
  TrailAllOrders(TrailingStopStart,TrailingStop,"USDCADm",Count("USDCADm"));  // this requires all 20 pairs singely

//----

//---

hey whr..... thanks for the reply..... i was not clear.... it's not orderstotal() i'm interested in but the total orders for the particular symbol that orderselect has chosen in the ..... as example if there are 20 eurusd orders open the trailingstop might be 100, but once there are 200 eurusd orders open the 'eurusd' trailingstop will move to 50..... this change will have no impact on the other pairs....

the single ea is placing trades on all 20 pairs and managing those orders...... the code above is how i do it now, i was just trying to reduce it......h

Reason: