Click here to Login





                                                   Cast Symbol field (e.g. name3) as numeric?

  0

0
Kiran
2019-06-04 13:26:39


I'm using name3 Symbol field to capture a numeric field [0-2], where if the earnings are reported in Jan/Apr/Jul/Oct = 0, Feb/May/Aug/Nov=1, etc.
Then, I use the calculation below to estimate how many months to earnings.
I'm using this as a BuyRule so i don't enter positions in earnings month. [i.e. Buy = months2earnings>0]

months2earnings = name3 - month()-4*round(month()/4,0);

The assignment gives an error because name3 isn't numeric.
- Is there another field i can use/create that's numeric? Don't want to create a custom database for "Earnings Month" because this value isn't date-dependent.
- If not, how do i case name3 to a numeric field, so the above assignment can evaluate.




QuantShare
2019-06-07 09:19:51

  0

You need to convert that string to a numeric value using for example: Convert.ToDouble method

Example:
String s = "1000.25";
Double d = Convert.ToDouble(s);



Kiran
2019-06-07 12:21:34

  0

"Convert.ToDouble" doesn't work in Simulators or Screeners.
Where do i add this code?
String s = "1000.25";
Double d = Convert.ToDouble(s);

If i need to create an Indicator, it returns a vector (time-series), which is overkill for this, because this is a Symbol attribute, not an indicator that changes with time.
- How can i extend the Symbol Members?

Pl provde a solution to this.



QuantShare
2019-06-08 06:56:15

  0

Here is a custom function you can download and use:
ToNumeric





ToNumeric (by Azouz, uploaded several months ago)
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads Notes Report an item

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
Equity Data to Ticker Symbol
Sum of a Custom Database's Field
Chande TrendScore By Symbol
Update the Stock Exchange Associated With U.S. Stocks - Market Fi...
Ticker Symbol Index

How-to Lessons
How to quickly select stocks based on the last value of a databas...
How to rename a ticker symbol
How to quickly add a ticker symbol
How to download and use U.S. stocks earnings data
How to import trades into a portfolio

Related Forum Threads
Creat a Composite Index from few stock symbol
How do I refer to the close price of another symbol in a formula?
STATIC WATCH LIST-add a symbol to existing static watch list from...
comp values stored as a separate field in the db
guru The ticker symbol for

Blog Posts
Update Chart Layout based on Active Ticker Symbol
Backtesting Your Trading Systems: Symbol Segmentation
Update Chart Layout based on Active Ticker Symbol - Part 2
How to create a trading indicator that uses stock news
How to Download Trading Data for Certain Securities Only









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.