• 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 Newbie

Discussion in 'Trading Strategies/Systems' started by stevecar144, Oct 21, 2019.

sentifi.com

Aussie Stock Forum Sentifi Top themes and market attention on:

  1. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007
    Hi All,
    I am trying to return a list of stocks where the price has increased 500% since 2014.
    So I am thinking of the below...but to be honest have no idea if I am even close to the right approach...I have an array "fivetimes" and trying to get count of bars since the price was 5 times lower...??? Any comments appreciated.

    fivetimes=BarsSince(C/5)>0;
    AddColumn(fivetimes,"fivetimes",1.4);
     
  2. Gringotts Bank

    Gringotts Bank

    Posts:
    6,163
    Likes Received:
    577
    Joined:
    Jun 30, 2007
    Padowan likes this.
  3. BoNeZ

    BoNeZ

    Posts:
    39
    Likes Received:
    35
    Joined:
    Nov 11, 2013
    If you want to know the number of bars since the close price was 5 * smaller than now

    Bars = BarsSince( Close * 5 < LastValue( Close ) ) ;

    If you want to compare the price between two dates

    StartDate = "2014-01-01" ;

    StartClose = Lookup( Close, _DT( StartDate ), 1 ) ;

    Filter = Close > StartClose * 5 ;
     
    Padowan and Gringotts Bank like this.
  4. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007
    Hey Guys
    This is what I have explored...but it misses many tickers that qualify.
    AC8 for example goes up by 5 times but is not flagged int he exploration.
    Thoughts? TIA...

    StartDate = "2014-07-01" ;
    StartClose = Lookup( Close, _DT( StartDate ), 1 ) ;
    Buy=C>startclose*5;
    Sell=0;
    Filter=Close > StartClose * 5;
    buy = ExRem( buy, sell );
    sell = ExRem( sell, buy );
    AddColumn(buy,"fivetimes",5);
    AddColumn(Close,"Close 30/6/2018",1.4);
    AddColumn(startclose,"close 1/7/2014",1.2);
     
  5. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007
    Hi again,
    My exrem is not working...getting multiple signals in exploration...any ideas?? TIA>

    StartDate = "2014-01-07" ;
    StartClose = Lookup( C, _DT( StartDate ), 1 ) ;
    Buy = C > startclose * 5;
    Sell = 0;

    Buy = ExRem(Buy,Sell);
    Sell = ExRem(Sell,Buy);

    Filter = C > startclose * 5;
    AddColumn(C > startclose * 5,"fivetimes",5);
    AddColumn(Close,"Close 30/6/2018",1.4);
    AddColumn(startclose,"close 1/7/2014",1.4);
    AddColumn(startclose*5,"start * 5",1.4);
     

    Attached Files:

  6. Trav.

    Trav.

    Posts:
    402
    Likes Received:
    394
    Joined:
    Nov 27, 2017
    Try changing you filter to the following, then your ExRem will work

    Filter = Buy;
     
  7. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007
    Agreed, Exrem does work with filter = buy, but the exploration then omits many candidates that qualify under the buy rule. I am filtering for ASX stocks that are operating holding companies and setting the date range 1 July 2014 to 30 June 2018.
    AC8 is an example. It has the 500% price rise, but is omitted using the exrem statement.
    Confused...

    If I comment out the exrem statement and get far more "up by 500%" stocks. Confused...
    StartDate = "2014-01-07" ;
    StartClose = Lookup( C, _DT( StartDate ), 1 ) ;
    Buy = C > startclose * 5;
    //Buy = ExRem( Buy, 0 );
    Filter = buy;
    AddColumn(C > startclose * 5,"fivetimes",5);
    AddColumn(C,"Close 30/6/2018",1.4);
    AddColumn(startclose,"close 1/7/2014",1.4);
    AddColumn(startclose*5,"start * 5",1.4);
     
  8. Trav.

    Trav.

    Posts:
    402
    Likes Received:
    394
    Joined:
    Nov 27, 2017
    This is way harder than it should be :confused:

    I get

    upload_2019-10-22_7-50-21.png

    Code:
    StartDate = "2014-01-07" ;
    StartClose = Lookup( C, _DT( StartDate ), 1 ) ;
    Buy = C > (startclose * 5);
    Sell = 0;
    
    Buy = ExRem(Buy,Sell);
    Sell = ExRem(Sell,Buy);
    
    Filter = Buy AND StrLen( Name () ) == 3;
    AddColumn(C > startclose * 5,"fivetimes",5);
    AddColumn(Close,"Close 30/6/2018",1.4);
    AddColumn(startclose,"close 1/7/2014",1.4);
    AddColumn(startclose*5,"start * 5",1.4);
     
  9. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007
    Yeah agreed,
    I still dont get the same result...??? No AC8 for instance...using above code...
    problem2.jpg
     
  10. Trav.

    Trav.

    Posts:
    402
    Likes Received:
    394
    Joined:
    Nov 27, 2017
    I see you have a filter applied AC8 is in the All Industries watch list, try selecting All symbols

    and you are limiting search to dates try all quotes. then we can move forward
     
  11. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007

    Okay,
    With Exrem on, using all symbols and all quotes AC8 is picked up but only in 1999 -which is correct - first instance only. If I set the date range to 2014-2018, then AC8 is rejected, but only when Exrem is used. Image is with exrem commented out. Note the 2017 AC8 entries are included.

    problem3.jpg
     
  12. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007

    Heading out to work...wont reply for several hours...cheers and thanks
     
  13. BoNeZ

    BoNeZ

    Posts:
    39
    Likes Received:
    35
    Joined:
    Nov 11, 2013
    The ExRem function removes excess signals. ExRem( Buy, Sell ) means you will get one buy signal then nothing until you get a sell signal then nothing until you get a buy signal and so on. You have a Sell rule but it will never be true so you will only ever get a single buy.

    Your Buy rule is comparing the close price on your start date with every close price through history and the first time that happened was 28-Jan-1999. Even when you set the date range to be 2014-2018 Amibroker still knows the first buy signal was in 1999.

    With the ExRem function Amibroker knows you had a buy signal before the start of your date range so will not display the symbol until you get a sell signal (which you never get) then the next buy signal...

    Two changes you could make are add a valid sell signal and filter buy and sell signals to dates after your start date. Something like

    StartDate = "2014-01-07" ;
    StartClose = Lookup( C, _DT( StartDate ), 1 ) ;
    Buy = Close > ( startclose * 5) AND DateTime() >= StrToDateTime( StartDate ) ;
    Sell = Close < ( startclose * 4.5 ) AND DateTime() >= StrToDateTime( StartDate ) ; ;

    Buy = ExRem(Buy,Sell);
    Sell = ExRem(Sell,Buy);

    Filter = Buy ;

    A scan of AC8 should return

    upload_2019-10-22_13-15-49.png
     
    Padowan and Trav. like this.
  14. stevecar144

    stevecar144

    Posts:
    12
    Likes Received:
    0
    Joined:
    Jun 7, 2007

    Awesome everyone, problem solvered....thanks a heap.
     
  15. Padowan

    Padowan

    Posts:
    26
    Likes Received:
    21
    Joined:
    Aug 13, 2019
    Hi All, I am very new amibroker user, I’ve been experimenting with some simplistic back testing on asx historical equities. I have a query around recommended position sizing methods during back testing and would greatly appreciate any guidance or reference to historical threads that would have discussed this in the past.
    Initially I was using a fixed percentage of capital and a maximum number of open positions as an input but with 100k starting capital and 5pct capital allocation per trade the trade size grows over long testing periods to what seems unrealistic levels to me. As a counter to this I run a fixed $ amount per trade as an input with an increase to the maximum number of open positions.
    Over the same system the fixed $ amount per trade approximately halves CAGR versus the 5pct capital allocation.
    I would be greatful to hear if I’m way of the mark with this kind of approach to position sizing in terms of good practice to generating back testing results and any other recommended methods I could investigate.
     
  16. Joe90

    Joe90

    Posts:
    16
    Likes Received:
    10
    Joined:
    Dec 24, 2013
    Suggest to read about OOS (out of sample/walk forward testing) and read some of Howard Bandy's books. Howard used to contribute here, try the search function.
     
    Padowan likes this.
  17. Joe90

    Joe90

    Posts:
    16
    Likes Received:
    10
    Joined:
    Dec 24, 2013
  18. Padowan

    Padowan

    Posts:
    26
    Likes Received:
    21
    Joined:
    Aug 13, 2019
  19. Trav.

    Trav.

    Posts:
    402
    Likes Received:
    394
    Joined:
    Nov 27, 2017
    Also read up on the following as this may help with some of those unrealistic trade sizes that would move the market

    upload_2019-11-14_7-4-6.png
     
    Padowan likes this.
  20. Padowan

    Padowan

    Posts:
    26
    Likes Received:
    21
    Joined:
    Aug 13, 2019
    Thankyou Trav.
     
    Trav. likes this.
Loading...

Share This Page