FOREX - Trends, forecasts and implications 2016 - page 721

 
Vladimir Zubov:

Rena ! The joke with real, I can't have an opening on one candle, there's an iron check there. Why is there such a situation because of the gap in the candlesticks? I even have not got the opening symbol in the screenshot, but the terminal closed the position.

As a version...

First, the 5-digit symbol means a lot of ticks and the number of times the same algorithm is executed. It is correct that an error may occur at a GEP due to a sharp change in the opening price of an order. The order did not open, the algorithm did not handle the error and the second order follows. And the first one might have been opened after the first one. Look at the time of order opening.

 
new-rena:

Like a version of...

First of all, it is a 5-digit value, which means a lot of ticks and the number of times the same algorithm is executed. It is correct that an error may occur at a GEP due to a sharp change of order open price. The order did not open, the algorithm did not process the error and here is the second order.

Version of what? MT4 988

Code under #property strict

I only process the first tick of a candlestick opening, is this construction correct ?

//=============== Переменные =========================================

int prev_time = 0; // Working with candlestick open prices

void OnTick()

{//Start-

// ======= Work on candlestick open prices ============================

if ( Time[0] <= prev_time ) {return;}

prev_time = (int)Time[0];

}//Start End-.

 
Vladimir Zubov:
Version of what ? MT4 988
Version of the cause of the chip you described.
 
Vladimir Zubov:

...

Code under #property strict

This is code error checking, not OrderSelect error handling. Do you have an OrderSelect error handling function in your code?
 
new-rena:
This is checking for errors in the code, not for OrderSelect command processing errors. Do you have OrderSelect error handling in your code?

added as a candlestick, maybe that's it ?

But there were no discos and no restart of the terminal. When restarting, I know that the method is not correct, may open in the middle of a candle, but on M1 it is not so important, and there was no restart.

 
new-rena:
This is a check for errors in the code, not for OrderSelect command processing errors. Do you have OrderSelect error handling in your code?

OrderSelect is my guardian for Kim's functions, so that there is no opening on the candle, it seems to be no problem there.

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает номер бара открытия последней позиции или -1.       |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ("" или NULL - текущий символ)          |
//|    tf - таймфрейм                  (    0       - текущий таймфрейм)       |
//|    op - операция                   (   -1       - любая позиция)           |
//|    mn - MagicNumber                (   -1       - любой магик)             |
//+----------------------------------------------------------------------------+
int NumberOfBarOpenLastPos(string sy="0", int tf=0, int op=-1, int mn=-1) {
  datetime t=0;
  int      i, k=OrdersTotal();

  if (sy=="" || sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) t=OrderOpenTime();
            }
          }
        }
      }
    }
  }
  return(iBarShift(sy, tf, t, True));
}
//End

This is not about the function, but about the nuances of working in the real world.

 
Vladimir Zubov:

added as a candlestick, maybe that's it ?

But there were no discos and no restart of the terminal. When restarting I know the method is not correct, may open in the middle of a candle, but on M1 it is not that important and there was no restart.

You will have this every tick. Use iTime(...PERIOD_XX...). If you do it that way, it will work only on opening of candle of that TF you've specified. However, if the command to open/close the order returns an error, the robot will give it again in a new candlestick.

Or iTime(...Period()...). - This is on the current TF, i.e. the one on the chart where the EA is

 
Vladimir Zubov:

OrderSelect is my guardian for Kim's functions, so that there is no opening on the candle, it seems to be no problem there.

It's definitely not about the function, but about the nuances of working on the real.

charge....

I don't need it for real...

 
new-rena:

charcoal scaffolding....

I don't need this on the real...

1. how to make a new candlestick control so that one iteration is at the first tick ?

I seem to have this code working to control the triggering on the opening of the candle :(

2. Why not, it's about Kim's function to determine the bar of an open position ?

P/S Turned MT4 now I have to write everything all over again ...

 
new-rena:

you'll have this every tick. Use iTime(...PERIOD_XX...). If you do this, it will only work at the opening of the candle of the TF you specify. However, if the command to open/close the order returns an error, the robot will give it again in a new candlestick.

Or iTime(...Period()...). - it's on the current timeframe, i.e. on the chart where the EA is

I downloaded the code from the example here five years ago, but now everyone is "smart" and is only cursing and fighting for freelancing and market...

How to determine the opening of a candle in a new and correct way ?