stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Returnig values of included function while backtesting
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2646
Page 1 of 1
Author:  VirtualFM [ Wed Jul 03, 2013 7:14 pm ]
Post subject:  Returnig values of included function while backtesting

Hi guys!

I've been messing around with some old EAs that seemed to work well until the fatidic moment when they just make you loose everything :-) and was trying to add filters based on what we know now about TMA Slope, RSI, CSS, etc, minimizinfg losses, getting better entry points, and so on.

But I got stumped with CSS! Instead of puttin gall CSS Code into each EA I thought about using one of the generously provided includes available, like CSSLib.mqh or libCSSMod.mqh.

After including those and using its functions nothing seemed to happen and took me a while until I realised what the problem was. First I thought that I couldn't get values returned from the function when backtesting, as the returned value was 0 (zero). Then I realized that not every function was returning 0, but the one I wanted was.

So, I want to know the value of CSSDiff and can only get 0 as return (This is in backtesting, of course, it works well when used a real chart).

Can anyone explain why can't get a value from CSSDiff?
Author:  phil_trade [ Wed Jul 03, 2013 7:29 pm ]
Post subject:  Re: Returnig values of included function while backtesting

VirtualFM wrote:Hi guys!

I've been messing around with some old EAs that seemed to work well until the fatidic moment when they just make you loose everything :-) and was trying to add filters based on what we know now about TMA Slope, RSI, CSS, etc, minimizinfg losses, getting better entry points, and so on.

But I got stumped with CSS! Instead of puttin gall CSS Code into each EA I thought about using one of the generously provided includes available, like CSSLib.mqh or libCSSMod.mqh.

After including those and using its functions nothing seemed to happen and took me a while until I realised what the problem was. First I thought that I couldn't get values returned from the function when backtesting, as the returned value was 0 (zero). Then I realized that not every function was returning 0, but the one I wanted was.

So, I want to know the value of CSSDiff and can only get 0 as return (This is in backtesting, of course, it works well when used a real chart).

Can anyone explain why can't get a value from CSSDiff?
CSSdiff need all pairs values to be calculated...but in Backesting you could only have one pairs !
Author:  VirtualFM [ Thu Jul 04, 2013 4:09 am ]
Post subject:  Re: Returnig values of included function while backtesting

So you're saying that while backtesting you don't have access to other pairs and thus CSS can't be calculated, much less the difference between pairs, right?

As a workaround, could we have another indicator running in a real chart, inputing CSS values into some Global Variables, and then access those from the EA we are using in backtesting?

I'm just thinking out loud...
Author:  phil_trade [ Thu Jul 04, 2013 4:56 am ]
Post subject:  Re: Returnig values of included function while backtesting

VirtualFM wrote:So you're saying that while backtesting you don't have access to other pairs and thus CSS can't be calculated, much less the difference between pairs, right?

As a workaround, could we have another indicator running in a real chart, inputing CSS values into some Global Variables, and then access those from the EA we are using in backtesting?

I'm just thinking out loud...
So you're saying that while backtesting you don't have access to other pairs

Yes, that's the BIGGEST limitation of Empty4. Switch to ForexTester, you will have all... and a lot of work also :)
Author:  VirtualFM [ Sat Jul 06, 2013 1:57 pm ]
Post subject:  Re: Returnig values of included function while backtesting

Thank you for you reply, phil_trade. Hum, Forextester sounds like a lot of work indeed... having to code the same stuff twice or dealing with the issues of converting Empty4 code is not in my league and it's something I am not inclined to do right now.

Anyway... I am "faking it" right now... I input the CSS value manually and then look at the real CSS curve, testing it when the real CSS values are OK. It almost works...
Author:  aSushiRoll [ Sun Sep 29, 2013 9:35 pm ]
Post subject:  Re: Returnig values of included function while backtesting

Wow I'm happy I searched & found this!

I just more or less finished my EA, which uses CSS and was just about to backtest (only having it work on opening of new bars, so no problems with "fake ticks"), but then I indeed found that if you try to access other pairs it will give you the other pairs info, but from .hst files, so normal history, not from the tester history, which means you can go back a bit, but nog years and years and not with the accurate data.

By the way the reason why CSS fails in backtesting, I found out, is because of this code:

Code: Select all

int libCSS.initSymbols()
-> inside the

Code: Select all

while ( i != -1 )
check this out:

Code: Select all

      if ( MarketInfo( newSymbol, MODE_TRADEALLOWED ) > libCSS.EPSILON 
It can't access the marketinfo, so I changed it to:

Code: Select all

if ( MarketInfo( newSymbol, MODE_TRADEALLOWED ) > libCSS.EPSILON || isBTIgnoreMarketInfo)
where isBTIgnoreMarketInfo is a global variable i set to true when backtesting! Then it works ;)
But like I said.. it only works for recent backtesting, as it uses values from other pairs not from the tester history, but from the normal history (I think,.. I don't know where it would get it otherwise).

It does actually access the other pairs, because when I print out dblTmaTrue and dblPrev values in LibCSS.getSlope they give me values, dunno if they're correct, but they seem correct! ie. when working on EUR/USD it also prints for EURJPY the value 132.xxx and 133.xxx so that would correspond to that pair I guess.



Anywy it's been quite a while since phil last posted in this thread, but I wonder if you guys found another workaround yet!?
All times are UTC Page 1 of 1