Australian (ASX) Stock Market Forum

Amibroker FAQ

It takes an exit the next bar after the buy because the variable "BuyPrice" is a reserved variable which is an array. You assign "Close" to the BuyPrice at the beginning of the formula outside the loop so on every iteration of the loop the variable "PriceatBuy" is assigned the close price of that particular bar. That's why your exits are triggered immediately after your entry.

Captian black, sorry. BuyPrice is an array, but PriceAtBuy no, it is a single number. It is created for to be single number.
I think "PriceAtBuy" only acquires a non-zero value inside the loop, when a buy signal (Buy = = 1) outside the loop. And "PriceAtBuy" retains this value until it is one of the other conditions in the rest of the loop is satisfied. That is the intent of the code. Am I wrong?
As I think that the code works? In the beginning in the code, the bars are being evaluated for buy signal. When a buy signal and reaches the loop, all bars from that which generated the buy signal are evaluated. If some condition is met, an action is generated. If not, move on to the end. I may be wrong about what I believe is the logic of program operation.

Thanks.
Edilson
 
Captian black, sorry. BuyPrice is an array, but PriceAtBuy no, it is a single number. It is created for to be single number.
I

I think you will find every variable defined in AB is an array. If you create a variable PriceAtBuy = 2, it will just create an array n periods long with every array element set to the value of 2.
 
Is it possible to have Amibroker draw price bars without the open tick, like Tradeguider. For intraday charts the open tic isn't that useful, and by not show it IMO makes the graph easier to read. Even MS.net charts package has an option to not draw the open tic.
Here is an example in Tradeguider
close dash.jpg
 
Is it possible to have Amibroker draw price bars without the open tick, like Tradeguider. For intraday charts the open tic isn't that useful, and by not show it IMO makes the graph easier to read. Even MS.net charts package has an option to not draw the open tic.

I use something similar to the code below on a modified Amibroker VPA chart:

Code:
PlotOHLC (Null, High, Low, Close, "" , ColorBlack, StyleBar|StyleThick );
This code plots thick, black bars. I use coloured bars to give an indication of the trend and volume etc.
 
I think you will find every variable defined in AB is an array. If you create a variable PriceAtBuy = 2, it will just create an array n periods long with every array element set to the value of 2.

I've read a document here in AUSSIE: "Looping in Amibroker AFL". It is clear in this question about array and single number and it's my suggestion.

Thanks.
Edilson
 
Code:
PlotOHLC (Null, High, Low, Close, "" , ColorBlack, StyleBar|StyleThick );
This code plots thick, black bars. I use coloured bars to give an indication of the trend and volume etc.

Thanks that works fine, replacing ColorBlack, I can get different colours based on open and close.
Code:
IIf(C>O, IIf(H>C, colorRGB(72,170,222), colorRGB(53,83,218)), IIf(L<C, colorRGB(245,170,13), colorRGB(227,43,36)))
 
Thanks that works fine, replacing ColorBlack, I can get different colours based on open and close.
Code:
IIf(C>O, IIf(H>C, colorRGB(72,170,222), colorRGB(53,83,218)), IIf(L<C, colorRGB(245,170,13), colorRGB(227,43,36)))

It's worth having a look at Karthik's VPA code as well to pick up a few ideas. It uses LinRegSlope calculations to change the bar colours depending on whether price is trending or in accumulation/distribution zones. I also have bars with extreme volume a particular colour as well.
 
It's worth having a look at Karthik's VPA code as well to pick up a few ideas. It uses LinRegSlope calculations to change the bar colours depending on whether price is trending or in accumulation/distribution zones. I also have bars with extreme volume a particular colour as well.
I looked at it sometime back and looked to complicated, but I do use my own method for classifying relative volume.
 
I'm interested in identifying the value of the line signal of the MACD in the penultimate top. In the last one I am using the function ValueWhen (LastTop, Signal ()).
Could anyone help me?

Thanks.
Edilson
 
I'm interested in identifying the value of the line signal of the MACD in the penultimate top. In the last one I am using the function ValueWhen (LastTop, Signal ()).
Could anyone help me?

Thanks.
Edilson

Hi Edilson --

ValueWhen has three parameters. From the AmiBroker Useer's Guide:

-----------------

VALUEWHEN
- get value of the array when condition met Trading system toolbox
(AFL 1.1)


SYNTAX valuewhen(EXPRESSION, ARRAY, n = 1)
RETURNS ARRAY
FUNCTION Returns the value of the ARRAY when the EXPRESSION was true on the n -th most recent occurrence. Note: this function allows also 0 and negative values for n - this enables referencing future
EXAMPLE valuewhen( cross( close, ma(close,5) ) ,macd(), 1)

--------------

If it is omitted, the third parameter has a default value of 1. To return the value one occurrence earlier, use a 2.

Your example would be:
xxx = ValueWhen (LastTop, Signal (), 2);

Thanks,
Howard
 
Hi Edilson --

ValueWhen has three parameters. From the AmiBroker Useer's Guide:

-----------------

VALUEWHEN
- get value of the array when condition met Trading system toolbox
(AFL 1.1)


SYNTAX valuewhen(EXPRESSION, ARRAY, n = 1)
RETURNS ARRAY
FUNCTION Returns the value of the ARRAY when the EXPRESSION was true on the n -th most recent occurrence. Note: this function allows also 0 and negative values for n - this enables referencing future
EXAMPLE valuewhen( cross( close, ma(close,5) ) ,macd(), 1)

--------------

If it is omitted, the third parameter has a default value of 1. To return the value one occurrence earlier, use a 2.

Your example would be:
xxx = ValueWhen (LastTop, Signal (), 2);

Thanks,
Howard

Howard,
Thank you.
Edilson
 
Tried searching but had no luck. Trying to view a weekly and daily chart of the same stock in different panes but on the same sheet in Amibroker. :S Help?
 
Boofis...Is this what you are after:

SetChartBkGradientFill(colorWhite,colorLightGrey,colorWhite);
Period= ParamList("Base","Monthly|Weekly|Daily|Hourly|15Minute|5Minute|1Minute",0);

if(Period=="Monthly"){
TimeFrameSet(inMonthly);
PlotOHLC(Open, High, Low, Close, "Monthly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Weekly"){
TimeFrameSet(inWeekly);
PlotOHLC(Open, High, Low, Close, "weekly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Daily"){
TimeFrameSet(inDaily);
PlotOHLC(Open, High, Low, Close, "Daily Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="Hourly"){
TimeFrameSet(inHourly);
PlotOHLC(Open, High, Low, Close, "Hourly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="15Minute"){
TimeFrameSet(in15Minute);
PlotOHLC(Open, High, Low, Close, "15Minute Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="5Minute"){
TimeFrameSet(in5Minute);
PlotOHLC(Open, High, Low, Close, "5Minute Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}
if(Period=="1Minute"){
TimeFrameSet(in1Minute);
PlotOHLC(Open, High, Low, Close, "1Minute Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}



Cheers
 
SetChartBkGradientFill(colorWhite,colorLightGrey,colorWhite);
Period= ParamList("Base","Monthly|Weekly|Daily|Hourly|15Minute|5Minute|1Minute",0);

if(Period=="Monthly"){
TimeFrameSet(inMonthly);
PlotOHLC(Open, High, Low, Close, "Monthly Price Chart", colorBlack, style = styleCandle | styleOwnScale);
Plot(V,"Volume",colorWhite, styleHistogram);
}.....

Appreciate it, thanks mate. Yeah got the error when I entered it, no dramas!
 
Hi,

Can Amibroker import market depth from a live intra-day data feed?

I was thinking it would be nice to have a custom indicator say "buyers:sellers ratio" or "best buy vs best sell".

If it's possible, can this data be included in a scan/exploration? eg. scan for stocks where # best buyers > # best sellers.

I know some data feeds can provide this info, just not sure if AB can use it.

Thanks.
 
Can anyone help me with restricting my symbols to those with only 3 characters?

Either in the importing of the data initially or in the coding where the buy's are selected.

I'd prefer it to be done when I import the data if possible...
 
Can anyone help me with restricting my symbols to those with only 3 characters?

Either in the importing of the data initially or in the coding where the buy's are selected.

I'd prefer it to be done when I import the data if possible...

To filter symbols to 3 characters in code use:

Code:
Buy = StrLen ( Name () ) == 3;
 
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?
 
Top