Australian (ASX) Stock Market Forum

Amibroker FAQ

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
My back testing had less than exciting results over various historical time zones.

The time vs. price appreciation issue has a few questions to consider.
If the stock has not continued in the anticipated way ...

a) is the stock in a consolidation phase?
b) am I giving any stock enough time to appreciate in price?
c) am I over trading?
d) is good news expected soon?

I can be very patient and I can be very impatient.
 
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!!

Hi australindgirl and welcome :)

Amibroker, by default will choose new positions alphabetically. To change this you need to use PositionScore.

The guide to Portfolio level backtesting is a must read:

http://www.amibroker.com/guide/h_portfolio.html
 
Hi all...need some help Thanks
I'm very new at this and have downloaded Amibroker. Also had a look around for AFL's and come across this one, it doesnt run as the error is on this line:
else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND Ref
Error Message
Ln:53,Col:14 : Error30, Syntax Error

Thank you very much for any help.



_SECTION_BEGIN("CandlePatternTest");

global O, H, L, C;
O1 = Ref(O,-1);O2 = Ref(O,-2);
H1 = Ref(H,-1);H2 = Ref(H,-2);
L1 = Ref(L,-1);L2 = Ref(L,-2);
C1 = Ref(C,-1);C2 = Ref(C,-2);
global PatternName;
if(P = 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND(O-C)/(.001+H-L)>.6); }
else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND((H-L)>(3*(O-C)))); }
else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND((C-O)/(.001+H-L)>.6)); }
else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND((H-L)>(3*(C-O)))); }
else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND C==L); }
else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND O==L); }
else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND C==L); }
else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND C==H); }
else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND O==H); }
else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND O==L); }
else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND ((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND (((C-L)/(.001+H-L))<.4)); }
else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND ((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND (((O-L)/(.001+H-L))<.4)); }
else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1) AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND ((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND ((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND (O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND (C<C1)); }
else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1) AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND ((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND (C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND (C>C1)); }
else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O) AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND (C>C1) AND (O>O1)); }
else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND ((C-O)/(.001+(H-L))>0.6)); }
else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2) AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND (C<C1) AND (O<O1)); }
else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND (O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND (((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND (MA(C,13)-Ref(MA(C,13),-4)>0); }
else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND (O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1) AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2) AND (((C2-L2)/(H2-L2))<.2); }
else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
else if(P == 37) { PatternName = "GapUp"; Pv = GapUp(); }
else if(P == 38) { PatternName = "GapDown"; Pv = GapDown(); }
else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
else if(P == 43) { PatternName = "DoubleGapUp"; Pv = GapUp() AND Ref(GapUp(),-1); }
else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND Ref(GapDown(),-1); }
return Pv;
_SECTION_END();
 
Your formula is missing some lines. Try this:

Code:
function CandlePattern(P)
   {
    global O, H, L, C;
    O1 = Ref(O,-1);O2 = Ref(O,-2);
    H1 = Ref(H,-1);H2 = Ref(H,-2);
    L1 = Ref(L,-1);L2 = Ref(L,-2);
    C1 = Ref(C,-1);C2 = Ref(C,-2);
   global PatternName;
   if(P == 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
   else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
   else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND
(O-C)/(.001+H-L)>.6); }
   else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND
((H-L)>(3*(O-C)))); }
   else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
   else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND
((C-O)/(.001+H-L)>.6)); }
   else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND
((H-L)>(3*(C-O)))); }
   else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND
C==L); }
   else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND
O==L); }
   else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND
C==L); }
   else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND
C==H); }
   else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND
O==H); }
   else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND
O==L); }
   else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND
((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
   else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND
((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
   else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))
AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
   else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))
AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
   else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND
((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND
(((C-L)/(.001+H-L))<.4)); }
   else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND
((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND
(((O-L)/(.001+H-L))<.4)); }
   else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1)
AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
   else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)
AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND
((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
   else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND
((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
   else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND
(O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
   else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND
(C<C1)); }
   else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1)
AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
   else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND
((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
   else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND
(C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
   else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND
(C>C1)); }
   else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O)
AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
   else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND
(C>C1) AND (O>O1)); }
   else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND
(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6)); }
   else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)
AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
   else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND
(C<C1) AND (O<O1)); }
   else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)
AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND
(O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND
(((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
   else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND
(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND
(MA(C,13)-Ref(MA(C,13),-4)>0); }
   else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND
(O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1)
AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2); }
   else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
   else if(P == 37) { PatternName = "GapUp"; Pv = GapUp(); }
   else if(P == 38) { PatternName = "GapDown"; Pv = GapDown(); }
   else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
   else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
   else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
   else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
   else if(P == 43) { PatternName = "DoubleGapUp"; Pv = GapUp() AND
Ref(GapUp(),-1); }
   else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND
Ref(GapDown(),-1); }
   return Pv;
   }
 
hi,
i just found this code, daily/weekly/monthly pivot points
i removed the daily pivots and im having trouble trying to change the code so that the weekly and monthly automatically change each week. so i can look at th history and so it projects the next week when it changes.
Also does anyone know how i would add in another pivot, say 2 weeks??
any help would be great as im struggling with AFL
heres the code i have

_SECTION_BEGIN("pivots mw");
/***************************************/
/*SUPER PIVOT POINTS ver 1.3 day week month
by Avi b a
/***************************************/
/*
SUPER PIVOT POINTS can by used in 2 ways:
if you choose daily, the pivots are calculated from the previous day,
this can be used for daily charts.
the second option is next day for EOD charts.
for all the options available right click on the chart parameters.
to utilize all the program features you need amibroker from version 4.80.1 and above.
enjoy!
*/
/*-----------------data------------------*/
SetChartBkColor(16 ) ;
k=IIf(ParamList("select type","daily|next day")=="daily",-1,0);
k1=-1;


TimeFrameSet(inWeekly);
Week_h= LastValue(Ref(H,K1));
Week_l= LastValue(Ref(L,K1));;
Week_c= LastValue(Ref(C,K1));;
TimeFrameRestore();

TimeFrameSet(inMonthly);
month_h= LastValue(Ref(H,K1));
month_l= LastValue(Ref(L,K1));
month_c= LastValue(Ref(C,K1));
TimeFrameRestore();

/*--------------------------------------*/
// day
DH=Day_h;
DL=Day_L;
DC=Day_C;


// week
WH=Week_h;
WL=Week_l;
WC=Week_c;

// WEEK PIVOT Calculation
pw = ( WH+ WL + WC )/3;
sw1 = (2*pw)-WH;
sw2 = pw -(WH - WL);
sw3 = Sw1 - (WH-WL);
rw1 = (2*pw)-WL;
rw2 = pw +(WH -WL);
rw3 = rw1 +(WH-WL);

// month
MH=month_h;
ML=month_l;
MC=month_c;

// MONTH PIVOT Calculation
pm = ( MH+ ML + MC )/3;
sm1 = (2*pm)-MH;
sm2 = pm -(MH - ML);
sm3 = Sm1 - (MH-ML);
rm1 = (2*pm)-ML;
rm2 = pm +(MH -ML);
rm3 = rm1 +(MH-ML);

/*--------------------------------------*/
// PARAMETERS
slide = Param("slide all",33,-1000,1000,1);
slide1 = Param("slide_day",50,0,1000,1);
slide2 = Param("slide_week",70,0,1000,1);
slide3 = Param("slide_month",90,0,1000,1);
slide_Hight = Param("slide_Hight",0,-1000,1000,1);


SHALD = ParamList("daily Pivots", "all|selected only|hide" );
SHALW = ParamList("weekly Pivots", "selected only|all|hide" );
SHALM = ParamList("monthly Pivots", "selected only|all|hide" );

//week
PWP = ParamList("WP", "SHOW|HIDE" );
PWR1 = ParamList("WR1", "SHOW|HIDE" );
PWR2 = ParamList("WR2", "HIDE|SHOW" );
PWR3 = ParamList("WR3", "HIDE|SHOW" );

PWS1 = ParamList("WS1", "SHOW|HIDE" );
PWS2 = ParamList("WS2", "HIDE|SHOW" );
PWS3 = ParamList("WS3", "HIDE|SHOW" );

//month
PMP = ParamList("MP", "SHOW|HIDE" );
PMR1 = ParamList("MR1", "SHOW|HIDE" );
PMR2 = ParamList("MR2", "HIDE|SHOW" );
PMR3 = ParamList("MR3", "HIDE|SHOW" );

