[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 215

 

And still, how to limit the number of open orders in the EA, because it opens them like a snowball?

 
stalkertula:

And still, how to limit the number of open orders in the EA, because it opens them like a snowball?

1. Checked the necessity of setting an order, if yes.

2. Check the number of existing orders, if yes, then...

3. Checked the time elapsed since the previous order was set (or any other delay criteria), if yes, then...

4. Placed an order.

In general, it goes something like this...

Although... each of these items includes various other checks needed to correct the order setting parameters (to avoid an error returning from the DC)

Tip:
When you decide to place an order or open a position, what are your own criteria?
Now ask yourself the question: "Why don't I let my EA evaluate all the criteria for my decision like I do?
Once you have taken into account all the criteria in your EA, you will reduce logical errors considerably...

Take it as a rule to first describe all the logic of this or that program block on a piece of paper (there's nothing wrong with that, on the contrary - it helps),
and then translate it into code.

 
artmedia70:

1. Checked whether a warrant needs to be installed, if so

2. Check the number of existing orders already in place, if yes, then...

3. Checked the time elapsed since the previous order was set (or any other delay criterion), if yes...

4. Placed order.

In general, it goes something like this...
Although... each of these points also includes various necessary checks to correct the order setting parameters (to avoid an error returning from the DC)

Thank you for your reply, but the algorithm is written in Russian, but in mql, I'm not strong, at least a tip on the functions which fixed the number (the number of prescription in the settings) open orders sell/buy, and then the signal to prohibit placing a sellstop/buystop.

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

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();

}
 
Roman.:

I test EAs on the opening prices of a new bar (for this I need to specify in the EA code the control for the formation of a new bar)
I try to modify stops in a tickwise manner. Roman, what are the disadvantages of this modification, apart from missing modification arrows?
 

when pasting the indicator, the terminal hangs and writes the same thing in the logs: unknown subwindow number -1 for ObjectCreate function

I have the index of a window with the name of this indicator in all ObjectCreate(x=WindowFind(short_name); ObjectCreate("fut "+i,OBJ_TREND,x,0,0,0);)

It's always worked before... I don't understand why it's like this.

 
eddy:

when I insert an indicator, the terminal hangs and writes the same thing in the log: 15:18:16 RSI EURUSD,M15: unknown subwindow number -1 for ObjectCreate function

I have an index of a window with the name of this indicator in all ObjectCreate (WindowFind(indikator_name), for example, ObjectCreate("fut "+i,OBJ_TREND,x,0,0,0);

it's always worked before... I don't understand why it's like this

It may be because ObjectCreate is called from init(). In this case the window search may return -1 even if the indicator name is correct.
 
that's what he's doing... thank you
 
I can't understand it.
2011.03.07 15:49:40     2011.01.19 10:50  RSI-тралинг EURUSD,H1: OrderSend error 131

This is on Alpari...with floating spread...but the fixed spread works fine...

I read about the error, i put all volumes and 1 lot and 0.1 lot and 0.01 lot.....pis the same error((((((

 
Vovo4ka:
I can't understand it, it says.

This is on Alpari...with floating spread...but the fixed spread works fine...

I read about the error, I put all volumes and 1 lot and 0.1 lot and 0.01 lot.....pis the same error((((((

On a code of the error, you can learn the direction in which to dig. But without the code no one will tell you where this error is coming from.

 
Vovo4ka:
I can't understand it.

This is on Alpari...with floating spread...but the fixed spread works fine...

I read about the error, i put all volumes and 1 lot and 0.1 lot and 0.01 lot.....pis the same error((((((


Write the code.
Reason: