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

 
evillive:
iHighest, iLowest will give the candle address, not the price.

That's right. We need

double Vhod1=iHigh(Symbol(), 0, iHighest(Symbol(),0,MODE_HIGH,8,0));

double Vhod2=iLow(Symbol(), 0, iLowest(Symbol(),0,MODE_LOW,8,0));

 
alvlaf:


I put it in wrong, but it still wouldn't have worked properly because... Because.) Anyway, it should go like this:

1) create an AllowNewOrders variable in the inite (if it doesn't exist)

2) Create a new order, until it closes, OnTick of this symbol is idle, but will run OnTick of another symbol

3) Perform step 2 for the other symbols until the MaxOpenOrders limit is reached

4) when the order finishes, if it is losing or has zero value, prohibit opening new orders for all copies through AllowNewOrders

[here is the immediate problem - when the losing series finishes, AllowNewOrders=1, but what if MaxOpenOrders>1 and there are several of these sessions?]

5) If point 4 is not fulfilled, then you may open new orders.

The program MUST work when MaxOpenOrders=1. Perhaps, there will be a problem if we forbid new orders following an unprofitable order AllowNewOrders=0 and the next OrderSend, for some reason, does not open the order. I will write below how I hedge for this case...

int OnInit()                     
{
   if (!GlobalVariableCheck("AllowNewOrders")) GlobalVariableSet("AllowNewOrders", 1);
   return(INIT_SUCCEEDED);
}
//----------------------------------------------------------------------
void OnTick()
{
   if (CountTrades() == 0)  // Количество ордеров должно равняться нулю
   {
      if ((TypeLastHistOrder() == OP_BUY && PriceCloseLastHistOrder(OP_BUY) < PriceOpenLastHistOrder(OP_BUY))
      || (TypeLastHistOrder() == OP_SELL && PriceCloseLastHistOrder(OP_SELL) > PriceOpenLastHistOrder(OP_SELL)))
      // Если последняя сделка убыточная, то открывается такая же, но с увеличенным лотом
      {
         GlobalVariableSet("AllowNewOrders", 0);
         Type = TypeLastHistOrder();
         if (Type == OP_BUY)  Price = Ask;
         if (Type == OP_SELL) Price = Bid;
         Lot = NormalizeDouble(LotsLastHistOrder()*Multiplier, 2);
         ticket = OrderSend(Symbol(), Type, Lot, Price, Slippage, 0, 0, IntegerToString(Exp), Magic);
      }
      else GlobalVariableSet("AllowNewOrders", 1);
      if (PriceCloseLastHistOrder() == PriceOpenLastHistOrder() && CountHistTrades() > 0) 
      // Если прибыль последней сделки равняется нулю, то открывается такая же
      {
         GlobalVariableSet("AllowNewOrders", 0);
         Type = TypeLastHistOrder();
         if (Type == OP_BUY)  Price = Ask;
         if (Type == OP_SELL) Price = Bid;
         Lot = NormalizeDouble(LotsLastHistOrder(), 2);
         ticket = OrderSend(Symbol(), Type, Lot, Price, Slippage, 0, 0, IntegerToString(Exp), Magic);
      }
      else GlobalVariableSet("AllowNewOrders", 1);
      if (((TypeLastHistOrder() == OP_BUY && PriceCloseLastHistOrder(OP_BUY) > PriceOpenLastHistOrder(OP_BUY))
      || (TypeLastHistOrder() == OP_SELL && PriceCloseLastHistOrder(OP_SELL) < PriceOpenLastHistOrder(OP_SELL)))
      || CountHistTrades() == 0)
      // Если последняя сделка прибыльная или это первая сделка, то открывается ордер
      {
         if (OrdersTotal() >= MaxOpenOrders || GlobalVariableGet("AllowNewOrders") == 0) return;
         if (SignalBuy())
         {
            ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, IntegerToString(Exp), Magic);
         }
         if (SignalSell())
         {
            ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, IntegerToString(Exp), Magic);
         }
      }
   }
}
 
A13ksandr:

I will write below how I hedge for this eventuality...

int Tries = 5;
ResetLastError();
do
{
   // решение ошибок с предыдущей попытки открытия ордера, например:
   if (_Error == 134)
   {
      _Lot = NormalizeDouble(_Lot / 2, 2);
      if (_Lot < SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN)) _Lot = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN);
   }
   if (_Error == 138) RefreshRates();
   Ticket = OrderSend(Symbol(), OP_BUY, _Lot, Ask, 3, 0, 0, NULL, 0, 0, clrNONE);
   if (Ticket < 0)
   {
      _Error = GetLastError();
      Sleep(100);
   }
   Tries--;
}
while (Ticket < 0 && Tries > 0);

If the error solution is properly foreseen, the success rate of opening an order increases.

 
Hello! Please advise me if I use the function from the post (each order has its own magician) - http://forum.forexpeoples.ru/showthr...=1#post1715092 , how would it look like to find the last orders for sales or purchases, or upgrade a series of orders, if not each order has its own magician, but each series of orders has its own magician. I.e. it is assumed that when a new series of orders with its own magik is opened, the old series of orders continue to open their own orders with their own magiks. Each series is expected to have its own profit and there are a lot of such series of orders.

