I cross-posted this in the auto-trading group on Friday and haven't heard any 
responses, so I am posting it here as well since this group appears to be a 
little more active. Apologies in advance if this goes against any established 
policies.

I have a quick question about using StaticVarSet with SetForeign. I want to 
capture and log study values of $SPX at the time my system enters and exits 
positions. (I am currently using the IBc and TWS to perform a walk-forward test 
of a system sending limit orders.)  I want to do this by first switching to the 
$SPX symbol (SetForeign) and then setting the study value in a static variable 
(StaticVarSet). However, I am noticing that after I RestorePriceArrays(), the 
static variable I am setting becomes empty. I have searched the various 
Amibroker Yahoo groups and UserKB, but have not been able to find a solution. 
I'm pretty sure I am overlooking something rather obvious. Any help would be 
greatly appreciated.

Here is my code snippet:

SetForeign("$SPX");
//Get RSI value for the S&P500
RSISPX = LastValue(Ref(RSI(14),-1));
StaticVarSet("RSI-SPX-"+Name(),RSISPX);

// Trace statment to test what is happening
RSISPX = StaticVarGet("RSI-SPX-"+Name());
_TRACE("RSISPX: " + RSISPX);
RestorePriceArrays();

//Another trace statement to see what is going on
RSISPX = StaticVarGet("RSI-SPX-"+Name());
_TRACE("RSISPX: " + RSISPX);


The first "_TRACE" outputs the correct value. The second "_TRACE" (after 
RestorePriceArrays()) shows up as <EMPTY> in the Trace window.

Thanks,
Dave

Reply via email to