Australian (ASX) Stock Market Forum

Amibroker FAQ

Why would I be getting varying results for backtests depending on the date range i select?

For example trades that should be taken this week are taken if i set the start date to 1/1/12, but not if i set it to 1/1/11. I can't work out why this would be.

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.

Its also very frustrating that the backtest window just seems to dissapear when i minimize it! Am i doing something wrong?

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.
 
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
 
Why would I be getting varying results for backtests depending on the date range i select?

For example trades that should be taken this week are taken if i set the start date to 1/1/12, but not if i set it to 1/1/11. I can't work out why this would be.

Its also very frustrating that the backtest window just seems to dissapear when i minimize it! Am i doing something wrong?

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.
 
Why would I be getting varying results for backtests depending on the date range i select?

For example trades that should be taken this week are taken if i set the start date to 1/1/12, but not if i set it to 1/1/11. I can't work out why this would be.

Its also very frustrating that the backtest window just seems to dissapear when i minimize it! Am i doing something wrong?

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.
 
Why would I be getting varying results for backtests depending on the date range i select?

For example trades that should be taken this week are taken if i set the start date to 1/1/12, but not if i set it to 1/1/11. I can't work out why this would be.
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.
Its also very frustrating that the backtest window just seems to dissapear when i minimize it! Am i doing something wrong?
Mine appears in the lower left hand side of the Amibroker window when I minimise it.
 
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 :)
 
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);

PHP:
PreviousEMA = MA(Ref(C, -1), 6);
CustomEMA = (Ref(C, -1) - PreviousEMA) * (0.025 + PreviousEMA);
 
PHP:
PreviousEMA = MA(Ref(C, -1), 6);
CustomEMA = (Ref(C, -1) - PreviousEMA) * (0.025 + PreviousEMA);

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.
 
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.
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);
 
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);

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.
 
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.

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
 
Buy = Cross( C, Peak( MA( C, 50 ), 5, 1) );

Adjust the 2nd parameter of Peak() to what you want - see Peak() syntax in Help.
 
Buy = Cross( C, Peak( MA( C, 50 ), 5, 1) );

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

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.
 
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).
 
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.
 
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");
 
Top