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)
Obtaining the Account in code and keeping reference to it thro re-connects etc
I want to automate some sanity checking for NT7 which I currently do by eye (and occasionally get wrong, costing me serious money).
I have a strategy running on 20 forex pairs. The strategy enters a position and places a stop and a profit target bracket simultaneously.
Various things can go wrong so I'm going to try to build:
(a) an indicator for the Market Analyzer to display the nearest stop order
(b) a strategy whose sole purpose is to check every market for a position and check those with positions for the presence of a stop and a target order.
I have this, which the NT support team told me they can't help me with:
The "accountName" variable is a parameter I can set in the Parameters dialog box of the indicator or strategy, I found a NinjaTrader indicator that does some stuff in this area - BarTimer.cs - and I tried copying that as far as it went but I've had no joy.
The thing I can't figure out is which event should I use? It doesn't work in Initialize().
It looks like there are different events available in strategies that indicators don't have.
And of course I don't want to write something that's going to hog the CPU cycles just to do checks.
Generally speaking, maybe I'm barking up the wrong tree completely here - or perhaps there's a secret API documentation for NT7 somewhere that they wouldn't tell me?
Thanks in advance!
You can discover what your enemy fears most by observing the means he uses to frighten you.
Can you help answer these questions from other members on NexusFi?
I have a similar thing, not quite finished and tested. I run a strategy called MonitorLive which just checks account value changes and can email/text me. It also has an OnConnectionStatus to let me know if that goes down.
Regarding which event to use, what I do is run it against something that trades most of the time, like ES or 6E, and set it to a 1 min strategy. Then I put all the code in OnBarUpdate and it runs every minute (apart from when the market is closed which is 10pm for an hour, London time.)
That sounds good. What is the actual if statement you use to trigger your alarm in onBarUpdate()?
That's definitely something I need. It isn't my primary aim, but I can see I'll need it to make sure I have a valid connection & therefore account etc.
PS you must be David? I would have put you in as my 'referrer' when I did the registration form but I didn't know your username - not sure what advantage it gives you but I'd be happy to do it in retrospect if I still can.
You can discover what your enemy fears most by observing the means he uses to frighten you.
What are you not sure about? The notify() bit or the GetAccountValue stuff?
I think I can just play around with it on the simulation account, e.g. I can put something in the onConnectionStatus and then pull out the network cable.
Actually even with documentation, you still have to play around with the NinjaTrader API to find out what it really does.
You can discover what your enemy fears most by observing the means he uses to frighten you.