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)
i have been trying to code some simple strategies in nt and so far have not had much problem if i use just one single position. if i try to have multiple positions in the same direction, i am having trouble with the code to manage those positions.
i have emailed nt's ninjascript support staff and for the most part they know their stuff and are quite helpful. some days ago one of these ninjascript support people helped me put an idea into code, but it is still incomplete. i would greatly appreciate if more advanced programmers could tell me how should i structure a strategy so that it did the following:
as long as uptrend condition is true do the following, as soon as uptrend condition is no longer true, exit all long positions. [how could i bracket or condition all this code so that all long positions and their respective stops are closed as soon as the uptrend condition is no longer true?]
as soon as uptrend condition becomes true, open one long position. [the entries would look like these and are ok, that's not where i'm having trouble]
[the position management section the people at nt have helped me with is what is incomplete]
the idea is for the strategy to set a stoploss order for each position and if price moves in my favor, move each stop first to break even and then to lock profit. it seems like it would be necessary to use iorder objects and onexecution() methods, so the strategy knows how many positions it has opened and at what price each. the guys at nt helped me with the above code, but if i try to test it on a chart, it will only take a long position once (my guess is that all variables need to be reset to their starting values after the positions are closed because the uptrend condition stopped being true or a stop was hit. i just don't know how to do that).
so, i have a position management system that causes the strategy to open positions only the first time the uptrend condition is true in a chart, but i would like the strategy to open those positions every time the condition is true, shut everything down if uptrend stops being true, otherwise manage the positions and then reset everything after the positions were closed.
i would greatly appreciate it if anyone can help me complete this code so that it is more functional. thanks in advance.
Can you help answer these questions from other members on NexusFi?