[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 158

 
Xaoss1990:

Help, please... I've been struggling for days....

Where's the code? How can I help?
 
Roger:
Where's the code? How can I help?

Here is part of the code where we make deals:

//+------------------------------------------------------------------+
//+----------------------CLOSE A POINT---------------------+
//+------------------------------------------------------------------+
if (POINT_BUY_M15 >= Strgh_UP_M15 &&& POINT_BUY_H1 >= Strgh_UP_H1 && POINT_BUY_H4 >= Strgh_UP_H4 && OrdersTotal() == 0)
{
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 5, 0, 0, "My order #", 111, 0, Blue);
if(ticket < 0)
{
Print("Order not set. Error - #",GetLastError());
return(0);
}
}

//+------------------------------------------------------------------+
//+-------------------------СТАВИМ СПОП ЛОСС-------------------------+
//+------------------------------------------------------------------+
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
Magic = OrderMagicNumber();

if (POINT_BUY_M15 < Strgh_UP_M15 || POINT_BUY_H1 < Strgh_UP_H1 || POINT_BUY_H4 < Strgh_UP_H4 && OrdersTotal() == 1 && Magic == 111 && OrderType( ) == 0)
{
close = 1;
}
if (close == 1)
{
if (OrderClose(OrderTicket(), lots, Bid, 5, Yellow) == true) Alert("OrderTicket() = ", OrderTicket(), ", lots = ", lots, ", Bid = ", Bid);
else Print ("Stop not set;)

}

//+------------------------------------------------------------------+
//+----------------------CONCLAIM SALE---------------------+
//+------------------------------------------------------------------+
if (POINT_SELL_M15 >= Strgh_DOWN_M15 && POINT_SELL_H1 >= Strgh_DOWN_H1 && POINT_SELL_H4 >= Strgh_DOWN_H4 && OrdersTotal() == 0)
{
ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 5, 0, 0, 0, "My order #", 222, 0, Green);
if(ticket < 0)
{
Print("Order not set. Error - #",GetLastError());
return(0);
}
}
//------------------------------------------------Print parameters to select----------------------------------------------------
//Print("Sell M15 = ", POINT_SELL_M15, ", Sell H1 = ", POINT_SELL_H1, ", Sell H4 = ", POINT_SELL_H4, ", order number = ", ticket);
//------------------------------------------------Печать параметров на выбор----------------------------------------------------

//+------------------------------------------------------------------+
//+-------------------------СТАВИМ СПОП ЛОСС-------------------------+
//+------------------------------------------------------------------+
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
Magic = OrderMagicNumber();

if (POINT_SELL_M15 < Strgh_DOWN_M15 || POINT_SELL_H1 < Strgh_DOWN_H1 || POINT_SELL_H4 < Strgh_DOWN_H4 && OrdersTotal() == 1 && Magic == 222 && OrderType( ) == 1)
{
close = 1;
}
if (close == 1)
{
OrderClose(OrderTicket(), lots, Ask, 5, Red);
}

 
This is not the part of the code where there could be an error.
 
Roger:
This is not the part of the code where there could be an error.

em.... and the rest of the code is calculating values ( POINT_BUY_M15, POINT_BUY_H, POINT_BUY_H4, POINT_SELL_M15, POINT_SELL_H, POINT_SELL_H4 ) to make trades, it works correctly... I checked. it's simple there....

 
If the error was here, the logs would say "Stop not set", but this is not the case.
 
Please advise. An order was opened by a certain condition and closed by trawl. How can I make a position not to be opened again on this candle if the condition is true.
 

A condition in the init function is being checked:

...
extern int proc_zahlest=50;

int init() 
{
if (proc_zahlest>100)
{
Alert("Параметр proc_zahlest д.б. <100% !!!");
}
return(0);
}

How to stop the indicator from running (prevent the start function from running) if proc_zahlest>100

 
prom18:
Please advise. An order was opened by a certain condition and closed by trawl. How can I make a position not to be opened again on this candle if the condition is true.


If only one order can be opened, it is easy

start()
{
static int newbar;
if(newbar==Time[0])return(0);
if(OrdersTotal()>0)newbar=Time[0];
...
 
Roger:


If only one order can be opened, it is easy

Please explain in words the logic of what is written.
 
prom18:
Please explain in words the logic of what is written.

When an order is opened, the newbar variable is assigned the value of the time of the current bar opening. On the next ticks, up to the new bar, the EA will be blocked. If the order hasn't been closed yet, the operation repeats. And so we keep doing it until the order closes. Then on the next bar, the Expert Advisor is ready for new openings.