Australian (ASX) Stock Market Forum

Dump it Here

PANDA certainly looks like another impressive addition to the stable Skate! How are you doing those extended Backtest stats including Expectancy please - guessing they are custom user metrics coded onto your reports?

@Newt you are correct I’ve coded the extra stats into the body of each strategy & they form part of the Amibroker’s standard backtest report.

Return on investment
@peter2 made a remark about contacting his bank, so I’ll use that analogy: “if I had money to deposit in a bank I would like to know the return on my investment before I make the deposit”

The “Expectancy” (per $100 invested)
This displays the consistency of returns & this metric is important to me. When I deploy my funds (soldiers) I expect to receive the spoils of war.

Skate.
 
How are you doing those extended Backtest stats including Expectancy please - guessing they are custom user metrics coded onto your reports?

from the user guide

upload_2020-1-9_20-2-10.png

Code:
/* First we need to enablecustom backtest procedure and
** tell AmiBroker to use current formula
*/

SetCustomBacktestProc("");

/* Now custom-backtest procedure follows */

if( Status("action")== actionPortfolio )
{
   bo = GetBacktesterObject();

   bo.Backtest(); // run default backtest procedure 

  SumProfitPer100Inv = 0;
  NumTrades = 0;

   // iterate through closed tradesfirst
   for(trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
  {
      // here we sumup profit per $100 invested 
      SumProfitPer100Inv = SumProfitPer100Inv + trade.GetPercentProfit();
      NumTrades++;
  }

   // iterate through eventually still open positions 
   for(trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() )
  {
      SumProfitPer100Inv = SumProfitPer100Inv + trade.GetPercentProfit();
      NumTrades++;
  }

  expectancy2 = SumProfitPer100Inv / NumTrades;

   bo.AddCustomMetric( "Expectancy (per $100 inv.)",expectancy2 );

}

// your trading system here 
fast = Optimize("fast", 12, 5, 20, 1 );
slow = Optimize("slow", 26, 10, 25, 1 );
Buy=Cross(MACD(fast,slow),Signal(fast,slow));
Sell=Cross(Signal(fast,slow),MACD(fast,slow));
 
Actually I'm pretty happy with my backtesting lately. Just about ready to jump back in time 10 years and start trading my strategy :)

Or may as well go back 20 :)


There’s No Time Like Today

“The best time to plant a tree was 20 years ago. The second best time is now.” — Chinese proverb

Meaning, it isn’t too late to start..

Start what?
That's for you to decide.

Skate.
 
no problem mate. I have had it coded ( and the other examples ) for a while but not really used it.

Looking at Skate's report has given me some ideas on other parameters to add but just haven't pulled the trigger yet.

View attachment 99582
One way i found this custom backtest useful was adding a cause of exit if using trailing stop
This way i could check how many trailing SL would have happened on a given period, google search will give details but was simple and useful
 
Some of my best early trading learning, and later quite a few entry/exit ideas, came from writing code to scoop up a small universe of trending stocks then review and distinguishing entry (or exit) features that might be codable (is that a word?)

Agree Qldfrog that flagging which of multiple exit conditions fires is a good application too.
 
A lot of interesting talk this week and a pretty disappointing/bad end result for the systems today I know there is so much to fix that I feel pretty tempted to stop system 2 and flipper.
System1 lost a whooping $829 on a week which saw the asx surge I have to get into the details and check which shares produce that and see if there is a fundamental fault I can spot and system2 got a minimal $108 profit Flipper lost another $342 and does have a single (slightly) positive position out of 5!!!!!
Pathetic..

Yes, that is disappointing with 15 open positions in the Sys 1 portfolio. I'd love to help but unfortunately I don't use Amibroker nor could I evaluate your system code. 13/14 positions in the P2 wkly/dly portfolio went up this week and I'm certain @Skate portfolios would show the same pattern.

@qldfrog from memory your system 1 is a modified version of the CAM strategy. I'll post an update of my CAM strategy - its above it's mission statement. @peter2 is correct his P2 portfolio went up & all my three strategies have done the same.

FYI
The CAM strategy is a live trading account. I started trading the CAM Strategy on a whim to keep the 'Dump it here' thread alive - $58k in 31 weeks was worth the effort.

Cam Strategy Capture.JPG

@debtfree My humblest apologies. I must have read your post as I liked it. I didn't test it straight away and forgot about it. I'm going to bookmark @Skate CAM, MAP, BOX, HYBRID, PANDA strategies, exit discussions and even his secret sauce.
View attachment 99612 Skate will wonder what's hit him.

@peter2 thank you for your comment to bookmarks some of my posts. Your post may encourage others to do the same or at least revisit some of my older posts, it may be the catalysis for a member to grab the 4th edition of my eBook.

Skate.
 
The 'Dump it here' thread
The 'Dump it here' thread was originally intended to help beginners find their feet, start them off on the right foot (as to say) with the hope of conditioning their way of thinking. (In my defence - the conditioning posts were designed in such a way to encourage others - "how to think" not what to think )

For the more advanced
As this thread is being followed by a few seasoned traders I'll break one of my cardinal rules of keeping its simple & make a more complex post as it may be helpful to a few members at the moment.

When I develop a strategy - "consistency" - is the main measure - profit performance 'not so important' as there is a direct correlation between consistency & performance, meaning get the consistency right & the performance naturally follows.

I'm not a lover of pyramiding into a position or adding to an existing position (others can argue the case for pyramiding but with a "Take Profit Stops" or "Pyramiding" neither work for me) Moreover: I'm a TRUE believer in "pyramiding" my Position-sizing (I've discussed this many times in this thread) "Position-sizing Pyramiding" is handle by re-balancing my weekly position-sizes. How? - Position-sizing uses my trading Bank balance - the Bank feed is sent to a parameter setting within the strategy code. It's simply a way of putting every dollar to work.

Lets’ talk about “Pyramiding into PositionSizing”

What are the benefits of Pyramiding my PositionSizing
What metric do I use?, How do I measure how effective a strategy is? Which of my systems will generate the most return? Which is better for real trading? These are very important questions that I need answer for as I'm a numbers man. I happy to report there’s a metric that helps answer all those questions.

What metric is important to me
The Megan ratio, the Geometric Mean & the Expectancy Ratio answers all my questions. As @Trav. was kind enough to post some helpful Amibroker code I'll post a screen capture of the Megan ratio & the Geometric Mean code (both codes are embedded in the body of my codes). Why post my code? Because metrics & reporting is a dry subject to read & sometimes hard to grasp but by supplying the code hopefully it will keep you reading to the end.

Think about this
I value every dollar (lets call them soldiers) You wouldn't expect me to deploy my funds (soldiers) into the heat of battle without knowing the odds of winning the war would you? When I put my soldiers to war I need to know the odds of them returning as there are more wars to fight (talking about war at the moment is insensitive but combine it with the analogy of boxing "makes the explanation clearer" - well to me at least)

There are so many metric
Many metrics can evaluate the performance of trading systems. These include Net Profit, Recovery Factor, Sharpe Ratio, K-ratio, CAR/MaxDD, RAR/MaxDD, Profit Factor, Payoff Ratio, Risk-Reward Ratio, Risk-adjusted return, Ulcer Performance Index & now I'm giving you yet another two ratios to complicate matters further to go with my Expectancy Ratio - The additional two ratios are (1) the Megan ratio & (2) Geometric Mean percentile, 'phew'. Seasons traders know all this stuff but it highlights how beginners are swamped with an information overload.

Which System = Higher Return?
Even though you can use these metrics to select the best trading system for you, the criteria for selecting a system tends to be arbitrary. Metrics such as the Sharpe ratio or K-ratio give an indication about the slope & smoothness of the equity curve but don’t indicate which system is the best in terms of consistency or monetary performance.

Lets not chase Net Profits – Lets seek consistency of returns
Not only that, keep in mind that the system with the best "Net Profit" after backtesting is not necessarily the one that will generate a higher return when you actually trade it. Another system with fewer trades in backtesting but better returns/statistics could produce more trades & superior performance.

Backtesting means JACK
Real trading results will differ from backtest trades because different systems have different holding periods for trades & can't handle "PositionSize Pyramiding" because Amibroker simply doesn't have direct access to my trading funds Bank account balance. Also in summary, those systems that generate more trades in the same period should do better (if the rest stays the same). This is where the Megan ratio is a God send when evaluating different strategies, it gives you the ability to compare apples with apples when backtesting apples & oranges.

FYI
MEGAN is an acronym which stands for the “Maximum Exponential Growth Annualized Notation” of the equity curve of a trading system, it’s a metric specifically designed to highlight the system that generates more returns per year when the profits are "reinvested" (PositionSize Pyramiding) regardless of the number of trades, holding period, drawdown, & so on.

The geometric mean
This is especially useful to determine whether a specific filter, which eliminates trades & therefore profits, is beneficial to the performance of the system. The best system is the one with the best geometric mean. This is because we want to reinvest the profits in the next trade (PositionSize Pyramiding). IMHO all other metric don't take into account the reinvestment of profits.

As promised - The Megan ratio, the Geometric Mean code capture

MEGAN Capture.JPG

Skate.
 
Last edited:
A lot of interesting talk this week and a pretty disappointing/bad end result for the systems today
I know there is so much to fix that I feel pretty tempted to stop system 2 and flipper.

Lifted without your permission

@qldfrog compare your equity curve to my Hybrid Equity curve - don't be disheartened you are on track & "fine tuning" of any strategy is an ongoing process. It's wise to remember "A good strategy is not good when better is expected"

QldFrog equity curve Capture.JPG

Trend Trading

I've posted a screen capture of my Hybrid Strategy Equity Curve back in November 2019 & in comparison you are doing OK. (2019 seems so long ago)

(The Hybrid Equity curve below is from: Jan 2019 till end-of-trade 11th November 2019)

My original post is found here - https://www.aussiestockforums.com/posts/1045831/

equity-curve-capture-jpg.98528



Update - of my Hybrid Strategy
The updated Equity Curve of my Hybrid Strategy below confirms trading with the trend still works but I'm first to admit trend trading is not always a smooth process.

Comparison
FYI - The chart above is from 6th January 2019 whereas the chart below is a little longer in the date range - from 6th July 2019.

System1 lost a whooping $829 on a week which saw the asx surge

I'm trading a large account
Well to me it's a large account & I have to accept that sometimes "I win big & sometimes I lose big" that's just trading - If you look at the chart below each dip represents real dollars just evaporating away. It's the very reason why you need to control your emotions & be in the correct head-space.

(The Hybrid Equity curve below is from: July 2019 till end-of-trade 10th January 2020) The Equity curve is a recent sample of a much larger chart as I commenced trading back in July 2015. My previous Equity curves posted can be found here: https://www.aussiestockforums.com/posts/1006532/ & here: https://www.aussiestockforums.com/posts/1010348/ if anyone is interested.

Hybrid 10th January 2020 Capture.JPG


Losing
There are times when trading it can all go south for no good reason & at other times the **** can hit the fan that will be unavoidable, just like a tweet from Trump, that's just how it is sometimes. No one knowingly puts themselves in harms way - "but" - no matter how smart we are, or how hard we work, we will regularly be hit by something unforeseen. Trading is Bat-**** scary for beginners & as seasoned traders we aren't immuned. Remember the words of my old boxing coach "Don't get in the ring if you don't want to be hit"

The "Pep talk" is over...

Skate.
 
Thanks Skate, after analysis, the strong under performance last week was not there I made a modest 370 gain..I posted details on my thread, but interesting how a simple manipulation error triggerred me into deeper searches, discovered a few minor errors and a major problem in my dynamic trending (system 2)
Moral of the story:(pathetic attempt at Skate poetry mixed with Confusius wisdom follows, read at your peril):
"Chasing shadows might lead you to discover the gold at the end of the rainbow"
Thanks again for your support and wise words
 
@debtfree I'm going to bookmark @Skate CAM, MAP, BOX, HYBRID, PANDA strategies, exit discussions and even his secret sauce.

@peter2 comments missed two other strategies I've discussed previously & both have merits to be studied. Both strategies aren't too shabby having already been discussed previously in this thread.

1. SuperTrend Strategy
The SuperTrend Strategy is based loosely on @peter2 1st Blue Bar setup that has been discussed in his thread. The performance results of the SuperTrend Strategy are quite respectable

2. The High5 Strategy
It’s a simple strategy that enters on a higher high of previous 5 high periods & exits when there have been 5 lower highs since entry. The strategy is so simple it’s hard to believe something so simple could have legs.

For the new followers: This portfolio is an educational portfolio

Using the search
If you want to bookmark any post or re-read about any of my strategies just use the search feature. Meaning, 'Search' for [Strategies] by [Skate] will get you started.

I've lost focus
I've stopped the educational side of posting because it was obvious that most prefer talking about charts & strategy performance but I believe there is importance to understand & grasp the practical / emotional side of trading. I'll bring out the soap box for a few post & put it away before "I hop on my high horse". I'll make a mixture of posts to encourage reading of the 'Dump it here' thread.

I'm not seeking to contest ideas but to express my own that I've found helpful in my trading experience. I'll also post more about the two strategies above with displayed backtest results as a refresher for others that enjoy the practical side to posts.

Skate.
 
Let’s talk about 'Strategies'

My views
All the posts in the ’Dump it here’ thread have been written to pass on my experience I’ve gained over the years explaining that there is an alternative way of thinking about trading & I’m very mindful that every member enjoys a different level of experience & expertise.

A profitable strategy
For a strategy to be profitable it needs to have a mathematical advantage & without the advantage you won’t make any money. Trading can be scary when you trust a system developed by someone else, developing your own system has its advantages as we need discipline, commitment & confidence in your trading plan or strategy just to keep pulling the trigger. (your own strategy development provides this)

Skate.
 
The advantage of an edge
Traders need an edge to beat the markets & selling the losers whilst holding the winners can in fact be your simple edge, it’s a stressful situation selling losers I know, but selling quickly & holding the winners is how this mathematical advantage works.

What's my edge?
I keep the winners & trash the poor performers.

It's a fallacy
The reason most traders concentrate on the entry is based on the false premise that if the "right" stock is bought at the "right" time this is where the money will be made. In my experience, timing of the exit is where the money is made. Cutting losing trades early is the secret of being a profitable trader. Alternative views have already been expressed in this thread that "buying" is the most important to a successful trade but in my trading experience getting the exit timed correctly works better for me.

The importance of an exit
Getting into a trade is simple knowing when to pull the trigger & exit (exiting at the correct time) is the hard part of trading - nailing the exit is my EDGE & as traders we all should be seeking to fine tune this part of our strategy. It’s important to remember the "EXIT" really determine the final outcome of a trade leading to the long-term success or failure of any trading strategy.

Skate.
 
Trading is a slow process (Give it time)
For the mathematical advantage I've been posting about needs time to work, any strategy will not be an overnight sensation. Every strategy takes time & you'll need to be patient as truly does takes time, sometimes it’s a slow process and it can take months to develop into profits. That's just the nature of the beast. Traders without an education are notoriously optimistic & lack patience when they first start out.

It's complex
I’m first to admit financial markets are complex, but that doesn’t mean it requires a complex strategy. Understanding what drives the markets is the key that leads to better decision making & the level of complexity of a strategy has little to almost no bearing on its performance.

The Holy Grail
Everyone's looking for the perfect strategy, the foolproof method, well if the perfect strategy is out there it has eluded me so far. Trading in a disciplined manner by following your trading rules/plan without override your system - BINGO ! - you may have just found your “Holy Grail”.

Skate.
 
Top