Australian (ASX) Stock Market Forum

Amibroker FAQ

Using close price in relation to DEMA 250 this way references close price of stock and not foreign index.

SetForeign( ParamList("Index","^AORD | ^GSPC"), True, True );

X1 = DEMA(C, 250);
X2 = C > X1; //Open long stock positions
X3 = C < X1; //Open short stock positions

RestorePriceArrays(True);

X1 and X2 and X3 arrays are filled inside the SetForeign function and therefore reference only the Foreign ticker.

Running my code in the backtester on just WOW I get short entries on 21/01/09 and 5/03/2009. No entry in June.
 
Okay captain I will have to give it some breathing space. Thanks for your help.

Wish you an enjoyable long weekend. :)
 
Anyone know how I can make it so the value of a line is drawn on the line on the actual chart rather than in the axis?

Also, if its possible to create a scan to determine how many times price touches a certain line?
 
Hi

Can anyone please help me code a ATR trailing stop for amibroker. Im after 2*ATR(10);

I have a applystop which works for backtesting I think but I want to view a stop on the chart. The only trailing stop that I have is a percent based one and I have no idea how to code a ATR based one. This is the percent based one that I have

HTML:
StopLevel = 1 - Param("trailing stop %", 3, 0.1, 10, 0.1)/100;

Buy = Cross( MACD(), Signal() );
Sell = 0;
trailARRAY = Null;
trailstop = 0;

for( i = 1; i < BarCount; i++ )
{

   if( trailstop == 0 AND Buy[ i ] )
   {
      trailstop = High[ i ] * stoplevel;
   }
   else Buy[ i ] = 0; // remove excess buy signals

   if( trailstop > 0 AND Low[ i ] < trailstop )
   {
      Sell[ i ] = 1;
      SellPrice[ i ] = trailstop;
      trailstop = 0;
   }

   if( trailstop > 0 )
   {
      trailstop = Max( High[ i ] * stoplevel, trailstop );
      trailARRAY[ i ] = trailstop;
   }

}

PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);

Plot( Close,"Price",colorBlack,styleBar);
Plot( trailARRAY,"trailing stop level", colorRed );

Thanks
 
Here's an example of displaying a 2*ATR(10) stop using ApplyStop.

Code:
ApplyStop(stopTypeTrailing, stopModePoint, 2*ATR(10), True, True );
PlotShapes( IIf(Sell==4, shapeHollowDownArrow, shapeNone), colorBlue, 0,H);//trailstop
Equity(flag=1, rangetype=0);
 
Hi guys, I currently have a NYSE database where I download EOD data from Yahoo. If a share traded a volume of 100M shares, Yahoo data shows 100M in Amibroker.

I tried this morning to get IB feed into the database, however IB seems to report NYSE volume in a 100th of actual volume, ie the 100M shares from above is only reported as 1M. As you can see this really stuffs up the volume if I combine the two different data.

I was wondering is there a way to either get all IB volume to be multiplied by a 100, or divide all existing volume as a 100th of actual number, specifically only for this database without affecting my other databases?

Thanks very much for any assistance :eek:
 
I'd be wary of combining data from 2 different sources into one database but that's just my personal preference.

One way to get the yahoo volume data in a format the same as IB would be to export your database files as ASCII files using an exploration then reimport them with the ASCII importer with a command to divide volume by 100.

Here's a list of commands for ASCII import. There's a few there that will reference and adjust the volume.

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

As with all things Amibroker-ish there's many ways to skin a cat, someone else may have a simpler solution. :)
 
Wow, what a great thread.
I myself use amibroker and love how the software is so customizable to each trading style and system etc.
I look forward to reading & learning more about amibroker in this thread.
Cade
 
Hi I am new to Amibroker and have a lot of learning to do on AFL. I have the following time based sell formula which uses closing prices:

Sell = 0; //no regular sell signals
ApplyStop( stopTypeNBar, stopModeBars, 4);

Can anyone help me to alter it to use open prices?

Also could anyone translate the first line for me into plain speech and explain what it does to the formula?

Any help will be much appreciated.

Andy
 
Hi I am new to Amibroker and have a lot of learning to do on AFL. I have the following time based sell formula which uses closing prices:

Sell = 0; //no regular sell signals
ApplyStop( stopTypeNBar, stopModeBars, 4);

Can anyone help me to alter it to use open prices?

You would need to set Sellprice to open.

Code:
SellPrice = Open;
Also could anyone translate the first line for me into plain speech and explain what it does to the formula?

It sets your formula to only exit a position using the ApplyStop criteria. ie. All positions will be exited after 4 bars, there are no other "Sell" criteria.
 
Hi all,

Any ideas on how I might go about writing a time based exit? Trying to test the
following -

Exit when - stock hasn't risen by x% within y days/bars

I have seen ApplyStop being used, but keen to use an alternative if possible.

Cheers
S
 
How about this -

In english:

Sell when -
1. the number of bars since purchase are greater or equal to the hold period
AND
2. the percentage change of the current close compared to the 1st close since purchase is < the minimum required increase


In psuedo amibroker:

Sell when:
Sell = BarsSince(Buy) >= HoldPeriod AND (C - Ref(C,- HoldPeriod))/ Ref(C,- HoldPeriod) < Min%Increase (e.g. +5%);

Cheers
S
 
Hi,

I am trying to run a backtest. Assuming I set a position size, what happens if I can only purchase 1 new position on any given day and the exploration / scan criteria returns 5 possibilities?

Does the backtester just choose the first (alphabetically speaking) candidate and buy that?

Are there any options to refine this?

Thanks!!
 
How about this -

In english:

Sell when -
1. the number of bars since purchase are greater or equal to the hold period
AND
2. the percentage change of the current close compared to the 1st close since purchase is < the minimum required increase


In psuedo amibroker:

Sell when:
Sell = BarsSince(Buy) >= HoldPeriod AND (C - Ref(C,- HoldPeriod))/ Ref(C,- HoldPeriod) < Min%Increase (e.g. +5%);

Cheers
S

Hi there,

2 1/2 hours worth ( very much a newbie) .... just check the % is accurate after a run.

Hold for minimum of 10 bars and Sell if Close of 10 th bar is less than 10 % Higher than Buy Open Price or Sell when Condition met.

PHP:
 Buy = Cross(MACD(), Signal()); 
 
 Entry = ValueWhen(Buy, O);
 Rule1 = C < 1.10 * Entry;
 Rule2 = SetOption("HoldMinBars", 10);
 Exit = IIf(Rule1, 1, 0);
 
 Sell = IIf(Rule1 = Rule2, ApplyStop(stopTypeLoss, stopModePercent, Exit, 1,  True), 0) OR Cross(Signal(), MACD());
 
Hiya Wysiwyg,

Thanks for your conversion! :) I might try some of your code tonight.

I had a crack last night and, on the surface, managed to get it going as well - although my code was pretty much what I had posted. Interesting that there are many ways to 'skin the cat'.

I plan on checking out the trades a bit deeper to ensure it is doing what I expect.

I have a trailing ATR stop which is working well and have now added the time stop - with the little testing I did, the results were inconclusive. Did is improve yours at all? (I am trying to tighten up my system by removing trades that aren't progressing as I expect...)

Cheers :)
S
 
Top