Click here to Login





                                                   t-test / z-test

  0

0
GS
2012-09-15 13:01:54


Hi,

Within statistics of simulation/backtesting I would like to see results of t-test or z-test, how do we do this? For t-test we can have following formula based on excel sheet functions:

t-test = SQRT(Total number of trades)*AVERAGE(first trade : last trade)/STDEVP(first trade : last trade). Here, within AVERAGE and STDDEVP we will use values of % gain/loss for each trade, i.e. perf(close,1).

Thanks,




QuantShare
2012-09-15 13:21:17

  0

You must use the money management script (OnEndSimulation event) to create this t-test measure.


GS
2012-09-16 11:45:00

  1

OK, so following script is giving me t-score^2 for my trading system:

===========================================================

MMPosition[] pos = Portfolio.GetAllPositions();
double aveg = 0.0;
for(int i=0; i < pos.Length;i++)
{
aveg += pos[i].Performance;
}

aveg = aveg/pos.Length;
double differ = 0.0;
for(int i=0; i < pos.Length;i++)
{
differ += (pos[i].Performance - aveg)*(pos[i].Performance - aveg);
}

pos[pos.Length-1].AddTradeMetric("t-score^2", (pos.Length*pos.Length*aveg*aveg)/differ);

===========================================================

Actually I want to see sqrt( (pos.Length*pos.Length*aveg*aveg)/differ). The moment I use "sqrt" formula, it is giving error, saying that it is not the part of this event. I would appreciate if you could guide me on how to use sqrt formula withing OnEndSimulation event of MM script. After that that we can upload this script for the benefit to all the users of QS.

Thanks,



QuantShare
2012-09-17 11:26:00

  0

To calculate sqrt use this function:
Math.Sqrt(variable)



GS
2012-09-17 12:07:33

  1

Thanks a lot, the final script is given below. I would like to upload it on the sharing server, would appreciate if you could help in doing so.

Best regards,

==============================================================
MMPosition[] pos = Portfolio.GetAllPositions();
double aveg = 0.0;
for(int i=0; i < pos.Length;i++)
{
aveg += pos[i].Performance;
}

aveg = aveg/pos.Length;
double differ = 0.0;
for(int i=0; i < pos.Length;i++)
{
differ += (pos[i].Performance - aveg)*(pos[i].Performance - aveg);
}

differ = Math.Sqrt(differ);
pos[pos.Length-1].AddTradeMetric("T-score", pos.Length*aveg/differ);

==============================================================



QuantShare
2012-09-17 13:15:12

  1

After you create and save the money management script based on the above formula (Analysis -> Advanced Money Management), select "Tools -> Sharing Server", select "Advanced Money Management", your item then click on "Share Selected Item".


GS
2012-10-17 13:51:29

  0

Hi,

Is it possible to this value of T-Score on the optimization report? Currently I have to open "TradeMetric" to see this.If yes, any suggestion on how to do this?



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
History of dividend payment for stocks in the US stock market
Switch Traded Asset
Year to Date Excess Return
Relative Momentum Index
BSE historical data

How-to Lessons
How to improve the performance of QuantShare databases?
How to create a screen
How to download EOD quotes for active and valid stocks only
How to create a hatched area in a chart
How to add future bars to plan for market scenarios

Related Forum Threads
Portfolio features
how 2 wrt rule
about scaners and fliters
Simulator question
addcolumn and stock name

Blog Posts
How to download the history of dividend payments for stocks in th...
How to Optimize a Trading System with Thousands of Billions of Co...
How to Backtest Each Stock or Asset Individually
5 position sizing techniques you can use in your trading system
Creating Stock & Market Short Interest Ratios using Historical Sh...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2025 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.