Amibroker: How to “Scale In” to Positions (1) – Buying Once a Month

Line1

Beginners Course  |  Intermediate Course  |  Amibroker Course Home

A few people at Youtube and at ASX Market Watch have asked for an Amibroker video on “Scaling In” to positions, or Pyramiding.  In other words, sometimes we may not want to buy out full position on our first entry signal, and may want to increase it over time.

This two-part series will start by looking at the basics of scaling in using Amibroker Formula Language, with a simple Dollar Cost Averaging example.

The rules change just a little bit – instead of simply setting up a “Buy” condition, now we use “If, Then, Else”.  If our buy signal is true, Then Scale In, otherwise (Else) return no signal.

Check out the video and leave a comment below!

Hope you enjoyed, and happy trending!

– Dave McLachlan

Beginners Course  |  Intermediate Course  |  Amibroker Course Home

Videos in the FREE Amibroker Course:

  1. Amibroker: How To Import A Watchlist With A CSV File
  2. Amibroker: How To Backtest A Single Stock Or Index
  3. Amibroker: How To Backtest a Portfolio or Group of Stocks
  4. Amibroker: How To Optimize A Trading System
  5. Amibroker: How To Scan The Market For Buy And Sell Signals
  6. Amibroker: How To Use Explore To Find And Filter Stocks
  7. Amibroker: How To Add Position Sizing Using AFL
  8. Amibroker: How to Add An Index Filter To Your Trading System Using AFL
  9. Amibroker: How To Plot Your Trading System On A Chart (incl. Buy/Sell Arrows)
  10. Amibroker: How to Use the If, Then Else Function (IIF)
  11. Amibroker: How to Code the ATR Trailing Stop (Chandelier) using ApplyStop
  12. Amibroker: How to Plot ApplyStop on a Chart
  13. Amibroker: How to Code Van Tharp Position Sizing (Fixed Fractional)
  14. Amibroker: How to “Scale In” to Positions (1) – Buying Once a Month
  15. Amibroker: How to “Scale In” to Positions (2) – Pyramiding Three Times
  16. Amibroker: How to Use “Cross”, When One Thing Crosses Another
  17. Amibroker Advanced: How to Compare Equity Curves

FREE Trading System Video Lessons:

  1. 7 Free Trading Systems and Their Returns From The Last 13 Years
  2. Seven Full Trading Systems Revisited, With Completely New Data
  3. Trading System: How to Create A Buy and Hold Trading System
  4. Trading System: How to Code “Sell In May And Go Away”
  5. Trading System: How to Code a Moving Average Channel That Made 23% p.a
  6. Trading System: How to Code Highest Highs As Used In 52 Week Highs Or Turtle Trading System
  7. Trading System: How to Code a Bollinger Band Breakout Trading System
  8. Trading System: How to Code a Moving Average Crossover That Returned 28% per annum
  9. Trading System: How to Refer to Previous Signals For MAup Trading System
  10. Trading System: How to Code the Leap Of Faith (Gaps) Trading System That Returned 24% p.a.
  11. Trading System: How to Code a Short Selling System (Plus Results)
  12. Trading System: Meb Faber Trading System Using Different Timeframes
  13. Trading System: How to Code the Three Billion Dollar Trading System

FREE Amibroker Q & A Videos:

  1. Amibroker Q & A: How To Do A Monte Carlo Test? (on ALL versions)
  2. Amibroker Q & A: Visualising Monte Carlo Data with Histograms and Scatter Plots
  3. Amibroker Q & A: How to Create the 52 Week High/Low Index with AddToComposite
  4. Amibroker Q & A: How to Code Trend Pilot: Five Consecutive Days Above or Below a Moving Average
  5. Amibroker Q & A: Three “Hacks” To Improve Your Coding Skills
  6. Amibroker Q & A: How to Remove Excess Signals

Read Related Articles:




  And, subscribe for free to stay in touch and receive the latest updates:

Enter Your Email Address:

.
(Check Your Junk Mail, Just In Case)

February 7, 2016  Tags: , , , , ,   Posted in: Amibroker Course

7 Responses

  1. Loordh - February 8, 2016

    Hello Mr.Dave McLachlan,

    Thanks for sharing your Amibroker knowledge.
    I learned lot from your post.

    I believe in Fundamental+Technical based investing. I use technical indicators to buy quality companies.

    For technical requirements, Amibroker helps me lot. However for fundamental filter, I don’t know how to use it.

    Can you please post article about importing and use basic fundamental datas like PE ratio, EPS ,Debt, outstanding shares, Market Cap, promoter holding…. etc.

    How to import these data from google finance or yahoo finance or from excel sheet or text file. ?

    Thanks in advance,
    Loordh

  2. David McLachlan - February 8, 2016

    Hey Loordh,

    Thanks for the kind words, and for stopping by the site!

    That is a good question. In fact I’ve wondered the same thing myself. It might take me some time, but I will look into it!

    Happy trending,

    Dave

  3. Kushal - February 21, 2016

    Hi Dave,

    Great video !!
    I love the concept of dollar cost averaging.
    Could you please assist with the following code: if we would want to sell the position today or on any particular date?
    Also, with this code, we always buy on the 1st of every month. What would the code be if we wanted to buy on the 5th of every month?

    Cheers !!

    Thank you

  4. David McLachlan - February 22, 2016

    Hey Kushal,

    It is great to have you here and thank you for watching!

    Great idea. A few people have asked about this, or made comment about different trading days of the month, so I will delve into it more and see if I can come up with a video 🙂

    Happy trending – Dave

  5. Kushal - February 22, 2016

    Hi Dave,

    I tried to use the Date(), DateNum(), Now() functions, but they didn’t seem to work.
    I wanted to put the sell code in so that we can see the equity curve, drawdowns, etc..
    You are doing a great job here !!
    Love your work !!

    Cheers!!

  6. Kushal - February 22, 2016

    Hi Dave,

    Do you know why is the system giving a buy signal on the last day of the month rather than 1st.
    I have kept my backtesting settings to buy and sell on the open without any trade delays, still it buys on the last day of the month.

    Thanks 🙂

  7. David McLachlan - February 23, 2016

    Hey Kushal,

    Thank you sir. For the equity curve, it should show anyway, if you click Report. It will “close” any positions when the back-test ends.

    I checked the code, and it is buying on the first of the month for me. I changed the settings to 0 trade delays, and open, then close, and a few others. All worked as they should… that is strange. You can post your code here if you like, and we can have a look.

    I was looking at the Day() function in another post – which gives days between 1-31. We could use that, or LP gave some code for counting TRADING days in the comments of another post:

    TradingDayThisMonth = BarsSince( Day() < Ref(Day(),-1) ) + 1; The post is here 🙂 http://www.asxmarketwatch.com/2016/02/trading-system-monthlydaily-trading-system-using-different-timeframes/

    Happy trending!

    Dave

Leave a Reply