How can the code below change under such conditions?
for(cnt=OrdersTotal()-1;cnt>=0;cnt--){
if (!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderSymbol()!=Symbol()) continue; if(OrderMagicNumber() < startMagicNumber || OrderMagicNumber() >= startMagicNumber + MaxTrades) continue;

I put the code to generate a magik when opening the first orders of a series, but here is the problem when opening new orders in the same series.

The code itself to generate the magic from the post:
//+------------------------------------------------------------------+
// get the next magic in the series
int getNextMagicNumber(){
int magic = EMPTY;

if (OrdersTotal() == 0) {
return(startMagicNumber);
}

for (int i = startMagicNumber; i < startMagicNumber + MaxTrades; i++){
magic = checkMarketByMagic(i);
if (magic != EMPTY) break;
}

if (magic == EMPTY){
magic = startMagicNumber; // first in the series
} else {
magic++; // next in the series
}

return(magic);
}
//+------------------------------------------------------------------+
// keekkenen: check for an order in the market with a given magic
int checkMarketByMagic(int magic){
for(int i = 0; i < OrdersTotal(); i++){
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderSymbol() != Symbol()) continue;
if(OrderMagicNumber() == magic) return(magic);
}
return(EMPTY);
}
//+------------------------------------------------------------------+
 
Good afternoon gentlemen of the forum,
apologize if I confused the threads, but I have not found the correct place to post the THEME, so do not kick me.

Sometimes, while surfing the Internet for new Expert Advisors, I came across one that I didn't pay attention to, because its description was standard, of which there are many.

If I had not seen or read it, please give me the name, and google will do its job or if I have one, I will take it as a gift. Maybe there is a similar advisor performs similar actions.

I will describe the meaning of the Expert Advisor (there is nothing very sophisticated, what I need now).

Roughly speaking, the job would look like this:

1. Open a position manually, for example buy.
2. The Expert Advisor sets Stop Loss and Take Profit according to the settings.
3. The order is closed at takeprofit - the EA immediately opens another buy and sets the same stoploss and takeprofit until it catches the first stoploss or if there is an ultimate takeprofit.
4. If the position is closed by Stop Loss, the robot does nothing more. The Expert Advisor waits for the next order to be opened manually.

That is all.

I would be very grateful.
 
A13ksandr:


I inserted it wrong, but it still wouldn't work properly, because... Because.) Anyway, it goes like this:

1) create an AllowNewOrders variable in the initem (if it does not exist)

2) Create a new order until it closes OnTick of this symbol is idle, but OnTick of the other symbol will work

3) Perform step 2 for the other symbols until the MaxOpenOrders limit is reached

4) when the order finishes, if it is losing or has zero value, prohibit opening new orders for all copies through AllowNewOrders

[here is the immediate problem - when the losing series finishes, AllowNewOrders=1, but what if MaxOpenOrders>1 and there are several of these sessions?]

5) If point 4 is not fulfilled, then you may open new orders.

The program MUST work when MaxOpenOrders=1. Perhaps, there will be a problem if we forbid new orders following an unprofitable order AllowNewOrders=0 and the next OrderSend, for some reason, does not open the order. I will write below how I am hedging for this case.

Thanks Alexander, I'll check it tomorrow. [hence, the problem immediately - when losing series ends, AllowNewOrders=1, and if MaxOpenOrders>1 and there are several sessions?] If MaxOpenOrders>1 by some value, then in idea AllowNewOrders=1 should also be greater by the same value. But we don't need to bother with this and MaxOpenOrders should be removed at all, because in this version of the program no more than one series is planned anyway.
 
alvlaf:
Thanks Alexander, I will check it tomorrow. [hence the problem immediately - when losing series ends, AllowNewOrders=1, but if MaxOpenOrders>1 and there is more than one session?] If MaxOpenOrders>1 by some value, then in idea AllowNewOrders=1 should also be greater by the same value. But I don't need to bother with it for now and MaxOpenOrders should be omitted altogether, because in this version of the program no more than one series is planned anyway.
I tried it, worked fine for the first five minutes, then I started to open several deals (4) at once and for the same pair with larger lot. Alexander, I don't quite understand how the global variable gets and changes its value in your version?
 

Hi all !

Here is a graphical object on a graph.

Its parameters are time, value , code. The value corresponds to the price at which the object is located.

Is there any way to get its time and value (through a function or something else) ?

\\\\\

Or, in a broader sense, are there any objects (apart from trend lines, Fibonacci lines, Gannets) that enable us to get their time and price instantly?

I need to place some markers on the chart and obtain information from them. Drawing trend lines , fibo, etc... - It's awfully cumbersome and slow...

Thanks for the answers !

PS Just started studying...

 
ilmel:

Hi all !

Here is a graphical object on a graph.

Its parameters are time, value , code. The value corresponds to the price at which the object is located.

Is there any way to get its time and value (through a function or something else) ?

\\\\\

Or, in a broader context, are there any objects (apart from trend lines, Fibonacci lines, Gannets) that can be immediately derived at time and price?

I need to place some markers on the chart and obtain information from them. Drawing trend lines , fibo, etc... - It's awfully cumbersome and slow...

Thanks for the answers !

PS Just started studying...

https://docs.mql4.com/ru/objects/objectgetdouble
https://docs.mql4.com/ru/objects/objectgetinteger
 
alvlaf:
I tried it, the first five minutes worked fine, then I started opening several trades simultaneously (4) and on the same pair with an increased lot. Alexander, I'm not quite clear in your version, how does the global variable get and change its value?
So, start successively. First, test all possible trades on one pair, and then run it on several pairs. (4) is the number of trades?
When the EA is started, the variable is assigned 1, if there is no such variable (in your case there certainly is, as it is stored for 4 weeks). At every tick this variable allows or disallows new trades - that is its only meaning. If a trade is losing or non-profitable, AllowNewOrders=0, if not - 1. Before checking for Buy/Sell signals, this variable is checked and the loop is removed from the loop, without opening any order. If 4 orders on one symbol are opened, moreover with bigger lot, CountTrades obviously does not work. I cannot check it myself, as the Internet is very very bad where I am. And by the way for me on Grand Capital options on any timeframe a new tick comes only with a new candle - is it the same for you?