Australian (ASX) Stock Market Forum

AmiBroker Tips and Tricks

I think that we all have found that a system tested too good to be true sometimes and a quick easy way to look at why is the code check & profile tool as per below.

I recently missed the - symbol in a reference function which gave me outstanding results but when running the code through the checker it flagged my error.

Ref(H,1) entered instead of Ref(H,-1)

Below are some basic steps for you to follow.

upload_2020-7-13_6-18-52.png

upload_2020-7-13_6-17-4.png

Also you can monitor the system blow by blow by using the Bar Replay feature, where you can see the buy / sell shapes being plotted on your chart.

upload_2020-7-13_6-27-18.png
 
ideally open both a set of 4 layouts and as well 4 apx...
I am so surprised to NOT see this as default facility:
in Windows .Net just a matter of storing of a Configuration object even as a blob and saving/loading , very basic ;
wonder why not implemented and everyone trying to find works around ..yes we can survive but if every user start its session by redoing these steps, this is a MUST HAVE fct , not a wish...
Thanks all for your work arounds

Perhaps send a feature request to Amibroker support? Although if you've seen a lot of complaints on AB forums, then perhaps it might be a waste of an email. But worth a shot to see what their reply would be.
 
I wasn't sure if this post should go here, or in a Norgate Data thread. I guess it could go in both.

I had a "play" with accessing the Norgate Data "extras" Fundamental and Metadata functions, and created the attached AFL file. Just run it in the debugger and view the Output window.

I thought I'd post it here in case anyone else would be interested.

I ask a few questions in the program header. If you know the answers, or can suggest improvements to this code, please let me know.

Cheers...
 

Attachments

  • Snippet - Norgate Data Element Processing.afl
    15.5 KB · Views: 27
Drawing Lines on charts, sounds pretty easy but can be frustrating if you want to connect to open price or close price etc. but line snaps to High or Low.

Well easy fix is to turn on snap to price and hold the relevant key down to to connect to O H L C

example

Turn on Snap to Price = upload_2020-8-3_20-14-6.png

Then select line ( or rectangle etc ) = upload_2020-8-3_20-14-33.png


Then hold down the 'C' key to connect to relevant close point . upload_2020-8-3_20-15-45.png


Happy drawing !
 
I wasn't sure if this post should go here, or in a Norgate Data thread. I guess it could go in both.

I had a "play" with accessing the Norgate Data "extras" Fundamental and Metadata functions, and created the attached AFL file. Just run it in the debugger and view the Output window.

I thought I'd post it here in case anyone else would be interested.

I ask a few questions in the program header. If you know the answers, or can suggest improvements to this code, please let me know.

Cheers...
Good work @Linus van Pelt as this is something that I have not experimented / utilised yet and will have a look at now. To answer one of your questions in the header I have found this.

1): I could not find where the actual field name is listed. For example, how to retrieve "Gold/Australian Dollar Spot Rate", "AU Unemployment Rate", or "Advance/Decline Ratio". If you know, please let me know.

Try the following mate

Symbols / Groups / Currencies & Currency Indices / XAUAUD

Symbols / Groups / Economic Data & Indices / #AUJOB

Symbols / Groups / Market Breadth Indicator / #ASXADR.au


So plenty of info available for us to play with but just need an application. How to link Fundamental and Technical Analysis togeteher.

Cheers
 
Can someone help me interpret this code?

Code:
Sell = Cross(Ref(EMA(L,50),-1),C)OR BarIndex()==(LastValue(BarIndex())-1)

I can understand the first part - it's seeing whether yesterday's low was below the 50 period EMA of lows....but I don't understand what the BarIndex part does - and the Amibroker F1 didn't really help me.
 
but I don't understand what the BarIndex part does

@TraderJimmy I am guessing that it detects that the stock is no longer trading (delisted)

upload_2020-8-20_10-2-23.png

with Norgate data you do not need to do this (as shown below)


How do I exit a position in a backtest prior to a stock being delisted?

Assuming a trade delay of 1 bar, you need to have an "exit" signal on the second last bar to simulate exiting a delisted stock. This will cause AmiBroker to exit the position on the final day of trading. You also want to avoid entering any new positions during the final 2 days.

OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );
 
Wondering if someone can help me - I seem to get inconsistent results with things like added columns in exploration or chart plot/notation. ie. the code I am running doesn't seem to find it's way to the out exploration or charts. The code is often shared from others and I can see their charts displaying properly, so it's unlikely the code.

