Ozzy,
I have found that Code Check will report looking into the future if you have
a "lastvalue()" in your code, and I see that you do. You can take the
simplest code such as buying on the MACD as in TJ's system example and put
in a last value on something or other and bang!, the system reports a future
leak. Don't know why, but it does.
You can also get a reported future leak with a trace statement, something
as innocent as _trace("Hello world");
Hope this helps.
Grover Yowell
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of ozzyapeman
Sent: Wednesday, September 24, 2008 8:08 PM
To: [email protected]
Subject: [amibroker] Does my code really look into the future?!?
I clicked on "Code Check & Profile" in the AFL editor and it gives me the
warning that my code references future quotes, "40 past and ALL future
quotes are needed to calculate the formula correctly." Hoping anyone can
chime in here with reasons why that might be happening.
Is there any other way to test if I have a "Future Leak" other than relying
on the Code Check tool?
I have gone through my FOREX trading system with a fine tooth comb and can't
find any place where it references the future. It makes use of several
moving averages that only reference the current Close, and back through the
lasts 40 Closes. I test my current Close against the MAs, as well as against
static profit and stop targets.
I am wondering if my backtester settings are somehow setting off the Code
Check warning. Would any of the following backtester settings set off a
false warning of this sort? What else might trigger the 'Future Leak' alarm?
I don't use any fancy functions like ZIG, just plan old MAs...
SetOption("AccountMargin", 100); // Account
margin, 100 = no margin
SetOption("ActivateStopsImmediately", False); // Intraday stops ?
SetOption("AllowPositionShrinking", False); // Take partial trades
if equity available ?
SetOption("AllowSameBarExit", True); // Allow same bar
exit for profit stops
SetOption("CommissionAmount", 3.00); // Commission amount
SetOption("CommissionMode", 3); // 3 = $ per
share/contract
SetOption("FuturesMode", 1); // = use
MarginDeposit and PointValue in calculations
SetOption("InitialEquity", 100000); // Initial
equity $
SetOption("InterestRate",0); // Set
interest rate earned for free cash, zero to evaluate system
SetOption("MaxOpenPositions", maxPairsTraded * maxContractsPerPair);
SetOption("MinPosValue", 0); // Min
position Value to make trade worthwhile, 0 = no limit
SetOption("MinShares", 1); //
Min number shares
SetOption("PriceBoundChecking", False ); // Price to stay in
bar range ?
SetOption("ReverseSignalForcesExit", False);
SetOption("UsePrevBarEquityForPosSizing", True );
// Use last known bar for position sizing ?
SetTradeDelays(tradeDelay, tradeDelay, tradeDelay, tradeDelay);
SetPositionSize(1, spsShares);
quoteCurrency = StrRight(Name(), 3); // eg. EURJPY gives JPY.
if (maxContractsPerPair > 1)
SetBacktestMode(backtestRegularRawMulti);
tradedelay = 0;
// Make sure backtester only starts computing at the start of our testing
date range, not the start of the symbol database
if(Status("action")>2) start = Max( tradeDelay, LastValue( ValueWhen(
Status("firstbarinrange"), BarIndex() ) ) );
else start = tradedelay;
// Barcount Loop
for (start = 1; i < BarCount; i++)
{
// Trade system using MAs goes here.