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

 
AlexeyVik:

Almost everything can be programmed, and this algorithm all the more so.

Only one problem in the algorithm (highlighted in bold), it may happen that it will not be equal for a very long time (maybe several years). That is why in this case we should not place the check condition equal ==, but equal to or greater than =>. At the same time, after opening an order, we should prohibit opening further orders, which makes the head boil.

That's the point is that I need exact comparison ==, not how many years to wait why if I output for example in my comment the price of order Buy and price Bid and these variables coincide at some moments but the comparison condition == is not fulfilled: Is it POSSIBLE to program this algorithm? My head is boiling for the third week!
 

the archive has been dealt with. Can you tell me please:

1. is it possible to include more than one EA on the same chart?

2. or advisor+script?

3. is it necessary to put on the chart of the instrument exactly the TF that is used by the Expert Advisor? if so, what will happen otherwise?

4. is it necessary to put in the instrument window the indicator used by the Expert Advisor? if yes, what will happen otherwise?

5. if the EA uses multicurrency, is it necessary to open all windows with these currency pairs?

 
m8akca:
The point is that I need an exact comparison ==, not how many years to wait why if for example in the comment I output a Buy order price and a Bid price and these variables coincide at some points, but the comparison condition == is not fulfilled: Is it POSSIBLE to program this algorithm? My head is boiling for the third week!
Because the price may be _Point more or less and it is no longer equal.
 

Could you please suggest a function that counts the amount of the last series of losing trades in a row. If TakeProfit is triggered, it will reset the counter to zero.

 

Hello all, Dear! Please tell me if there is a network, or maybe someone has time to write an advisor, for the following parameters. 1) specify the direction of buying (selling), and the price of this purchase (sale). 2) I specify the stop size. 3) I put for example three price levels, at which a part of the lot size should be closed. For example, I expose the order to sell at $ 1, in the parameters of the adviser specifies how much % (or how much volume) close at 1.2, how much % (or how much volume) at 1.3 and the balance at 1.4.

 
ara66676:
Let's say, it was important for me to determine the time, 10 seconds before the close of each five minutes, and since the analysis includes 28 currency pairs, this bar will be for some currency pair, and the number of ticks in my case does not matter.

Then it's simpler like this:

datetime TSec; // Current time in seconds from the start of the last five minutes

TSec = TimeCurrentl() % 300; // Remainder of division. It can be compared to 290 = 5 minutes - 10 seconds.

In case of a disconnection from the server, the last known time TimeCurrent will not change, lagging behind the real time. If there is confidence in the system timer running on the terminal computer, for example, when the computer's time is automatically synchronized with the astronomical time of the operating system (1-2 seconds error) or otherwise, it is better not to use the last known server time (the time of the last arrival of quotes), but the computer time datetimeTimeLocal(). This time is also counted from 1970.01.01 0:00:00 in seconds and is suitable for measuring 5 minutes and 10 seconds, the difference between computer and server time zones is not important. Then

TSec = TimeLocal() % 300;

 
Vlad143:

Then it's simpler like this:

datetime TSec; // Current time in seconds from the start of the last five minutes

TSec = TimeCurrentl() % 300; // Remainder of division. It can be compared to 290 = 5 minutes - 10 seconds.

In case of a disconnection from the server, the last known time TimeCurrent will not change, lagging behind the real time. If there is confidence in the system timer running on the terminal computer, for example, when the computer's time is automatically synchronized with the astronomical time of the operating system (1-2 seconds error) or otherwise, it is better not to use the last known server time (the time of the last arrival of quotes), but the computer time datetimeTimeLocal(). This time is also counted from 1970.01.01 0:00:00 in seconds and is suitable for measuring 5 minutes and 10 seconds, the difference between computer and server time zones is not important. Then

TSec = TimeLocal() % 300;

thanks, also useful .
 
Please advise how to interrupt the summation of unprofitable positions
    Подскажите, пожалуйста, как прервать суммирование убыточных позиций при срабатывании Тейкпрофита. После заново считать.
    
    Использую функцию Кimа 
    
     double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1,  datetime dt=0)
{
  p=0;
  int    i, k=OrdersHistoryTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
      if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (mn<0 || OrderMagicNumber()==mn) {
            if (dt<OrderCloseTime()) {
             
             if(OrderProfit()<0){
              p+=OrderProfit();
            }
          }
        }
      }
    }
  }
 }
  
  return(p);
 
Neron_plus34:
Please advise how to interrupt the summation of unprofitable positions
if(dt<OrderCloseTime()) {
   if(OrderProfit()<0) p+=OrderProfit(); 
   else break;
   }
 
artmedia70:

And you need to be very specific about what you want to redraw.

You may have to recalculate all of the indicator buffers.
We have to experiment with the indicator's behavior and its response to external changes of its internal variables.

Honestly, I've never tried this (no... well, I've certainly done it, and many times made indicators that react to events and draw what's required. But I originally used a non-standard approach for drawing buffers). Make a test indicator, which draws something (at least two or three points on the screen on the nearest bars) and try to change its buffer value using events. If it changes - this is one way to work with your indicator, if not - this is another approach to be considered. Maybe you have to move all calculations to a timer, or directly in OnChartEvent() do one cycle of recalculation after the desired event is detected...

In short - experiments are needed...

Thank you!

Reason: