Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi guys, I had a block of code that I’ve used in many strategies. I created a user defined function today so that I can just call it in my strategies. This way, anytime I need to make changes to the function.. I can amend the function and it changes it in all my strategies. One of those functions is simple... calculating position size
Then I am calling this function in my strategy as
AccountCalculation();
It works, it prints out the correct position size that my strategy would had calculated.
Problem: I can’t seem to assign the values from this function to a variable within my strategy so that I can use it.
I keep getting an error “can’t convert void to double”
I just want to take the value that this function is calculating and then assign it to a variable for the position to purchase.... any help would be appreciate
Can you help answer these questions from other members on NexusFi?
[Note that when using public static for shared functions it is best to use a naming prefix to avoid namespace clashes, and also that compiling will cause links to be broken until all charts/strats are F5'd or reopened. (I do use this mechanism a lot and would like to find a good solution to that problem.)]
Another alternative is to use the 'partial class' mechanism for instanced funtions.
I'm not a programmer so i think the problem is pretty basic but b/c i don't have the background i'm stuck. i've been working with ninjascript for about 4 years and am well verse in creating strategies... just never done anything like this. would appreciate if someone can help! i think once i get this to work i should be good to go with various other functions that i need to create..