I'm trialing Amibroker, is this a limitation? Or is there a setting I haven't selected?
 
Another tip that I've had some success with this week. When you're writing or testing a strategy - its good to output your buy/sell conditions and values to the explore columns. That way you verify the triggers for yourself.

I discovered this while testing a strategy, and I couldn't understand why I wasn't getting buy triggers for months on end. So I added columns to the explore output for each of the buy conditions. Then I could check why the buy wasn't being triggered.

To illustrate this, lets say you have:
  1. an index filter which is true or false, based on the market index being in an uptrend.
  2. A buy condition where the close needs to be above the 40 day EMA =of the stock
Add code like this to output values to your explore results.
AddColumn( indexFilter, "Weekly Index filter", 1 );
AddColumn( cond1, "Condition 1", 1 );
AddColumn( EMA ( C, 40), "40 day EMA", 1 );


You can see below that the output lets you see exactly which part of the trigger is and isn't being met.

upload_2020-9-4_11-52-20.png
 
Thanks @TraderJimmy, the columns thing is very helpful.

I have a question with my Amibroker - running the exploration in a test formula I've coded, for some reason it gives me a Buy Signal that's outside of my date range? I.E. Buy signal for 7th August when the Range is set to 1 recent day(s) and The date is 1st Sept to 5th Sept.

upload_2020-9-5_21-53-0.png

FYI
- it is a weekly system, and I ensured that the parameters in the explore setting is weekly,
and that my charts are also in the weekly view
- The Filter is set to All Ordinaries (ASX) from Norgate Data
 
@Nameless_ I have unsuccessfully tried to replicate your issue with a few of my test systems, so without your test formula it is impossible to answer your question.
 
@Nameless_ I have unsuccessfully tried to replicate your issue with a few of my test systems, so without your test formula it is impossible to answer your question.

@Trav. Thanks for looking into this - it's essentially a minimally modified version from one of the systems from Skate's Dump It Here thread as I was going through it and trying to learn how to code
 

Attachments

  • Nameless Test Formula.afl
    6.4 KB · Views: 17
@Nameless_ OK, I think that I have found the problem, and I will attempt to describe it below which may be a bit confusing on the first read :confused:

In your snip AJM is giving the problem and that is because they have been suspended from trading and their last trading day was the Friday 7/8/2020 which just happen to be a day that generated a Buy Signal in the code

From the ASX announcement page

upload_2020-9-6_4-52-3.png

Now this brings us to the problem of why the Explore results bring up AJM....

I suspect that you have Pad and Align Off in the Analysis Settings as per the default setting and when running the Explore set to 1 recent day it finds that the last recent day for AJM was on the 7/8 as per above.

Now if you use the pad and align feature in AmiBroker you will see that it fills the holes in the data with the last valid previous data.

http://www.amibroker.com/guide/w_settings.html

upload_2020-9-6_5-7-53.png

EXAMPLE on Pad & Align

By changing the Explore Filter to 1 as per below, turning on Pad & Align and then adding some range dates for the test you will see the newly added close column shows 0.07 for the period since AJM was delisted.

Filter = 1;//Buy OR Sell; // Buy & Sell Filters
AddColumn(Close, "Close");

upload_2020-9-6_5-27-19.png

upload_2020-9-6_5-24-59.png

To expand on this test I have included the before and after results when the Pad & Align feature is used.

Before

upload_2020-9-6_4-48-3.png


After

upload_2020-9-6_4-48-32.png



Now in figuring out the above Norgate has a different approach which I have not implemented yet but will do so later today.

https://norgatedata.com/amibroker-faq.php#padandalign

upload_2020-9-6_5-38-39.png

The below lines will are needed for the above to work

#include_once <..\Norgate Data\Norgate Data Functions.afl>;
Condition1 = NorgatePaddingStatusTimeSeries()==0;

Buy = Condition1 AND ...................normal buy conditions

Hopefully the above helps and if anyone else has some thoughts or better way to explain this then please chip in, as I am no expert here.

Cheers
 

Attachments

  • upload_2020-9-6_4-53-48.png
    upload_2020-9-6_4-53-48.png
    143.6 KB · Views: 8
  • upload_2020-9-6_5-5-12.png
    upload_2020-9-6_5-5-12.png
    12.2 KB · Views: 7
Top