[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Question about staticvarset + recall in backtester



PureBytes Links

Trading Reference Links

mp,

I can see a number of issues here, which you may or may not be aware of.

1. You're combining static variables with non-static ones (ie.
StaticVerSet with VarGet). I don't know if this is supposed to work or
not, although your second example seems to indicate it does, but is
there any reason not to use StaticVarGet?

2. Your test condition "Buy OR sigScaleIn" will always be true for
every bar. "sigScaleIn" is a non-zero constant, not a variable, so it
doesn't matter what Buy is, that expression will always be true.

3. DateNum returns an array not a single value, so I'm not sure what
"sig.Symbol+DateNum()" is supposed to look like. With a quick test, I
notice it doesn't give an error but the appended string always seems
to be the same date, which for some reason is two days after today's date.

I don't think you can create multiple static variables at once using
array-style arithmetic. I think you have to use a loop (could be wrong
though). So to get what you want, try something like:

dn = DateNum();
for (i = 0; i < BarCount; i++)
{
    if (Buy[i]) // Will include sigScaleIn
        StaticVarSet(Name()+dn[i], longTriggerLevel[i]);
}

Then in the custom backtest procedure:

dn = DateNum(); // Before for loop over bars
....
eval = StaticVarGet(sig.Symbol+dn[i]);

Note that I haven't tried this though, so it may not work. 

Regards,
GP


--- In amibroker@xxxxxxxxxxxxxxx, "gonzo99e99" <mp@xxx> wrote:
>
> Hi,
> 
> I am trying to store in static variables on my entry days what the
> long entry level should be to be recalled from custom backtester. I
> converted all the signals from buy to sigscalein (because buy strips
> out all future entry signals). Basically, the first buy shows up as a
> buy and the rest show up as sigscalein (I used
> buy=iif(buy,sigscalein,false);)
> 
> Anyway,in my code I have:
> 
> StaticVarSet(Name()+ValueWhen(Buy OR
> sigScaleIn,DateNum()),LastValue(ValueWhen(Buy OR
> sigScaleIn,Longtriggerlevel)));
> 
> I used lastvalue in the above because without it wont take
> longtriggerlevel because its an array. The lastvalue converts it to an
> integer.
> 
> Basically it should store the value as a the symbol name, plus the
> date (in numeric format). This would be the level the stock would have
> to reach for a buy to be initiated.
> 
> Then, from custom backtester to recall the value I have:
> 
> eval=VarGet(sig.symbol+DateNum()));
> 
> However, using _trace I see the return value is {EMPTY}.
> 
> When I use only the symbol ie:
> 
> staticvarset(Name(),lastvalue(longtriggerlevel));
> 
> and in backtester
> 
> varget(sig.symbol);
> 
> I can pass variables successfully (however it is always the last value
> of the prices, since in the first pass/sweep it stores the final entry).
> 
> Finally, I would like to only store on buy or sigscalein rather than
> all dates (to hopefully save time memory). Would I need to do anything
> special for this?
> 
> Thanks!!
> 
> -mp
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/