Is it possible to get a candle high under MT4 strategy tester?

 

Hi,

I have a problem: Is it possible to get a candle high under MT4 strategy tester? I have tried with this code, but what I got is 0 or something wrong tick data.

candle_count=iBars(Symbol());
tesztfile=FileOpen("adatgyujtes.txt",FILE_WRITE|FILE_CSV,";");
FileWrite(tesztfile,"nyitoar ","max/min_close ");

//trade opened here in this session
...
//

if (iBars(Symbol()),timeframe)>candle_count)
   {
      if (selected_order_typ==0)             //long
         {
         if (price<iHigh(Symbol(),timeframe,1)) price=iHigh(Symbol(),timeframe,1); 
         Alert(price);
         }
      if (selected_order_typ==1)             //short
         {
         if (price>iLow(Symbol(),timeframe,1)) price=iLow(Symbol(),timeframef,1);
         Alert(price);
         }
   }
FileWrite(tesztfile,selected_open_price,price);

and what I got as price is not the candle high or low. Thanks for help. Cheers

 

Not enough code!

1) price?,

2) What is 0: selected_open_price || price?,

3) confound of Ask and Bid (Long,Short, Buy,Sell)?

 
gooly:

Not enough code!

1) price?,

2) What is 0: selected_open_price || price?,

3) confound of Ask and Bid (Long,Short, Buy,Sell)?


1) price is the searched max or low data of the candle

2) 0? selected_open_price is the running trade open price.

3) why are you in confound? I don't care ask or bid price. I want to get the max and low price of a candle under strat.tester.

With this I like to know after long how up gone the price, and after short how low gone the price. Thats all.

 
pecskeke1976:

1) price is the searched max or low data of the candle

2) 0? selected_open_price is the running trade open price.

3) why are you in confound? I don't care ask or bid price. I want to get the max and low price of a candle under strat.tester.

With this I like to know after long how up gone the price, and after short how low gone the price. Thats all.

1) if you don initialite price price==0.0 and e.g. always lower then any iLow(..)!

2) selected_open_price == 0 => it is not initialized! I guess a) position is closed meanwhile or b) is not correctly selected => show the code of setting this var.

3) iLow(..),iHigh(..),i.. are always Bid! If you are long the OrderOpenPrice() has been Ask , which is in some cases can be always > iHigh(..)

 
gooly:

1) if you don initialite price price==0.0 and e.g. always lower then any iLow(..)!

2) selected_open_price == 0 => it is not initialized! I guess a) position is closed meanwhile or b) is not correctly selected => show the code of setting this var.

3) iLow(..),iHigh(..),i.. are always Bid! If you are long the OrderOpenPrice() has been Ask , which is in some cases can be always > iHigh(..)


Ty Gooly,

I have initialized price as 0 (as I wrote I got some not zero value as candle price under test) and ofc initialized selected_open_price too. The EA is a good working EA, I want to get the max and low. With this info I like to set the best TP and SL. Thats why I am curious.

The outcome under test is like a mistake. I was testing 1 week. I got 8 trade taking. With the code above I wrote into the file the trade open price (this working good, I have checked) this is the selected_open_price but as "price" I got zero, then xxx.xx next zero next yyy.yy etc.

I can't decide where is a failure in my code. Thats why I asked is it possible to get a candle max/low price under strat.tester? What could you suggest?

 
pecskeke1976:

I can't decide where is a failure in my code.

Neither me - with out the code :(
 
gooly:
Neither me - with out the code :(
:) the code is above. If it is not enough to get the candle data under tester, what is missing? The rest of the code is the working EA.
Reason: