[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 213

 
Sergey_Rogozin:

I've already figured it out. Just looked at it inattentively at first.

I don't see the error.

I wonder then why orders are not deleted? I can post the code for the whole EA, but would that make sense?
 
dzhini:
I wonder then why the orders are not deleted? I can lay out the code of the entire EA, but would that make sense?

Try just writing your conditions in the start. In my opinion, you don't need the above for() loop in the start.


      if(CalculateCurrentOrders(Symbol())>0) {Alert(CalculateCurrentOrders(Symbol()));ClosePendingOrder(OP_SELLLIMIT);} // (1) 
      if(CalculateCurrentOrders(Symbol())<0) {Alert(CalculateCurrentOrders(Symbol()));ClosePendingOrder(OP_BUYLIMIT);} //(2) 
      if(TimeCurrent() - OrderOpenTime()>=HowManyHours*60*60) {ClosePendingOrder(OP_BUYLIMIT);ClosePendingOrder(OP_SELLLIMIT);} //(3

It's enough to just set them at the start.

 

Hehehe... That's exactly what it's not. So how would it go through the orders without a cycle? Since we are assuming that there could be a large number of orders and we want to avoid using magic symbols as individual tags, the main tags are currency symbol and order type. Basically, it works with those, but we accidentally discovered that it would not work with the above combination. I cannot understand where the error is. And if I can't figure it out, I'm going to the real experts.

If you're really interested, I can post the owl code... let's have a look at it... it'll be useful.

 
dzhini:

Hehehe... That's exactly what it's not. So how would it go through the orders without a cycle? Since we are assuming that there could be a large number of orders and we want to avoid using magic symbols as individual tags, the main tags are currency symbol and order type. Basically, it works with those, but we accidentally discovered that it would not work with the above combination. I cannot understand where the error is. And if I can't figure it out, I'm going to the real experts.

If you're really interested, I can post the owl code... let's take it apart... ...it'll be useful.

I'm too lazy to look into it now.

You have a loop with selection by operation type and symbol set in the function,

and in the start you prescribe only those conditions, on fulfillment of which the action you need is executed, i.e. ClosePendingOrder(OP).

Or you can search through the orders by magician with the execution of the order satisfying the condition .

 

Guys, set up foreign brokerage companies...very big money and don't want to pay taxes....)) who work on Metatrader 4...))

 
Vovo4ka:

Guys, set up foreign brokerage companies...very big money and don't want to pay taxes....)) who work on Metatrader 4...))

There are a lot of them.

Google will lead you to them easily.

Pay your taxes and sleep well...

 

Afternoon. Please, advise how to "force" the EA to stop placing pending orders if i already have 5 Buy and 5 Sell market orders open and as soon as at least one of the orders closes, the EA keeps placing pending orders in the direction the order has closed, and so on in the cycle. (Now, I have already posted the code in a correct form)

//----------------------------------------------------------------------- проверка установленных стоп ордеров

double StopOrderUp,StopOrderDn,price,MinBuyOrder=1000000000,MaxSellOrder,OldBuyOrder,OldSellOrder,OldBuyLot,OldSellLot;

int TicketUp,TicketDn;

TimeOllOpenBuy=0;TimeOllOpenSell=0;

double OOL_BUYSTOP,OOL_SELSTOP;

for (i=0; i<OrdersTotal(); i++)

{

if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)

{ price = OrderOpenPrice();

if (Magic==OrderMagicNumber() && OrderSymbol()==Symbol())

{

if (OrderType()==OP_BUYSTOP ) {StopOrderUp = price; TicketUp=OrderTicket(); OOL_BUYSTOP=OrderLots();}

if (OrderType()==OP_SELLSTOP) {StopOrderDn = price; TicketDn=OrderTicket(); OOL_SELSTOP=OrderLots();}

if (OrderType()==OP_BUY )

{ TimeOllOpenBuy = TimeOllOpenBuy + TimeCurrent()-OrderOpenTime();

if (MinBuyOrder > price) MinBuyOrder = price;

OldBuyOrder=price;

OldBuyLot=OrderLots();

if (DrawInfo&&!IsTesting()){

NameLine="ордер Bay "+OrderTicket();ObjectDelete(NameLine);ObjectDelete(NameLine+" з");

ObjectCreate(NameLine, OBJ_TREND, 0, OrderOpenTime(),price,Time[0],Bid);

ObjectSet(NameLine, OBJPROP_COLOR,LightSkyBlue);

ObjectCreate(NameLine+" з",OBJ_ARROW,0,Time[0],Bid,0,0,0,0);

ObjectSet(NameLine, OBJPROP_STYLE, STYLE_DOT);// Стиль

ObjectSet(NameLine, OBJPROP_RAY, false); // Луч

ObjectSet(NameLine+" з",OBJPROP_ARROWCODE,3);ObjectSet(NameLine+" з",OBJPROP_COLOR,WhiteColor);}

}

if (OrderType()==OP_SELL)

{ TimeOllOpenSell = TimeOllOpenSell + TimeCurrent()-OrderOpenTime();

if (MaxSellOrder < price) MaxSellOrder = price;

OldSellOrder=price;

OldSellLot=OrderLots();

if (DrawInfo&&!IsTesting()){

NameLine="ордер Sell "+OrderTicket();ObjectDelete(NameLine);ObjectDelete(NameLine+" з");

ObjectCreate(NameLine, OBJ_TREND, 0, OrderOpenTime(),price,Time[0],Ask);

ObjectSet(NameLine, OBJPROP_COLOR,Pink);

ObjectCreate(NameLine+" з",OBJ_ARROW,0,Time[0],Ask,0,0,0,0);

ObjectSet(NameLine, OBJPROP_STYLE, STYLE_DOT);// Стиль

ObjectSet(NameLine, OBJPROP_RAY, false); // Луч

ObjectSet(NameLine+" з",OBJPROP_ARROWCODE,3);ObjectSet(NameLine+" з",OBJPROP_COLOR,WhiteColor);}

}

}

}

}

if (MinBuyOrder==1000000000 && MaxSellOrder==0 && OOL_BUYSTOP!=OOL_SELSTOP)//если серия закрылась

{

DELETEORDERS();

}
 

Guys, another question has arisen. Some brokers, including Alpari, for example, offer their clients a floating spread .... in connection with this my advisor does not work...(((

They have a floating number that just spoils the whole thing...((((

 
What's the question? Redo the EA...
 
eddy:
What's the question? Redo the EA...


That's the question, remaking it works everywhere, but not with the floating one((

Reason: