How to protect yourself against copying long trades from the tester - page 3

 
George Merts:
Yeah, I get that. But again, in the strategy tester - you get ticks sequentially, and you don't know when you will have the last tick.
You can know the time of the first bar (start), and the number of bars in the symbol's history, that's enough.
 

dll is not needed

Inite there is something you can do to pull the first bar and the number of bars by character(any). But this is for old build. And I do not know whether it will work in the tester. But I have access to history in MT4 without dll

int init()
{
        int    _GetLastError = 0, cnt_ticks = 0, cnt_bars = 0, temp[13];
        // запоминаем символ графика, обнуляем хэндл окна off-line графика
        _Symbol = Symbol();
   hwnd = 0;

        // открываем файл, в который будем записывать историю
        string file_name = StringConcatenate( "!Eqv", _Symbol, TicksInBar, ".hst" );
        int sd_=iBars("!Eqv"+ _Symbol,TicksInBar)-1;
   double Open_[],
          Close_[],
          High_[],
          Low_[];
   int Time_[];
   ArrayResize(Open_,sd_+1);
   ArrayResize(High_,sd_+1);
   ArrayResize(Low_,sd_+1);
   ArrayResize(Close_,sd_+1);
   ArrayResize(Time_,sd_+1);
        for(int sd=iBars("!Eqv"+ _Symbol,TicksInBar)-1;sd>=0;sd--)
        {
           Time_[sd]=iTime("!Eqv"+ _Symbol,TicksInBar,sd);
           Open_[sd]=iOpen("!Eqv"+ _Symbol,TicksInBar,sd);
           Close_[sd]=iClose("!Eqv"+ _Symbol,TicksInBar,sd);
           High_[sd]=iHigh("!Eqv"+ _Symbol,TicksInBar,sd);
           Low_[sd]=iLow("!Eqv"+ _Symbol,TicksInBar,sd);
           //Print(sd," ",GetLastError()," ",Time_[sd]," ",Low_[sd]," ",High_[sd]," ",Close_[sd]," ",Open_[sd]);
        }

        return(0);
}
 
Alexandr Bryzgalov:
You can find out the time of the first bar(start), and the number of bars in the symbol history, that's enough.

In the strategy tester, the time of the first bar is the time of the incoming tick. And it will constantly increase with the arrival of ticks in the strategy tester.

A concrete example:

-----------------------------------------------

The current date is 1.05.2015, we start the strategy tester for the last year. On the first tick in the strategy tester, we will get the zero bar time of 1.1.2015. Although, the real time on the computer is 1.5.2015. As the ticks come in the strategy tester - the date will shift, and the zero bar as well.

Using file operation, we can get that even though our last (zero bar) has a date of 1.1.2015, the real time is 1.05.2015. Accordingly, we process ticks in the tester only up to 1.04.2015.

As new real days come - in the tester we will get more and more later date, and, accordingly, process ticks further and further, but not closer than a month to the real date.

Now - the user has decided to cheat us, and set the date on the computer six months ahead. Now, in the tester, together with the date 1.05.2015 we will get the date 1.11.2015, and the ticks will be processed until 1.10.2015, despite the fact that the real date - still 1.05.2015, and in the terminal really data only to this date. However, there is no way we can get this value from the tester at the beginning of the test.

This is the problem.

That is, if we could get the real last date of the timeseries recorded in the tester from the tester - the problem would be solved. But the problem is that it's not clear how to do it.

 
Alexandr Bryzgalov:

dll is not needed

Inite there is something you can do to pull the first bar and the number of bars by character(any). But this is for old build. And I do not know whether it will work in the tester. But I have access to history in MT4 without dll

In Inite the date will be 1.01.2015 and accordingly all bars will be pulled only from this date. Although, the real date is 1.05.2015
 
George Merts:

In the strategy tester, the time of the first bar is the time of the incoming tick. And it will constantly increase with the arrival of ticks in the strategy tester.

A concrete example:

-----------------------------------------------

The current date is 1.05.2015, we start the strategy tester for the last year. On the first tick in the strategy tester we will get the zero bar time of 1.1.2015. Although, the real time on the computer is 1.5.2015. As the ticks come in the strategy tester - the date will shift, and the zero bar as well.

Using file operation, we can get that even though our last (zero bar) has a date of 1.1.2015, the real time is 1.05.2015. Accordingly, we process ticks in the tester only up to 1.04.2015.

As new real days come - in the tester we will get more and more later date, and, accordingly, process ticks further and further, but not closer than a month to the real date.

Now - the user has decided to cheat us, and set the date on the computer six months ahead. Now, in the tester, together with the date 1.05.2015 we will get the date 1.11.2015, and the ticks will be processed until 1.10.2015, despite the fact that the real date - still 1.05.2015, and in the terminal really data only to this date. However, there is no way we can get this value from the tester at the beginning of the test.

This is the problem.

That is, if we could get the real last date of the timeseries recorded in the tester from the tester - the problem would be solved. But the problem is that it's not clear how to do it.

There is a history file, we should open it (FileOpenHistory), read it, find the first (THE LAST BAR in history), read its time and count total number of bars.

This will be enough to manipulate stopping the Expert Advisor at the right moment in the tester.

 
Don't get the last date, get the first date in the history file and the total number of bars in the history file by reading it from the init
 
Alexandr Bryzgalov:

There is a history file, you need to open it, read it, find the first (the LEFTEST BAR in the history), read its time, count the total number of bars.

This will be enough to manipulate stopping the EA at the right moment in the tester.

All right, but how can we access it from the Strategy Tester? The variant suggested above gets the bars using standard functions, which in Inite on the strategy tester will return us 1.01.2015 (If we run the test from that date)
 
Alexandr Bryzgalov:
You don't need to get the last date, you need to get the first date in the history file and the total number of bars in the history file by reading it from the init

А ! Now that's interesting.

I'll have to give it a try.

 
George Merts:
That's right, but how do you access it from the strategy tester?

So is this a normal file operation, or is the tester not allowed to access the history?

I haven't tried it myself, but there are no bans on it in the help

 
I may be out of the loop, but in OnTesterInit() if you check TimeLocal and TimeGMT, find the difference in days, what time will it show, the real time or the tester time?
Reason: