Australian (ASX) Stock Market Forum

Amibroker FAQ

And another question guys:

Although not usually effective, in my manual testing and trading of a system I have evidence that a wide trailing stop is effective at getting me out at the end of a move. When I have tried to implement trailing stops in the past I have gotten very strange backtesting results in AB. I ran an extensive optimisation and the most profitable settings (by far) was trailing stop set at "0%".

Can anyone shed any light on exactly how AB executes a trailing stop set at 0%?

The way I see trailing stops is if you set it at say 5%, if your stock drops 5%after you buy it, you sell, and if you stock rises 20%, then drops 5% you sell, locking in 15% profit.

The stops are set to execute intraday but buy and sell signals are on the open.

Not sure how AB executes with a 0% trailing stop?

Thanks.
 
And another question guys:

Although not usually effective, in my manual testing and trading of a system I have evidence that a wide trailing stop is effective at getting me out at the end of a move. When I have tried to implement trailing stops in the past I have gotten very strange backtesting results in AB. I ran an extensive optimisation and the most profitable settings (by far) was trailing stop set at "0%".

Can anyone shed any light on exactly how AB executes a trailing stop set at 0%?

The way I see trailing stops is if you set it at say 5%, if your stock drops 5%after you buy it, you sell, and if you stock rises 20%, then drops 5% you sell, locking in 15% profit.

The stops are set to execute intraday but buy and sell signals are on the open.

Not sure how AB executes with a 0% trailing stop?

Thanks.

Forget the stuff about 0% trailing stop guys, just exits at the high for the day!

If you could assume to get out on the exact high of a particular day this game would be a lot easier hahaha.
 
Hi guys,

I want to have a buy condition in my system of:

Only buy if the sector EMA of a stock is rising.

Any ideas on how to code that in AFL? Best I can do is foreign in a sector index like XMJ and only backtest on materials stocks, is there a way to reference to the sector the stock belongs to?

I have premium data.

PHP:
Call = Foreign("XMJ", "Close");

XMJema = EMA(Call, 12); 
BuyQ = XMJema > Ref(XMJema, - 1);  //Open long stock position  

Buy = Ref(C>O, -1) & BuyQ;

Trouble is the reference period. Greater than yesterday could be 1 day in a down ward trend. Greater than 10 days ago could be a short rally in a downward trend.
Greater than 50 days ago could be at the top of an up trend. Shorter or longer there is no guarantee that a rising sector EMA is the right time to enter a stock purchase. Let me know if you have a magic rising period. ;)
 
PHP:
Call = Foreign("XMJ", "Close");

XMJema = EMA(Call, 12); 
BuyQ = XMJema > Ref(XMJema, - 1);  //Open long stock position  

Buy = Ref(C>O, -1) & BuyQ;

Trouble is the reference period. Greater than yesterday could be 1 day in a down ward trend. Greater than 10 days ago could be a short rally in a downward trend.
Greater than 50 days ago could be at the top of an up trend. Shorter or longer there is no guarantee that a rising sector EMA is the right time to enter a stock purchase. Let me know if you have a magic rising period. ;)

Hmmm the problem with that code is it does not adjust to the sector ema of the specific security. This is what I came up with for the sector EMA, not efficient but works:

PHP:
//Sector EMA

Sector = SectorID(0);



S1 = Foreign("XDK","C",True);

IIf(Sector == 1, SectorArray = S1, 0);


S2 = Foreign("XFDK","C",True);
IIf(Sector == 2, SectorArray = S2, 0);



S3 = Foreign("XENK","C",True);

IIf(Sector == 3, SectorArray = S3, 0);


S4 = Foreign("XENK","C",True);

IIf(Sector == 4, SectorArray = S4, 0);


S5 = Foreign("XHCK","C",True);

IIf(Sector == 5, SectorArray = S5, 0);


S6 = Foreign("XKI","C",True);

IIf(Sector == 6, SectorArray = S6, 0);


S7 = Foreign("XIK","C",True);

IIf(Sector == 7, SectorArray = S7, 0);



S8 = Foreign("XMJ","C",True);

IIf(Sector == 8, SectorArray = S8, 0);



S9 = Foreign("XTEK","C",True);

IIf(Sector == 9, SectorArray = S9, 0);


S10 = Foreign("XUK","C",True);

IIf(Sector == 10, SectorArray = S10, 0);

SectorEMA = EMA(SectorArray, 40);

Sector_EMA_direction = SectorEMA > Ref(SectorEMA , -1) AND Ref(SectorEMA , -1) > Ref(SectorEMA , -2) AND Ref(SectorEMA , -2) > Ref(SectorEMA , -3)  ;


And to overcome your problem of picking a point in time to determine EMA slope, I just make a contingent string of EMA refs!

PHP:
//Long Term EMA


//LTEMAP = Optimize("LTEMA Period", 60, 40, 100, 5);
LTEMAP = 60;

LTema = EMA(C, LTEMAP);
//At least 3 days of EMA rising in a row required
EMA_direction = LTema > Ref(Ltema, -1) AND Ref(LTema, -1) > Ref(LTema, -2) AND Ref(LTema, -2) > Ref(LTema, -3)  ;
 
Hmmm the problem with that code is it does not adjust to the sector ema of the specific security. This is what I came up with for the sector EMA, not efficient but works:
I simply scan stock in the sector of interest, not the whole ASX. Energy stocks, Material stocks, Industrial stocks etc.

And to overcome your problem of picking a point in time to determine EMA slope, I just make a contingent string of EMA refs!
Went down that path of testing for several weeks and came out none the wiser. Good luck with it.
 
You need some way to back fill quotes too. Like from your last quotes when Amibroker was opened.

I advertised on Freelancer.com for a DDE server script like the set up with Forex Meta Trader platform but received no takers. I tried QuoteTracker but it updates prices every 20 seconds one at a time so not live and the more stocks (over 100) the slower it is.

It can't be that hard surely to connect to real time (instant) price data for the whole exchange. I believe even Interactive Brokers throttles backfill such ...



and limited to 100 stocks. What the. :eek:


My simple direct data exchange (or Plug-in) requirements to Amibroker =

a) The whole ASX list
b) Real time, live, instant feed
c) At least 1 week of 1 minute backfill for the whole ASX list reasonably fast (don't want to have to log in 2 hours before market opens to backfill)

Some clever computer technician could make a business from this as there would be many Amibroker users that would buy the setup or pay a small monthly fee.




Me too, surely it cant be to hard, ive also had a look on free lancer for amibroker past jobs, hopeing someone had already dealt with this, i might have to go with IB i really only need my list of 40ish stocks that i can run alerts on

Cheers
 
Me too, surely it cant be to hard, ive also had a look on free lancer for amibroker past jobs, hopeing someone had already dealt with this, i might have to go with IB i really only need my list of 40ish stocks that i can run alerts on
Favourites from these alerts can be easily created in AB and the exploration or scan set to 1 second for constant scanning of the ASX. Day traders dream ticket.
 
Hi guys,

I've got a question regarding Grids. I've been pulling my hair out trying to figure this one out.

I'm trying to plot grids at 0.25 intervals for ES, but when i use the plotgrid function with the attached code, i end up getting my grid lines with values at different decimal places. For example I would get

1306
1306.25
1306.5
1306.75
1307

The whole thing gets misaligned on the Y axis and is difficult to read.

what I want to see is:
1306.00
1306.25
1306.50
1306.75
1307.00

I've tried round() function and still didn't get any result. Any help would be awesome.

Cheers!

Code:
_SECTION_BEGIN("GRID");
gridINCR = Param("incr",.50,0,1,0.0001);
if( ParamToggle("show custom grid", "NO|YES", 1) AND Interval()==60)
{
SetChartOptions(1,chartShowArrows|chartShowDates, 0);
firstbarvisible = BarIndex()==1 OR (Status("barvisible") AND NOT Ref(
Status("barvisible"), -1));
GridMIN = LastValue( LowestSince( firstbarvisible, round((Low-10)/10)*10 ) );
GridMAX = LastValue( HighestSince( firstbarvisible, round((High+10)/10)*10 ) );
steps = (GridMAX - GridMIN)/ gridINCR ;
for(i=0;i < steps;i++)
PlotGrid(GridMIN+i*gridINCR, ParamColor("Color", colorBlack) );

}
else

SetChartOptions(1,chartShowArrows|chartShowDates);
_SECTION_END();
 
Folks,

I was trying to set up a simple code to scan weekly ADX values and filter those based on values being higher than 25:

TimeFrameSet(inWeekly);
M = ADX(18);
TimeFrameRestore();

Filter = TimeFrameExpand(M, inWeekly) > 25;
AddColumn (TimeFrameExpand(M,inWeekly),"Weekly ADX value");


However, checking the stock this scan returns I've noticed that so called "Weekly ADX value" does not match the actual weekly ADX indicator value plotted below price graph.

Why is this happening?

Thanks in advance
 
Have you plotted in Weekly on the daily window?

Plot(TimeFrameExpand(ADX(18), inWeekly), "ADX Weekly", colorBlue);
 
However, checking the stock this scan returns I've noticed that so called "Weekly ADX value" does not match the actual weekly ADX indicator value plotted below price graph.

Why is this happening?
Thanks in advance
I know what you mean now. On this screen shot I have created a separate chart for weekly ADX line. As can be seen, the ADX line (time frame expanded) on the daily chart displays the ADX line for that period in weekly.

Observing the weekly ADX line over the same period on a separate weekly chart it is very different. Must be a reason but I don't know why. This can be overcome by creating a separate chart as I have done. File -> New -> Blank Chart
 

Attachments

  • untitled.jpg
    untitled.jpg
    177.7 KB · Views: 3
This can be overcome by creating a separate chart as I have done. File -> New -> Blank Chart

Hey Wysiwyg,

I'm not sure what do you mean by that. I've create a new chart as you said and relay two ADX, one is expanded weekly and the other one is just inserted ADX function on weekly timeframe.

Capture.JPG

As you can see they are close, almost identical in shape, by the values are different.

Do you get the same?
 
I have a strange problem. I have EOD data isntalled for today 19-5-11 but AB isn't reading it. It reads yesterday's, and every day before that, but not today. Any ideas? It was working this morning, and I don't think I've changed any settings.
 
Folks,

The PlotShape function provides a subfunction called offset that one can use to offset shapes where offset is measure in pixels. My code reads something like this:

PlotShapes(IIf((Bull AND L<KS),shapeHollowSmallUpTriangle,shapeNone),colorBlue);


However when I put offset after color selection my shapes disappear from screen.
What am I doing wrong?
 
Folks,

The PlotShape function provides a subfunction called offset that one can use to offset shapes where offset is measure in pixels. My code reads something like this:

PlotShapes(IIf((Bull AND L<KS),shapeHollowSmallUpTriangle,shapeNone),colorBlue);


However when I put offset after color selection my shapes disappear from screen.
What am I doing wrong?

You must follow the syntax exactly (computers are dumb).

PlotShapes( shape, color, layer = 0, yposition = graph0, offset = -12 );

So, for example:

PlotShapes( shapeUpArrow, colorRed, 0, L, -15 );
 
How would I change the colour of these bars to black?

Or would I have to post the entire code for someone to be able to tell me?

PTM.png
 
Top chart: plot( c, "", colorblack, stylebar);

Bottom chart: plot( c, "", colorblack, stylecandle ); and then change the up and down candle color in preferences >> colors
 
Top chart: plot( c, "", colorblack, stylebar);

Bottom chart: plot( c, "", colorblack, stylecandle ); and then change the up and down candle color in preferences >> colors

thanks for that.
At the moment this is the code I've got for the top chart. I've changed the color to black as you've said.
How can I add code so that up days are green and down days are red?

_SECTION_BEGIN("Chart");
Vcolor=IIf(tls>0 AND tlm>0 AND tll>0,colorWhite,IIf(tls>0 AND tlm>0 AND tll<0,colorWhite,
IIf(tls>0 AND tlm<0 AND tll<0,colorWhite,IIf(tls<0 AND tlm<0 AND tll<0,colorWhite,IIf(tls<0 AND tlm>0 AND tll>0,colorWhite,
IIf(tls<0 AND tlm<0 AND tll>0,colorWhite,colorWhite))))));
GraphXSpace = 5;
PlotOHLC( Null, High, Low, Close, "", colorBlack, styleBar | styleThick );

Thanks
 
Top