PMS1 = ParamList("MS1", "SHOW|HIDE" );
PMS2 = ParamList("MS2", "HIDE|SHOW" );
PMS3 = ParamList("MS3", "HIDE|SHOW" );

DayCOLOR = 34;
weekCOLOR =10;
monthCOLOR =42;
/*--------------------------------------*/
// LABELS
for( i = 0; i < BarCount; i++ )
{


//week
if(i+slide2== BarCount && (PWP=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly Pivot "+pw ,i+slide,pw+slide_Hight ,weekCOLOR );
if(i+slide2== BarCount && (PWR1=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly R1 "+rw1 ,i+slide,rw1+slide_Hight ,weekCOLOR );
if(i+slide2== BarCount && (PWR2=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly R2 "+rw2 ,i+slide,rw2+slide_Hight ,weekCOLOR );
if(i+slide2== BarCount && (PWR3=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly R3 "+rw3 ,i+slide,rw3+slide_Hight ,weekCOLOR );

if(i+slide2== BarCount && (PWS1=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly S1 "+sw1 ,i+slide,sw1+slide_Hight ,weekCOLOR );
if(i+slide2== BarCount && (PWS2=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly S2 "+sw2 ,i+slide,sw2+slide_Hight ,weekCOLOR );
if(i+slide2== BarCount && (PWS3=="SHOW" OR SHALW=="all")&& SHALW!="hide") PlotText( "weekly S3 "+sw3 ,i+slide,sw3+slide_Hight ,weekCOLOR );
//month
if(i+slide3== BarCount && (PMP=="SHOW" OR SHALM=="all")&& SHALM!="hide") PlotText( "monthly Pivot "+pm ,i+slide,Pm+slide_Hight ,monthCOLOR );
if(i+slide3== BarCount && (PMR1=="SHOW" OR SHALM=="all")&& SHALM!="hide") PlotText( "monthly R1 "+rm1 ,i+slide,rm1+slide_Hight ,monthCOLOR );
if(i+slide3== BarCount && (PMR2=="SHOW" OR SHALM=="all")&& SHALM!="hide") PlotText( "monthly R2 "+rm2 ,i+slide,rm2+slide_Hight ,monthCOLOR );
if(i+slide3== BarCount && (PMR3=="SHOW" OR SHALM=="all")&& SHALM!="hide") PlotText( "monthly R3 "+rm3 ,i+slide,rm3+slide_Hight ,monthCOLOR );

if(i+slide3== BarCount && (PMS1=="SHOW" OR SHALM=="all")&& SHALM!="hide")PlotText( "monthly S1 "+sm1 ,i+slide,sm1+slide_Hight ,monthCOLOR);
if(i+slide3== BarCount && (PMS2=="SHOW" OR SHALM=="all")&& SHALM!="hide") PlotText( "monthly S2 "+sm2 ,i+slide,sm2+slide_Hight ,monthCOLOR );
if(i+slide3== BarCount && (PMS3=="SHOW" OR SHALM=="all")&& SHALM!="hide") PlotText( "monthly S3 "+sm3 ,i+slide,sm3+slide_Hight ,monthCOLOR );
}
/*--------------------------------------*/
// PLOTS
style = IIf(ParamList("Chart style", "styleCandle|styleBar")=="styleCandle",64,128);
Plot (C,Date ()+" close",11,style);


//week
if ((PWP=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (pW,"weekly Pivot ",weekCOLOR,1);
if ((PWR1=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (rw1,"weekly R1 ",weekCOLOR,32);
if ((PWR2=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (rw2,"weekly R2 ",weekCOLOR,32);
if ((PWR3=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (rw3,"weekly R3 ",weekCOLOR,32);

if ((PWS1=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (sw1,"weekly S1 ",weekCOLOR,32);
if ((PWS2=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (Sw2,"weekly S2 ",weekCOLOR,32);
if ((PWS3=="SHOW" OR SHALW=="all") && SHALW!="hide") Plot (Sw3,"weekly S3 ",weekCOLOR,32);

//month
if ((PMP=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (pm,"monthly Pivot",monthCOLOR ,1);
if ((PMR1=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (rm1,"monthly R1",monthCOLOR ,32);
if ((PMR2=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (rm2,"monthly R2",monthCOLOR ,32);
if ((PMR3=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (rm3,"monthly R3",monthCOLOR ,32);

if ((PMS1=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (sm1,"monthly S1",monthCOLOR ,32);
if ((PMS2=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (sm2,"monthly S2",monthCOLOR ,32);
if ((PMS3=="SHOW" OR SHALM=="all") && SHALM!="hide") Plot (sm3,"monthly S3",monthCOLOR ,32);
/*--------------------------------------*/
// TEXT
"high = "+H;
"low = "+L;
"close = "+C;
_SECTION_END();
 
Captain Black, many thanks for your reply. It was most helpful.

Given your knowledge of Amibroker and coding, do you have an opinion on the lack of monte carlo similation available in Amibroker?

I did read somewhere (I've been sooo busy googling) that you can set the postionscore to random (ie override the alphabetical selection) and then run manual iterations. I assume that you have to run many iterations and then crunch the numbers in excel, which seem like hard work.
 
Sorry, I have to ask this even though it's going to be a candidate for years dumbest question...... what's the difference between the "portfolio" backtester and the "custom" backtester??

Can some-one give me an example of both? I've been backtesting a system, but now I don't know if I'm using the portfolio backtester or the custom backtester.

See, told you it was a candidate and you didn't believe me!!
 
do you have an opinion on the lack of monte carlo similation available in Amibroker?

Native MCS capabilities in Amibroker would be great. The implementation of automated walk forward analysis a while ago made system building and testing much easier and from a personal point of view I find walk forward analysis provides me with better guidance to the robustness of a system. Some people use AB with Tradesim, I haven't used so don't have an opinion on it. A search of Monte Carlo in this forum (ASF) should provide some more info.

There is a request in the AB feedback centre for MCS. You'll need to login to access the feedback centre. Feel free to add a comment there.

http://www.amibroker.com/feedback/view_bug.php?bug_id=232

I did read somewhere (I've been sooo busy googling) that you can set the postionscore to random (ie override the alphabetical selection) and then run manual iterations. I assume that you have to run many iterations and then crunch the numbers in excel, which seem like hard work.

There is an MCS spreadsheet in the Amibroker Yahoo mailing list files section. You'll need to login to the group to access it.

http://finance.groups.yahoo.com/group/amibroker/files/MonteCarlo PortfolioBacktester/

There is a ReadMe file in the MCS zip file that explains how to use it.

There's also Equity Monaco from TickQuest which provides basic MCS graphs. Haven't used it for a long time but it should accept output from Amibroker.

http://www.tickquest.com/?page_id=70
 
what's the difference between the "portfolio" backtester and the "custom" backtester??

Can some-one give me an example of both? I've been backtesting a system, but now I don't know if I'm using the portfolio backtester or the custom backtester.

By default you would be using the Portfolio Backtester. In a nutshell the custom backtester uses a set of commands to give you more control over various stages of the backtest procedure. This document from TJ gives a good basic outline of the custom backtester:

http://www.amibroker.com/docs/Houston2.pdf
 
Captain Black, many thanks for your reply. It was most helpful.

Given your knowledge of Amibroker and coding, do you have an opinion on the lack of monte carlo similation available in Amibroker?

I did read somewhere (I've been sooo busy googling) that you can set the postionscore to random (ie override the alphabetical selection) and then run manual iterations. I assume that you have to run many iterations and then crunch the numbers in excel, which seem like hard work.

Hi AGirl --

There are several ways that Monte Carlo Analysis can be used.

1. To add random noise to data, allowing testing of the sensitivity of a trading system to the data.

2. To perturb parameter values, allowing testing of sensitivity of a trading system to the values of the parameters.

3. To rearrange closed trades, allowing testing of position sizing techniques.

The first can easily be done with AmiBroker as it now stands.

The second can also be easily done, but I recommend doing some analysis before doing these tests. Some parameters are amenable to perturbing, others not. Some of the newer optimization techniques (such as cmae) tend to find plateaus rather than peaks, so these tests may not be as important as they were several months ago.

The third can be done using post processing programs, such as TickQuest's free Equity Monte Carlo
http://www.tickquest.com/?page_id=70
or Adaptrade's not free, but reasonable, Market System Analyzer
http://www.adaptrade.com/product.htm

There are some who believe that random selection of trades is a valuable technique and use Monte Carlo methods to select trades randomly when there are more trades signaled than there is money to take them all. I strongly disagree with that approach and suggest that real traders trading real money do not select trades randomly -- they always have a preference. Rather, use AmiBroker's PositionScore to add criteria to allow ties to be broken using metrics that you define that rank the alternatives into the order you prefer. That is, do not use PositionScore = Random();

Try Equity Monaco or the free trial version of Market System Analyzer before going too much further in this area. Also, be certain you understand the theory and practical implications of aggressive position sizing, including fixed fraction and fixed ratio.

Thanks for listening,
Howard
 
Hi all,
after some searching i have gone back to basics but still am unable to change to multiple week pivot points.

here is my weekly pivot code
_SECTION_BEGIN("weekly pivot");
WeekH = TimeFrameGetPrice("H", inWeekly, -1);
WeekL = TimeFrameGetPrice("L", inWeekly, -1);
WeekC = TimeFrameGetPrice("C", inWeekly, -1);
WeekO = TimeFrameGetPrice("O", inWeekly);

// regular pivots
if ( True )
{
PP = (WeekL + WeekH + WeekC)/3 ;

}


Plot(PP, "PP",colorRed,styleLine+styleNoLabel);
_SECTION_END();

is anyone able to help me change from weekly to 2week PP
 
Hi, I'm a newbie trial-ing Amibroker before buying it. I'm finding understanding AFL quite a challenge, coming from a non programming background. Would anyone know if there's a course (hopefully affordable) in Sydney? I just think it might be easier if someone's explaining the fundamentals of it, saving some valuable time trying to read it all. Thanks
 
Hi, I'm a newbie trial-ing Amibroker before buying it. I'm finding understanding AFL quite a challenge, coming from a non programming background. Would anyone know if there's a course (hopefully affordable) in Sydney? I just think it might be easier if someone's explaining the fundamentals of it, saving some valuable time trying to read it all. Thanks

Do u think it is worthwhile for some one running a course to do this ? I could show you a lot of basics in a half day session, but in a small class room of 8 or less. Never done this, but I am in a position where I could teach.

Of course after the lesson you could ask questions as long as not system development, but only programming wise, although I may direct you to the yahoo forum or to Amibroker support itself.
 
If this goes ahead, for half or full day, will be at least, $200 but not more than $1000 a head, for a half or full day of Amibroker tutorials.

What topics would you like to see covered ?
 
Hi, I'm a newbie trial-ing Amibroker before buying it. I'm finding understanding AFL quite a challenge, coming from a non programming background. Would anyone know if there's a course (hopefully affordable) in Sydney? I just think it might be easier if someone's explaining the fundamentals of it, saving some valuable time trying to read it all. Thanks

Before investing in Dave's proposed workshop, I suggest you read through each of the 322 "AFL Function Reference - Alphabetical list of functions". This won't take as long as you might think because the descriptions are concise. Even if you just read and maybe practice the ones you would like to use.

That way you will have an idea of how a function works when it is used or explained by a teacher. The speak won't sound like double dutch. It is the knowing of the functions which helps considerably.
 
Looking at creating a workshop course, 1 day, probably around $400 or more (need to check costs of a venue and catered lunch ... although may have a introductory reduced fee for the first workshop), which will include a workshop book and cd (which includes code) but only a small class - 5-8 max.

Morning session will be basics ... introduction, overview of Amibroker, and basic usage etc ... then afternoon session much more advanced stuff ... addtocomposite, position sizing methods, and loops (providing some very useful and fully explained examples).

Anyhow send me a pm if interested, and what you would like to see in a workshop.

If this goes ahead based on interest, the courses will only be available in Sydney to start with, and won't be available for a few months until content and course is fully developed. The main goal for me, is to ensure that anyone that attends, receives much more than expected value from the course.
 
I was looking at all these else if statements, doesn't Amibroker have Case statements?

switch/ case statements were added in the 4.91.0 Beta

http://www.amibroker.com/devlog/wp-content/uploads/2007/05/readme4960.html

CHANGES FOR VERSION 4.91.0 (as compared to 4.90.5)

AFL: switch/case statement added (completed: 2007-03-31) (ext.ID: 580). More information: http://www.amibroker.com/guide/v50/keyword/switch.html (note: this link not working)

Example:

for( n = 0; n < 10; n++ )
{
printf("Current n = %f\n", n );

switch(n) {
case0:
printf("The number is zero.\n");
break;
case3:
case5:
case7:
printf("n is a prime number\n");
break;
case2: printf("n is a prime number\n");
case4:
case6:
case8:
printf("n is an even number\n");
break;
case1:
case9:
printf("n is a perfect square\n");
break;
default:
printf("Only single-digit numbers are allowed\n");
break;
}

 
Top