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
Accumulation Swing Index (To measure long term trends)
Optimizable Fibonacci Long and Short Trading System
Large price and volume gain after consolidation
Index Investment Data for U.S. Futures Markets
Coefficient of Determination - R Squared - Time-Series Prediction

How-to Lessons
How to automatically arrange charts?
How to calculate the average of a time series using the money man...
How to create a moving average of an indicator
How to plot the relative performance of several stocks/indices
How to import trades into a portfolio

Related Forum Threads
how can I get MCX commodity charts ?
Fundamental Data For NSE Stocks
Connection with brokers
Forex Scalping using Quantshare?
pivot tables

Blog Posts
Automatically create historical quotes charts
Backtesting Your Trading Systems: Symbol Segmentation
Download historical EOD data for the stock, futures, ETF and Fore...
Trading System: Buy stocks with the highest Sharpe ratio
Download Trading Data using the Pre-Script









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