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
Smartmoney news for US equities
ISEE Index - ISE Sentiment Index
Ivey PMI Index - Canada
High Short Selling Activity
BSE historical data by date

How-to Lessons
How to plot news on a chart?
How to download new quotes when selecting a chart
How to plot arrows below/above candlesticks on a chart
How to import trading data from CSV files
How to create a composite index/indicator

Related Forum Threads
Advance Money Management Script debug.
FullName
Can I update the sector and industry information in the stock dat...
Quantshare v1.6.8 crashes under 64 bit Vista
different weights for different asset class

Blog Posts
Ranking System Engine
How to Calculate and Display the Bid/Ask Spread on a Chart
How to make sure your Historical Price Data is Split Adjusted
6 ways to download free intraday and tick data for the U.S. stock...
Step by step on how to get free realtime/delayed data for stocks,...









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.