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
Geometric Moving Average Indicator
Forecast Oscillator
Forex Long to Short Position Ratios
Ulcer Performance Index
Moving Average Convergence/Divergence with Exponential Moving Ave...

How-to Lessons
What is the Bookmark Panel?
How to get trading orders from a portfolio programmatically
How to create a formula
How to optimize the number of positions in a trading system
How to add future bars to plan for market scenarios

Related Forum Threads
Can not move a square lying over a line
offline running
QS Release Notes
Can we create a custom database that without a Symbol relationshi...
how to remove non trading day entries

Blog Posts
Stocks: Market Capitalization
How to Create a Custom Real-Time Table using QS Trading Software
How to Download Trading Data for Certain Securities Only
Introduction to sentiment analysis applied to the stock market
4 indicators to create adaptive trading systems









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.