Amibroker - Learning how to use

mindgames

Well-Known Member
#21
I have an AFL code for SuperTrend

I want to change the parameters- PERIOD & MULTIPLIER.
Can anyone tell when what to search for in the code so that I can replace with my own numbers.

Thanks
I don't know about this AFL. You can try this:

1. Get into edit formula mode and just go through it, you should be able to locate (just copy it on to word and do a ctrl+f for the existing no.)

2. Or right click and go to parameters - you will get to know what the period and multiplier are called in the formula. Based on this, you can locate and change the no.

Do save a version of the formula before you edit it.
 

mindgames

Well-Known Member
#22
Replicating a chart

In Amibroker, we have multiple worksheets. Sometimes it may happen that we use the same chart on multiple worksheets - eg. price chart in multiple sheets, comparing with RSI, ADX, MACD etc. in their respective sheets.

Let's say you have TLs / support etc. drawn on a sheet. Instead of drawing the same in each of the sheets, do the following:

1. In the original sheet, click on the pane you want to be replicated - eg. Price
2. Edit > Copy
2. Go to the sheet where you want the replicated sheet.
3. Edit > Paste Special
4. Select "Entire chart pane (hard-wired, shared parameters........., same chartID)"

That's it. Now anything you draw on any of the charts will be automatically reflected in the other sheets as well!

The point here is that the chart in each of the sheets will have the same chartID.
 

mindgames

Well-Known Member
#23
Addcolumn function

This function can be used to get data with Exploration. It would give a report with 'columns' containing details that you want to be extracted / computed.

SYNTAX: AddColumn(array,name,format =1.2,textColor=colorDefault,bkgndColor=colorDefault);
1. Array can be pre-defined Amibroker array (OHLCV) or user defined variable in formula editor.
2. Name is your column head. To be specified in quotes.
3. Format refers to no. of decimals for numbered data. 1.2 means 2 decimals, 1.3 means 3 decimals...and so on.
4. textcolor and bkgndcolor can be used if want report with colors.

Example
Filter = 1;
Addcolumn(Close, "Close price", 1.2);

When you run this as an exploration, you would get stock-wise closing price with 2 decimals.

Ps: Filter=1 is used to return ALL symbols and quotes (in your Exploration criteria). Alternatively, we can use it to return stocks meeting criteria of particular volume, closing price, range etc...
 
Last edited:

mindgames

Well-Known Member
#24
Ref function

Refer previous post. There we used "addcolumn" to get closing prices of stocks.

Now, say we want to get prices over a period (eg. weekly price

Using the Ref function, we can get prices of specific dates.

Syntax: Ref(Array, period)

1. Array can be pre-defined from Amibroker or user defined variable
2. Period is the look-back period for which you want data to be returned.

Example:

Filter = 1;

Close1 = Ref(Close,-5);
Close2 = Ref(Close,-10);

AddColumn(Close,"Close",1.2);

AddColumn(Close1,"1 week",1.2);
AddColumn(Close2,"2 weeks",1.2);
The above code, when run as an exploration, will give stock wise closing prices: As of selected date / 5 bars earlier than that date / 10 bars earlier than that date
 

vijkris

Learner and Follower
#25
Addcolumn function

This function can be used to get data with Exploration. It would give a report with 'columns' containing details that you want to be extracted / computed.

SYNTAX: AddColumn(array,name,format =1.2,textColor=colorDefault,bkgndColor=colorDefault);
1. Array can be pre-defined Amibroker array (OHLCV) or user defined variable in formula editor.
2. Name is your column head. To be specified in quotes.
3. Format refers to no. of decimals for numbered data. 1.2 means 2 decimals, 1.3 means 3 decimals...and so on.
4. textcolor and bkgndcolor can be used if want report with colors.

Example
Filter = 1;
Addcolumn(Close, "Close price", 1.2);

When you run this as an exploration, you would get stock-wise closing price with 2 decimals.

Ps: Filter=1 is used to return ALL symbols and quotes (in your Exploration criteria). Alternatively, we can use it to return stocks meeting criteria of particular volume, closing price, range etc...
Filter = 1 returns all quotes,
Filter = Status("lastbarinrange"); will return only latest quotes , preferably 1 day, thus exploration window looks less cluttered.
 

mindgames

Well-Known Member
#26
Lookup function

Refer to previous 2 posts. We used Addcolumn to get a report from Amibroker and used Ref to get data for a particular lookback period.

Lookup function helps us to get data for a particular date/time.

Syntax:
Lookup(array,_DT("Caption"),mode);

1. Array - usual rules
2. Caption must be defined in the formula
3. Mode:

If 0: finds exact match, otherwise returns Null
If -1 or -2: finds exact match, otherwise returns nearest predecesor or nearest predecessor EXCEPT the very last bar (i.e. the bar before that)
If 1 or 2: finds exact match, otherwise returns nearest successor or nearest successor EXCEPT the very first bar (i.e. the bar after that)

Example:
Filter = 1;

Week1 = "7/29/2016";
Week2 = "7/22/2016";

//This section will lookup the Close values for the dates defined above//
Close1 = Lookup(Close, _DT(Week1),-1);
Close2 = Lookup(Close, _DT(Week2),-1);

AddColumn(Close,"Close",1.2);

AddColumn(Close1,"1 week",1.2);
AddColumn(Close2,"2 weeks",1.2);
 

mindgames

Well-Known Member
#27
Plot function

This function helps to "plot" graphs. The syntax for this defines various aspects such as color, 'style', etc.

Syntax:
Plot(array,name,color/barcolor,style=styleLine,1);

1. Array - Refers to "what" you want to plot. Could be predefined (OHLCV) or user defined (to be declared as a variable).
2. Name - Mention what you want the name of the indicator to be. The same will be displayed on top of the indicator.
3. Color - Used to define the color in which the graph is to be plotted (Refer user manual for color options).
4. Style - Used to define the nature of the graph. Eg. Line, Histogram etc. It is also used to define the way the graph is plotted - thickness, dashed, dotted, etc. Refer manual for various options available)

Example
Using, Plot function, the existing MACD indicator can be modified so that the histogram shows green bars for increase in histogram value and red bars for decrease in histogram value.

_SECTION_BEGIN("MACD");

//Declaring variables - i.e. the averages and signal line
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

//Plotting MACD line and Signal line
Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );

//Defining histogram conditions for coloring
a = ml-sl;
a1 = Ref(a,-1);

//Histogram Color conditions
HistogramColor = IIf (a > a1,colorBrightGreen,colorRed);

//Plotting MACD Histogram
Plot( a, "MACD Histogram", HistogramColor, styleNoTitle | styleHistogram | styleNoLabel | styleThick, maskHistogram);

_SECTION_END();
 
Last edited:

mindgames

Well-Known Member
#28
Adjusting a quote

Sometimes, one may want to edit the quote for a particular day - eg. adjust for demerger prices, double volume, any other reason...

Select that scrip > Symbol > Quote Editor > Select particular quote and edit
 

hir0406

Active Member
#29
hey ,
i have one question if any one can help.....
i am using amibroker 5.50.5
in that i am using simple moving avg. can someone pls tell me how can i increase the thickness of this moving average's.......
 

vijkris

Learner and Follower
#30
hey ,
i have one question if any one can help.....
i am using amibroker 5.50.5
in that i am using simple moving avg. can someone pls tell me how can i increase the thickness of this moving average's.......
You can use "style thick"(if available), option in parameter settings.
 

Similar threads