• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

Amibroker FAQ

Discussion in 'Software and Data' started by RichKid, Jul 15, 2005.

  1. TabJockey

    TabJockey

    Posts:
    370
    Likes Received:
    0
    Joined:
    Jul 13, 2009
    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.
     
  2. TabJockey

    TabJockey

    Posts:
    370
    Likes Received:
    0
    Joined:
    Jul 13, 2009
    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.
     
  3. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    PHP:
    Call Foreign("XMJ""Close");

    XMJema EMA(Call12); 
    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. ;)
     
  4. TabJockey

    TabJockey

    Posts:
    370
    Likes Received:
    0
    Joined:
    Jul 13, 2009
    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 == 1SectorArray S10);


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



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

    IIf(Sector == 3SectorArray S30);


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

    IIf(Sector == 4SectorArray S40);


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

    IIf(Sector == 5SectorArray S50);


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

    IIf(Sector == 6SectorArray S60);


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

    IIf(Sector == 7SectorArray S70);



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

    IIf(Sector == 8SectorArray S80);



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

    IIf(Sector == 9SectorArray S90);


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

    IIf(Sector == 10SectorArray S100);

    SectorEMA EMA(SectorArray40);

    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(CLTEMAP);
    //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)  ;
     
  5. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    I simply scan stock in the sector of interest, not the whole ASX. Energy stocks, Material stocks, Industrial stocks etc.

    Went down that path of testing for several weeks and came out none the wiser. Good luck with it.
     
  6. kastin

    kastin

    Posts:
    10
    Likes Received:
    0
    Joined:
    Nov 30, 2010



    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
     
  7. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    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.
     
  8. rexii23

    rexii23

    Posts:
    1
    Likes Received:
    0
    Joined:
    Jan 31, 2011
    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();
    
    
     
  9. Andruha

    Andruha

    Posts:
    54
    Likes Received:
    0
    Joined:
    May 27, 2009
    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
     
  10. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    Have you plotted in Weekly on the daily window?

    Plot(TimeFrameExpand(ADX(18), inWeekly), "ADX Weekly", colorBlue);
     
  11. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    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
     

    Attached Files:

  12. Andruha

    Andruha

    Posts:
    54
    Likes Received:
    0
    Joined:
    May 27, 2009
    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?
     
  13. Wysiwyg

    Wysiwyg Everyone wants money

    Posts:
    8,424
    Likes Received:
    260
    Joined:
    Aug 8, 2006
    Yes different.
     
  14. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    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.
     
  15. Gringotts Bank

    Gringotts Bank

    Posts:
    6,175
    Likes Received:
    602
    Joined:
    Jun 30, 2007
    solved. 'pad and align'. Strange because I always have it checked.
     
  16. Andruha

    Andruha

    Posts:
    54
    Likes Received:
    0
    Joined:
    May 27, 2009
    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?
     
  17. colion

    colion

    Posts:
    116
    Likes Received:
    0
    Joined:
    Aug 6, 2010
    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 );
     
  18. pavilion103

    pavilion103

    Posts:
    3,293
    Likes Received:
    14
    Joined:
    Dec 14, 2010
    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
     
  19. colion

    colion

    Posts:
    116
    Likes Received:
    0
    Joined:
    Aug 6, 2010
    Top chart: plot( c, "", colorblack, stylebar);

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

    pavilion103

    Posts:
    3,293
    Likes Received:
    14
    Joined:
    Dec 14, 2010
    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
     
Loading...

Share This Page