return values for bars in strategy tester

 

hi all

maybe this is simple but ...

im trying to return the values of bars in the strategy tester in a similar way to the way you can do this on a live chart.

i.e.  if i want to return the high for the most recently closed bar in a live chart it would be something like:    double myVariable = High[1];  

how can i do this on a strategy tester chart (in visual mode).  for instance, during play back hit a script etc and capture the high value of the most recently closed bar on the strategy tester chart equivalent to High[1] etc?

 

id be most grateful for any advice.

regards

 

Michael 

 
chaeljc:

hi all

maybe this is simple but ...

im trying to return the values of bars in the strategy tester in a similar way to the way you can do this on a live chart.

i.e.  if i want to return the high for the most recently closed bar in a live chart it would be something like:    double myVariable = High[1];  

how can i do this on a strategy tester chart (in visual mode).  for instance, during play back hit a script etc and capture the high value of the most recently closed bar on the strategy tester chart equivalent to High[1] etc?

You do it using the EA under test,  if you try and do it with a Script dropped onto the chart it will probably get the data from the live data . . . the clue is in the name,  Strategy Tester,  it's for testing EAs.
 
chaeljc: im trying to return the values of bars in the strategy tester in a similar way to the way you can do this on a live chart.
Why do you think there's a difference? If there was, what would be the point of the tester?
 
WHRoeder:
Why do you think there's a difference? If there was, what would be the point of the tester?


Raptor

thanks for your 'input'

im aware the strategy tester is for testing EAs...  i am developing a semi automated EA  which employs a degree of manual input and the use of on screen objects and scripts as triggers etc.  more a semi automated trading assistant than a fully fledged robot.  look around and you will find many other such EAs by other developers.

 

Roeder .. simply asking for High[1] gives you the latest High[1]  which is not necessarily the the same bar as 'appears' as the latest bar being displayed in the running strategy tester chart ... ie the apparent bar 1 could be from several years back depending from when (years etc)  you're running the EA and where the tester is 'in time' at that particular moment. hope that explains a little.

 
High[1] is the high "from several years back" What good is accessing the future? You can't do that live. You shouldn't be able to do that in the tester.
 

Hi Roeder

Apologies, im not explaining myself properly

 

say you are running the tester is visual mode from the period 01/01/2000 - 10/10/2001.  EURUSD  / 5min time frame.

 

you've just hit play and the tester has just started drawing the bars on the chart....

now pause the chart.

now the chart is paused, say for example the latest bar on the chart represents  09:00 hours Jan 1st 2000

any indicator calculations used by your EA or attached to the chart will be calculated / drawn up to that date time.

HOWEVER..

say i have a script that returns High[1] when dropped onto a chart...

if instead of pausing the chart i had at the same moment dropped the script onto the chart, the value returned by the script would be the value of High[1] for TODAYS date (or at the weekend the last High[1] value stored on the broker server prior to the weekend break.

All generally logical as scripts are generally used in the 'here and now' and EAs to test historical data.

 however ...

i am developing a semi automated EA which involves using scritps in real time to drop lines onto a chart which the EA acts upon.  The EA is acting more as a trading assistant than traditional robotic trading system.  This is a valid construct.

In real time the testing is fine as the latest High[1] on the chart is the latest on the server so the scripts picks up the correct value.

i would like to be able to develop further my semi automatic EA on the historical charts however as explained earlier the scripts then pick up the wrong value.

 

Im hoping someone knowledgeable out there in MQL4 land could offer me advice towards a work around to this problem.  Namely : -

 

When dropping a script onto a running strategy tester chart, how to i capture the values of the TESTER chart's bar0, bar1, bar2 etc and not the values of the bars as on the real live chart?

 

Any advice gratefully recieved.  ;-)) 

 
chaeljc:

Hi Roeder

Apologies, im not explaining myself properly

 

say you are running the tester is visual mode from the period 01/01/2000 - 10/10/2001.  EURUSD  / 5min time frame.

 

you've just hit play and the tester has just started drawing the bars on the chart....

now pause the chart.

now the chart is paused, say for example the latest bar on the chart represents  09:00 hours Jan 1st 2000

any indicator calculations used by your EA or attached to the chart will be calculated / drawn up to that date time.

HOWEVER..

say i have a script that returns High[1] when dropped onto a chart...

RaptorUK:
You do it using the EA under test,  if you try and do it with a Script dropped onto the chart it will probably get the data from the live data . . . the clue is in the name,  Strategy Tester,  it's for testing EAs.

I have already told you that this may not work . . .  you could get your EA to place an Object on the chart at the price of the information you require and your Script may be able to read this Object and get the information.

There are many things on a Strategy tester chart that do not work with Scripts and Indicators . . . https://www.mql5.com/en/forum/143310/page2#753302 

 
RaptorUK:

I have already told you that this may not work . . .  you could get your EA to place an Object on the chart at the price of the information you require and your Script may be able to read this Object and get the information.

There are many things on a Strategy tester chart that do not work with Scripts and Indicators . . . https://www.mql5.com/en/forum/143310/page2#753302 

 


thanks for the link raptor. very useful.  ill have a think how to proceed.  as you say an object might do the trick  :-)
Reason: