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
Advance/Decline NYSE, Amex and NASDAQ issues
Information Ratio - Appraisal ratio
Profile Count Per Month
TAA - Momentum and Volatility
Market: US Holidays

How-to Lessons
How to synchronize stock charts?
How to import trading items from other accounts
How to debug a trading system using the money management tool
How to display notes/commentaries on a chart
How to get stocks for a particular index using the global script

Related Forum Threads
Moving Key Info between Computers
QS standalone run option - no network connectivity.
Saving Pivot Tables
OnNewPosition and Timestamps and Order ID
Functions in Global Tab

Blog Posts
Volatility and trading systems
How to Backtest an Intraday Stock Trading System with EOD Ranking
How to Select the Best Market Indicator for your Trading System
Reducing risk and increasing return by combining several trading ...
Compare stocks and securities by creating a relative performance ...









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 © 2026 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.