Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Z Score for backtesting for Amibroker (AFL)
I am not the author of this AFL. It was provided by dubi197 on one of the blog.
It calculates the z score through the custom backtester.
Similar Indicators / Formulas
Indicator / Formula
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | SetOption ( "UseCustomBacktestProc" , True ); SetCustomBacktestProc ( "" , True ); if ( Status ( "action" ) == actionPortfolio ) // point to correct iteration of backtest engine { //initialize custom backtest engine //bo is backtestobject bo = GetBacktesterObject (); bo.Backtest(); // run default backtest procedure st = bo.GetPerformanceStats(0); // get stats for all trades totalLossTrades = totalWinTrades = totalRuns = 0; for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade()) { // Loop through all closed trades if (trade.GetProfit() > 0) // If this was a winning trade { if (totalWinTrades == 0) totalRuns++; totalWinTrades++; totalLossTrades = 0; } if (trade.GetProfit() < 0) // If this was a winning trade { if (totalLossTrades == 0) totalRuns++; totalLossTrades++; totalWinTrades = 0; } } // End of for loop over all trades N = st.GetValue( "AllQty" ); R = totalRuns; WIN = st.GetValue( "WinnersQty" ); LOSS = st.GetValue( "LosersQty" ); X = 2 * WIN * LOSS; Z_Score = (N*(R-0.5)-X)/ SQRT ((X*(X-N))/(N-1)); bo.AddCustomMetric( "Z-Score" ,Z_Score ); bo.AddCustomMetric( "totalRuns" ,totalRuns ); } |
0 comments
Leave Comment
Please login here to leave a comment.
Back