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

 
trader117:
Good afternoon. How can I calculate a single Stop Loss for a series of orders with exact magic numbers, so that this series of orders can close at breakeven. For example, there are 3 orders: 1 Buy lot 1.3320 with magic 1, 1 Buy lot 1.3345 with magic 2 and 1 Buy lot 1.3360 with magic 3. How should I calculate the total Stop Loss for all orders so that if there is a move against the price the orders are closed without losing?
What is the reason of averaging the Stop Loss? As soon as one position is closed by a SL, all other positions are immediately closed by Close! No need to lose precious pips!
 
borilunad:
What is the point of averaging StopLoss? As soon as I close one position at SL, the others are immediately closed at Close! No need to lose precious pips!

On the one hand, yes, but on the other hand I see an immediate vulnerability: an order may not be closed by an EA for many reasons, and a Stop Loss will be closed anyway, otherwise this is a serious reason to complain to the broker. + Disconnection will not allow an order to be closed. Anyone else have any ideas to implement this algorithm for the total SL for the order pyramid?
 
trader117:

On the one hand yes, but I see an immediate vulnerability in the fact that closing an order by an EA may not be executed for a variety of reasons, and a stop loss will close anyway, otherwise this is already a serious reason for a claim against the broker. + Disconnection will not allow an order to be closed. Who else has ideas to implement this algorithm for common SL for a pyramid of orders?
I'm not saying don't put SL on others! They will close and you will lose even less than the average SL! So, on the Real, you will not close at the same time, but one by one! Therefore, economical to close the rest of Close after closing one position on SL! Yes, and weigh the code uchuchitimo, because SL established repeatedly, and each time to conduct the calculation of the averaging? And every time you add a position, again recalculate and reset the SL, and I repeat, you will only lose on it, not win!
 

I can't get a handle on it, I don't know what the problem is. The task is as follows: find the bar of a given time on the minutes. If the time has not yet arrived, look for it in yesterday, otherwise look for it in today's day. I have written the following script:

#property show_inputs

extern string time = "15:25";
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   string comment = StringConcatenate(" TimeCurrent = ", TimeCurrent(),
      "\n TimeToStr(TimeCurrent) = ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES));
   datetime d_time = StrToTime(time);
   comment = StringConcatenate(comment,
      "\n d_time = ", d_time,
      "\n TimeToStr(d_time) = ", TimeToStr(d_time, TIME_DATE|TIME_MINUTES));
   int delta_time = TimeCurrent() - d_time;
   comment = StringConcatenate(comment,
      "\n delta_time = ", delta_time);
   if(delta_time < 0){
      d_time -= 60*60*24;
      comment = StringConcatenate(comment,
         "\n\n delta_time < 0");
   }else{
      comment = StringConcatenate(comment,
         "\n\n delta_time > 0");
   }
   //
   comment = StringConcatenate(comment,
      "\n\n d_time = ", d_time,
      "\n TimeToStr(d_time) = ", TimeToStr(d_time, TIME_DATE|TIME_MINUTES));
   delta_time = TimeCurrent() - d_time;
   comment = StringConcatenate(comment,
      "\n delta_time = ", delta_time);
   double d_delta_time = delta_time;
   double value = d_delta_time/60;
   int start = MathCeil(value);
   datetime sought_time = iTime(Symbol(),PERIOD_M1,start);
   comment = StringConcatenate(comment,
      "\n\n value = ", DoubleToStr(value, 3),
      "\n start = ", start,
      "\n sought_time = ", sought_time,
      "\n TimeToStr(sought_time)= ", TimeToStr(sought_time, TIME_DATE|TIME_MINUTES));
   Comment(comment);
//----
   return(0);
  }

This is what it outputs:

The algorithm there is as follows. We look at the difference between the current time and the given time, and if it is less than zero, we shift a day back. Then we divide the difference by 60 and round upwards, this will be the number of the bar on M1 and look at its time. It does not coincide with the one set in the externs. Where is this algorithmic error?

 
gyfto:

I can't get a handle on it, I don't know what the problem is. The task is as follows: find the bar of a given time on the minutes. If the time has not yet arrived, look for it in yesterday, otherwise look for it in today's day. I have written the following script:

This is what it outputs:

The algorithm there is as follows. We look at the difference between the current time and the given time, and if it is less than zero, we shift a day back. Then we divide the difference by 60 and round upwards, this will be the number of the bar on M1 and look at its time. It does not coincide with the one set in the externs. Where is this algorithmic error?

Volatility is low at night, there are minutes when not a single trade goes through, so there is no bar. Look at the history to see if all the bars are present.
 
Roger:
Look at the history to see if all the bars are present.


You can cycle from the found value in while() to the bar you are looking for. I'll give it a try.
 
gyfto:

I can't get a handle on it, I don't know what the problem is. The task is as follows: find the bar of a given time on the minutes. If the time has not yet arrived, look for it in yesterday, otherwise look for it in today's day. I have written the following script:

This is what it outputs:

The algorithm there is as follows. We look at the difference between the current time and the given time, and if it is less than zero, we shift a day back. Then we divide the difference by 60 and round upwards, this will be the number of the bar on M1 and look at its time. It does not coincide with the one set in the externs. Where is this algorithmic error?

Are you practising, or did iBarShift() not like it?
 
TarasBY:
Practising, or didn't like iBarShift()?
I'm an idiot.
 
Please give me the number/address of the demo server for MT4 from MetaQuotes. I have just downloaded MT4 from MetaQuotes website and it is on TeleTrade-Demo (Company Teletrade D.J.), but I want to connect to MQ and work on their quotes.
 
Greetings all, a question: is it possible to open a position at bar closing (working on 15-minute bars), if yes, how to do it with mt4?
Reason: