Calculate lowest tick since price break when backtesting?

376

Hi

I want to calculate drawdown between bars (Starting from the bar that breaked the price) relative to the value 1.0000

Example "SEE ATTACHED PIC BELOW": My EA buys when price brakes 1.0000 ! at time  15:30:05

15:30:45 / The price has moved down to 0.9500

15:30:55 / The price has moved up above 1.000 again

15:31:25 / A new bar has formed and lowest of that bar is 0.9700

At this point, at current bar the drawdown since breaking the price should be 1.0000 minus 0.9500 witch is 0.0500

But when i use M1 history data the candle that broke the value 1.0000 has a low for example of 0.9300  the drawdown will be 1.0000 minus 0.9300 witch is 0.0700   -Witch offcourse is wrong the acual is 0.0500

What i use now is:

`Low[iLowest(NULL,0,MODE_LOW,shift_of_bar_that_crossed_the_price,0)]`

But as i mentioned before it gives me wrong drawdown becuase

- It takes the lowest value of bar that crossed the value 1.0000 //Wrong

Instead of what value i need... that would be:

- The lowest value since crossed the value 1.0000  //Correct

So how do i build a function that will understand this, and somehow stores and print the lowest BID tick value of a certain bar. (I already have the correct shift value of the bar "shift_bar_that_crossed_the _price")

15311

pontuso:

What i use now is:

`Low[iLowest(NULL,0,MODE_LOW,shift_of_bar_that_crossed_the_price,0)]`

So how do i build a function that will understand this, and somehow stores and print the lowest BID tick value of a certain bar. (I already have the correct shift value of the bar "shift_bar_that_crossed_the _price")
1. The shift_of_bar_that_crossed_the_price is wrong. iLowest needs the bar count, which is last - first + 1. You have last=shift_of_bar_that_crossed_the_price and first=0.
2. The lowest Bid is the Low of the bar.
376

WHRoeder:
1. The shift_of_bar_that_crossed_the_price is wrong. iLowest needs the bar count, which is last - first + 1. You have last=shift_of_bar_that_crossed_the_price and first=0.
2. The lowest Bid is the Low of the bar.

1. Sorry i meant bar count

2.Yes you are correct.

- But let's say that lowest is 0.900 of a 1H bar, but it has only been 35 min of this bar yet.

And now high crosses my value of 1.000

it's still 25 min of the bar left before it's complete and the low might not change, witch will leave me with the wrong value of drawdown between "high crossing value" and "now".

I mean if it breaks the low during the 25 minutes left then i have the correct low and no worries. But if it dosen't........ ... ...

Is there a way to get all the "low BID" tick values of a specific bar, and exclude those who are older then the time that we crossed the value 1.000 and allso check for the lowest of those ?

BTW. This is just for Backtesting not real so mayby i can store the values somehow in array?

15311

pontuso:

it's still 25 min of the bar left before it's complete and the low might not change, witch will leave me with the wrong value of drawdown between "high crossing value" and "now".

Is there a way to get all the "low BID" tick values of a specific bar, and exclude those who are older then the time that we crossed the value 1.000

1. If the low doesn't change then how could the value be wrong?
2. If you want to exclude older values, you have to use the M1 chart.
376

WHRoeder:
1. If the low doesn't change then how could the value be wrong?
2. If you want to exclude older values, you have to use the M1 chart.

1. Becuase - if low value change after high crossing my value 1.000 then when new bar forms the low of the bar before is the lowest value after crossing my value of 1.000.

2. I use the M1 chart but the lows can change during a minute. like in my attached picture above.