Second question from a beginner - The three last values

 

Hi,

ok i tried to get the three last close values in the journal:

This is my code at start:

double Hilfsvariable= (Close[1]);
Print("Aktueller Close ",+ Hilfsvariable);

double Hilfsvariable2= (Close[2]);
Print("Vorgänger Kurs ",+ Hilfsvariable2);

double Hilfsvariable3= (Close[3]);
Print("VorVorgänger Kurs ",+ Hilfsvariable3);

The journal log gives me this result, so i marked 2 values bold, in my opion these two values have to be the same. (the second value should be 1,3196)

Can you help me again whats wrong?

07:38:36 2013.01.01 23:41 TEST EURUSD,M1: Aktueller Close 1.3195
07:38:36 2013.01.01 23:41 TEST EURUSD,M1: Vorgänger Kurs 1.3195
07:38:36 2013.01.01 23:41 TEST EURUSD,M1: VorVorgänger Kurs 1.3195
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: Aktueller Close 1.3196
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: Vorgänger Kurs 1.3195
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: VorVorgänger Kurs 1.3195
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: Aktueller Close 1.3196
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: Vorgänger Kurs 1.3195
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: VorVorgänger Kurs 1.3195
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: Aktueller Close 1.3196
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: Vorgänger Kurs 1.3195
07:38:36 2013.01.01 23:42 TEST EURUSD,M1: VorVorgänger Kurs 1.3195

 

A new bar happens every minute / every 5 minutes / every 15 minutes etc. (depending on the timeframe)

When a new bar is made, the values of the Close array shift by one (i.e. Close[1] becomes Close[2] etc.)

However, "Start" runs every tick, i.e. every time the price changes. That means many times Close[1] and Close[2] etc. will be the same for many ticks... they will only change when a new bar is made.

It looks like between the 1st and 2nd times, there was a new bar.. but the values of the 2nd, 3rd and 4th times are the same, so they are in the same bar.

 
AiGelb:

Hi,

ok i tried to get the three last close values in the journal:

This is my code at start:

double Hilfsvariable= (Close[1]);
Print("Aktueller Close ",+ Hilfsvariable);

double Hilfsvariable2= (Close[2]);
Print("Vorgänger Kurs ",+ Hilfsvariable2);

double Hilfsvariable3= (Close[3]);
Print("VorVorgänger Kurs ",+ Hilfsvariable3);

The journal log gives me this result, so i marked 2 values bold, in my opion these two values have to be the same. (the second value should be 1,3196)

Can you help me again whats wrong?

Read this thread: https://www.mql5.com/en/forum/146589

And print the value to the correct number of digits using DoubleToStr(value, Digits)

 

Ok,

Start runs for ervery tick...

If my timeframe is 1 minute it takes many ticks each minute and build the close. This is the close of the journal.

All in all i can't prove the journal log without manually work.

I have to build the function that the jounal give me just the 1m candles to compare the data?

Am i right?

 

I'm not sure what you mean.

Make sure you read the book https://book.mql4.com/ and you will know everything like this.

I don't want to be rude, but if you don't know basic information (such as Start runs every tick) you shouldn't let your EA/indicator risk your money...

 
AiGelb:

Ok,

Start runs for ervery tick...

If my timeframe is 1 minute it takes many ticks each minute and build the close. This is the close of the journal.

All in all i can't prove the journal log without manually work.

I have to build the function that the jounal give me just the 1m candles to compare the data?

Am i right?

If you just one one Print() per M1 bar then you have to do just that, only Print() when a new M1 bar arrives . . . for example, my code in this thread: https://www.mql5.com/en/forum/146649
 

Ok tkanks,

i will read the book at the evening.

@ RaptorUK

I think your code will help me to understand the problem.

Reason: