Click here to Login





                                                   C# Output for Validation

  0

0
Dave W.
2015-02-05 14:25:20


Hi. I'm trying to add some output statements in a money management script to help me troubleshoot a trading system. One of the statements is in the OnEndPeriod event and I want it to tell me if the period is the last day of the month. I'm using the following code, but I'm doing something wrong - the result should be either a 0 or a 1, but it isn't. Can you point me in the right direction / show me how to do it? Also, in the formula below I used "SPY" in one of the statements -- I'd prefer not to hard-code a symbol name.

OnEndPeriod Event Code

MMParser parser = Data.ParseFormula("a = (ref(Month(),-1) != Month());");
Divers.Output("Last Day of Month?: " + parser.GetTimeSeries("SPY","a") );



Dave W.
2015-02-05 14:46:58

  0

Best Answer
I figured it out. Here's the answer in case it helps someone else.

OnEndPeriod Event Code

// Last Day of Month. Returns 1 for true, 0 for false
string[] SymbolList = Data.GetSymbols(); //Need to get a symbol for use in the GetTimeSeries statement.
MMParser parser = Data.ParseFormula("a = (ref(Month(),-1) != Month());");
TimeSeries LastDay = parser.GetTimeSeries(SymbolList[0], "a");
double dblLastDay = LastDay[0];
Divers.Output("Last Day of Month?: " + dblLastDay );



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
Output metric for each trading year
Average Output Per Month
Per Symbol Average Output
Average Output Per Year
Index Investment Data for U.S. Futures Markets

How-to Lessons
How to display the number of stocks per day for different RSI gro...
How to download EOD quotes for active and valid stocks only
How to get stocks for a particular index using the global script
How to add future bars to plan for market scenarios
How to screen for stocks having a high correlation with the Dow J...

Related Forum Threads
Output window problem
Custom Multi-Dimensional Fitness Formula (CMDFF) for Optimizer
Save Rules Analyzer Output
Clear output window
Neural Network Prediction Output function - seems strange

Blog Posts
Rules performance for different volatility regimes
Create custom metrics for the statistical data analysis tool
How to Scan for Parallel Resistance and Support Lines
How to Download Trading Data for Certain Securities Only
How to Select the Best Market Indicator for your Trading System









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.