Bug in backtester: no PipCost

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Bug in backtester: no PipCost

Postby tllewell » Tue Sep 03, 2013 4:58 pm

I am working on a strategy where I am doing account balance calculations. The calculation does not work because the value of PipCost comes up as zero. The value appears as it should when the strategy is run in a live or demo account, but it fails in the backtester on two different machines running XP SP 3. Here is how I assign the value:

Code: Select all
pipCost = core.host:findTable("offers"):find("Instrument", instance.bid:instrument()).PipCost;


I do this in the Prepare() function.
tllewell
 
Posts: 76
Joined: Thu Mar 01, 2012 4:06 pm

Re: Bug in backtester: no PipCost

Postby Valeria » Wed Sep 04, 2013 10:43 pm

Hi tllewell,

Thank you for the report, we will investigate the issue. Anyway, could you please specify why you use pip cost in Prepare()? The point is that pipCost can be changed in time, and it can't be cached.
Last edited by Valeria on Thu Sep 05, 2013 10:06 pm, edited 1 time in total.
Valeria
 

Re: Bug in backtester: no PipCost

Postby Valeria » Thu Sep 05, 2013 1:04 am

Hi tllewell,

Thank you for the report, we will investigate the issue.

It is the feature of the backtester. The Prepare() function is called too early in backtester, when not all necessary data are available.
Last edited by Valeria on Thu Sep 05, 2013 10:09 pm, edited 1 time in total.
Valeria
 

Re: Bug in backtester: no PipCost

Postby tllewell » Thu Sep 05, 2013 12:31 pm

I'm setting it it Prepare() because the docs say that's the place to set "all common data for further work of the strategy logic." I do know that it changes, but I haven't seen it change often enough that I thought about it too much.

Are you saying I should look up PipCost whenever I want to use it? That would be every time ExtUpdate runs.
tllewell
 
Posts: 76
Joined: Thu Mar 01, 2012 4:06 pm

Re: Bug in backtester: no PipCost

Postby Valeria » Fri Sep 06, 2013 12:14 am

Hi tllewell,

Are you saying I should look up PipCost whenever I want to use it? That would be every time ExtUpdate runs.

You should look up PipCost the first time you run ExtUpdate.
The example:
Code: Select all
local pipCost;
function ExtUpdate(...)
    if pipCost == nil then
        pipCost = core.host:findTable("offers"):find("Instrument", instance.bid:instrument()).PipCost;
    end
...
Valeria
 

Re: Bug in backtester: no PipCost

Postby tllewell » Mon Sep 16, 2013 6:13 pm

OK, I guess that makes sense. How about variables I ask the user to assign? For instance, if I ask the user to decide how much to risk, I have a menu item for the variable SL. Then in the Prepare function, I assign

Code: Select all
stopLevel = instance.parameters.SL;


Should I be doing that differently?
tllewell
 
Posts: 76
Joined: Thu Mar 01, 2012 4:06 pm

Re: Bug in backtester: no PipCost

Postby Valeria » Wed Sep 18, 2013 1:40 am

Hi tllewell,

Yes, you can assign parameters to Prepare function.
Valeria
 


Return to Discussions

Who is online

Users browsing this forum: No registered users and 7 guests