• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

Amibroker FAQ

Discussion in 'Software and Data' started by RichKid, Jul 15, 2005.

  1. captain black

    captain black

    Posts:
    1,281
    Likes Received:
    748
    Joined:
    Oct 24, 2005
    That's a difficult one to troubleshoot without seeing your AA settings and formula. If no-one can offer up a solution here I'd suggest emailing support with your AA settings file and formula.

    I'm using the latest Release Candidate that has the AA window as a tab or floating so there's no "minimise" option but using the old AA whenever I minimise the window it sits down in the bottom left hand corner of the main Amibroker window.
     
  2. Sir Burr

    Sir Burr

    Posts:
    547
    Likes Received:
    152
    Joined:
    Feb 15, 2006
    Have you Pad and align to reference symbol set in the AA settings?
     
  3. Synergy

    Synergy

    Posts:
    358
    Likes Received:
    0
    Joined:
    Feb 26, 2007
    The correct trades come up in a scan, but not a backtest, depending on the date range I select. I can't see anything in the settings that would be limiting my results in any way.

    The pad and align option seems to give me unwanted signals.

    I have many other bigger issues with my code at the moment so this one isn't a show stopper just yet.

    Thanks for your thoughts
     
  4. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    What about if you start on 1-1-12, 2-1-12, 3-1-12, 4-1-12? Are they all different or do some match?
    If you're trading one symbol, this can happen because AB by default doesn't enter a stock it just sold the day before.
     
  5. colion

    colion

    Posts:
    116
    Likes Received:
    0
    Joined:
    Aug 6, 2010
    Depending on your Buy/Sell/Short/Cover conditions I can envision that changing the date could change the current signal. Suggest you plot the trades for both start dates and that should show you what is going on.
     
  6. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    Obviously any test date range change will show different results. All to do with funds available to trade, open trades, index bullish/bearish and other possible variables.
    Mine appears in the lower left hand side of the Amibroker window when I minimise it.
     
  7. Synergy

    Synergy

    Posts:
    358
    Likes Received:
    0
    Joined:
    Feb 26, 2007
    Ok the backtesting issue was simply due to some of the 'pre code' I'm using setting the max positions to 6. Sorry for wasting your time with that one!


    My current problem is with getting my EMA working. I know rnr replied to this question a few pages back, but the problem is my EMA is a manually coded EMA rather than using the EMA function.

    It's offset back a day, and basically works like this:

    EMA = (Previous Close - Previous EMA) * Constant + Previous EMA.

    For the initial EMA value, where there is no previous EMA, I use:

    MA(Ref(C,-1),6);

    No matter what I've tried I can't get the correct results. I can get values close to what they should be (excel) but not the same. I know the data is the same, because the resuls I get with a SMA are correct.

    Here's the code I am currently playing with, but I feel I'm just doing something fundamentally wrong. I'm initially setting EMA7C to null.


    SMAVG = MA(Ref(C,-1),6);
    PrvEMA = IIf(IsNull(Ref(EMA7C, -1)), SMAVG, Ref(EMA7C, -1));
    EMA7C = (Ref(C, -1) - PrvEMA) *constant + PrvEMA;


    I'm hopefull that if I can get this working I'll have converted my excel system to Ami :)
     
  8. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    PHP:
    PreviousEMA MA(Ref(C, -1), 6);
    CustomEMA = (Ref(C, -1) - PreviousEMA) * (0.025 PreviousEMA);
     
  9. Synergy

    Synergy

    Posts:
    358
    Likes Received:
    0
    Joined:
    Feb 26, 2007
    Hey Wysi,

    The MA(ref(c, -1), 6) should only be used once to get it started. From then on, the previous custom EMA is used. It's easy in excel, but I can't work it out.
     
  10. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    Okay Synergy, what is the condition to determine the initial EMA, is it ref(C, -1)?

    PreviousEMA = IIf(Condition, True Array, False Array);
    CustomEMA = (Ref(C, -1) - PreviousEMA) * (0.025 + PreviousEMA);
     
  11. Synergy

    Synergy

    Posts:
    358
    Likes Received:
    0
    Joined:
    Feb 26, 2007
    Yes that is the correct logic, but the issue is that the PreviousEMA must reference the Previous CustomEMA to be calculated. That's ok once it's up and running, because there will be a value for CustomEMA, but initially there isn't.

    It is confusing.

    I think i need to use a loop, which i'm struggling to get my head around. I've managed to avoid them so far.
     
  12. Billyb

    Billyb

    Posts:
    240
    Likes Received:
    0
    Joined:
    Dec 21, 2010
    Just briefly looking over what you've wirtten it sounds to me like you need to use a loop and write a function. There is some help on this in the amibroker guide
     
  13. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    Hi,

    I'm wanting to buy when the CLOSE crosses above the VALUE of the most recent peak of MA(C,50).

    Any help please?
     
  14. colion

    colion

    Posts:
    116
    Likes Received:
    0
    Joined:
    Aug 6, 2010
    Buy = Cross( C, Peak( MA( C, 50 ), 5, 1) );

    Adjust the 2nd parameter of Peak() to what you want - see Peak() syntax in Help.
     
  15. rnr

    rnr

    Posts:
    503
    Likes Received:
    249
    Joined:
    Jul 1, 2007
    There are a couple of problems when using the Peak function.
    It can't be used in back-testing and you may also find issues on the RHS of the chart with trades that appear to meet the entry criteria but no trades are taken.
     
  16. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    Thanks, yes I was getting some problems with backtesting.

    "ValueWhen" might do the trick. Still fiddling here!
     
  17. colion

    colion

    Posts:
    116
    Likes Received:
    0
    Joined:
    Aug 6, 2010
    Looking into the future is certainly a problem with all zig-zag related functions, as well as identifying the peak after it actually formed. As a result, backtesting will see the peak before it is certain that one exists and is, therefore, not reliable. The other approach is to use "peak" code that spells out the relative positions of lows around the peak. This approach will not identify a peak until after it has formed but unlike Peak() there will not be any initial uncertainty. I don't see how ValueWhen() gets around these problems.

    You did not indicate how you wanted to use the code. If you are a discretionary trader who, for example, wants the information in order to place text on a chart for use with other tools then there is no problem. If, however, you want to use the system in real time then there are the above limitations which I suspect you will not overcome (let us know if you do).
     
  18. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    I gave that idea away colion. :)

    I wonder if anyone can help me calculate the average (H-L)/L of the past 15 days, but only for days when C>O.
     
  19. colion

    colion

    Posts:
    116
    Likes Received:
    0
    Joined:
    Aug 6, 2010
    result = iif( c > o, ma( (h + L)/l, 15), null);
     
  20. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    thanks colion.

    Why would this not return any results in an exploration?

    filter = result = iif( c > o, ma( (h + L)/l, 15), null);
    addcolumn(result,"result");
     
Loading...

Share This Page