ET News & Sponsor Info
General Topics
Markets
Technical Topics
Brokerage Firms
Company Specific
Tools of the Trade
Trading for a Living
Community Lounge
Site Support

# An Amibroker formula glitch....suggestions welcome to fix

Discussion in 'Programming' started by themickey, Sep 11, 2018.

1. ### themickey

I'm experimenting on a simple type volatility formula and the results I get from an exploration leaves me with numerous zeros in the results.
Anyone know how to overcome this?
With the lookback period set to say a fixed period of example 300 days, I still get this issue, therefore I doubt the lookback period formula is the issue.

// THIS FORMULA EXPERIMENTING WITH VOLATILITY
VT1 = Cum(Nz(DateNum()>=1160127)); // MAX LOOKBACK DATE
VT2 = IIf(-20+(BarIndex())<VT1,-20+(BarIndex()),VT1); // ADJUSTED LOOKBACK TIME
MA20 = MA(C,20);
VT3 = MA20>Ref(MA20,-1); // RISING MA20
VT4 = Sum(VT3,VT2); // SUM OF RISING MA20
VT5 = H>MA20;
VT6 = L>MA20;
VT7 = L<MA20;
VT8 = IIf(VT3,Sum(VT5,VT4),0); // SUM OF H>MA20
VT9 = IIf(VT3,Sum(VT6,VT4),0); // SUM OF L>MA20
VT10 = IIf(VT3,Sum(VT7,VT4),0); // SUM OF L<MA20
Filter = 1;
AddColumn(VT8,"VT8",1,1,10,50);
AddColumn(VT9,"VT9",1,1,10,50);
AddColumn(VT10,"VT10",1,1,10,50);

2. ### fan27

Are they trailing decimal zeros? Perhaps post what you expect to get vs what you are getting.

3. ### themickey

The column results are returning zero, for example, if my exploration is returning results for 500 stocks, maybe 250 of the results have been calculated and 250 of the remainder return a zero. It's early AM here now so will send a pic in a few hours time.

4. ### Peter8519

Amibroker exploration will step through all the elements of the array within the specified range(All quotes, 1 recent bars, 1 recent day, From-to dates). The IIF statements have zero option so there are plenty of zeros in those arrays. It tough to control the output result in the Amibroker exploration. What you can do is to cut and paste into Excel spreadsheet and filter out the zeros.

5. ### themickey

Approx 60% of all results show a zero result for columns VT8, VT9 & VT10.

Last edited: Sep 11, 2018
6. ### themickey

Seems the problem lays in the fact if current price is less than MA20 or MA20 is falling, then it wont calculate any historical result.

fan27 likes this.
7. ### themickey

Zeros can easily be filtered out in AB, no need for transposing to a seperate spreadsheet, however the overall results whichever way is inaccurate if 60% of the exploration result is missing.

8. ### themickey

Fixed! Used a different approach, also modified VT2 line.

ET IS FREE FOR TRADERS BECAUSE OF THE FINANCIAL SUPPORT FROM THESE SPONSORS:
 Alpaca Commission Free Stock Trading API AMP Global Clearing Futures and FX Trading Bookmap Visual Trading Platform Earn2Trade Trading Education and Funding Challenge Jigsaw Trading Advanced Trading Tools KJ Trading Systems Trader Education Services Lightspeed Equities & Options Trading MotiveWave Full-Featured Trading Software MultiBank Group Financial Derivatives Providers NinjaTrader Trading Software & Brokerage Optimus Futures Futures Trading Platforms and Order Routing ORATS Option Data & Backtesting Polygon.io Real-Time & Historic Data Raltin Finance Research Tools Rithmic Futures Trade Execution Platform SpreadProfessor Spread Trading Instruction TD Ameritrade Free Futures Education and Specialists TopstepTrader We Fund Traders TraderDock Your Path to Professional Trading TradersStudio System Development Platform TradeZero America Commission Free Trading Trading Technologies Trading Software Provider Tradovate Commision-Free Futures Trading TrendSpider Automated TA Software