Click here to Login





                                                   Compress bar for custom database

  0

0
Salvatore Gaziano
2018-03-01 07:08:41


Dear community,
i created a custom historical database "nav_rettificati" where there are two column: "Date" is a date and "closeret" is a float. This database store the daily closing price adjusted with dividend/distribution for each symbol (the value for symbol doesn't make distribution is the same of daily closing price).
I can get access to this data in Simulator thorugh:
rettNav= GetData("nav_rettificati", "closeret", LastData);

Now i want use this to compare the 1 month performance of a fix benchmark to each stocks in my strategy.
In the past i used a system like this, but i calculate the performance on the close price in the Quote db.

In this context i created a New trading system strategies in Simulator where i did it.
The time frame bars is daily. I rebalance only at the end of each month.

bench = TimeframeGetSeries1("MON", 31, close, LastData);
bench = timeframecompress(bench);
bench = perf(bench, 1);
benchPerf = timeframedecompress(bench);
symPerf = timeframedecompress(timeframeapply(31, perf(close, 1)));
compare = symPerf > benchPerf;

Now i want do the same functionality, but i cant use TimeframeGetSeries1 to get apply monthly timeframe (31)
I use this instruction to get the data information for benchmark and i get daily "closeret" price for benchmark symbol "MON"
rettNav= GetData("nav_rettificati", "closeret", LastData, "MON");

But i don't understand how i can proceed to compress in monthly like this
bench = TimeframeGetSeries1("MON", 31, close, LastData);
bench = timeframecompress(bench);
bench = perf(bench, 1)

Thank you



QuantShare
2018-03-05 03:58:42

  0

Hi,

"TimeframeGetSeries1" only uses OHLC values and the "timeframeapply" will not work well with "GetData".
Either you create a custom function in C# to calculate the montly values of "closeret" or you simply use the daily time frame and calculate the performance using: (it isn't a problem since you are rebalancing at the end of the month)
rettNav= GetData("nav_rettificati", "closeret", LastData, "MON");
newMonth = month() != ref(month(), 1);
a = perf(rettNav, barssince(newMonth));

You can always use the chart to check the values and have a visual confirmation of the the values returned by each variable.



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
Lagged Data From a Custom Database
Random Value for Each Trading Bar
Custom Weight for Individual Securities
Extensive Fundamental Data for U.S. Stocks
History of dividend payment for stocks in the US stock market

How-to Lessons
How to quickly select stocks based on the last value of a databas...
How to add custom position-based metrics to your trading system
How to get fundamental data for U.S. Stocks
How to download earnings calendar data for various stocks
How to create a custom trendline

Related Forum Threads
Monthly/weekly summation for a custom database field
Chart for 1m bars over a custom time range
Composite tickers under custom database
Updates to a custom database
How do I find the close price for an entry matching a custom DB

Blog Posts
Speed Up Optimizations by Saving Ranking Data into a Custom Datab...
Create custom metrics for the statistical data analysis tool
How to Create Custom Metrics for Your Trading Positions
Creating and managing notes for your stocks
Custom Shortcuts - Move a Chart to Display the Last Quotes/Data









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 2021 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.