I'm still pretty new as far as NinjaScript/C# goes, and I'm not a programmer. I've gone from 0 to an okay working knowledge in a short time, but still, my experience and skill is limited... Being new, sometimes, while implementing a new concept, I run into roadblocks I don't know how to resolve, don't want to/can't spend more time on yet, and shelf (to later ask the forum for help figuring it out). So, I've built up a few things by now I will need help understanding. But I finally set up a forum account because I ran into one such roadblock that I think (if resolved) will help my efficiency too drastically to shelf.
Time to start clearing those shelves (I hope)!
I'll start by saying that, for this post, my goal is basically to combine the code of two indicators I've found.
I found the "Position Display Indicator" posted by NinjaTrader_Jim on the NT ecosystem (I'll call this the Display script):
Works exactly as intended, and it's a great starting point to piggyback off of (with some mods, I think I can get the kind of display I want out of it, or at least close enough for now). However, the way it's scripted, it requires that I go into the user dialog to select the account I want it drawing its info from. Huge inconvenience when needing to switch between a variety of accounts (such as sim accounts to test/practice varying concepts concurrently). For now, I don't want more charts/chart tabs to juggle. I prefer to just change accounts as needed in the chart trader drop-down, keeping a cleaner interface with a lower impact on computer resources.
So, I searched for how to auto-detect the account name that's already attached to a given chart window, and I found the following link with a "PrintChartTraderSelectedAccount" indicator zip file posted by NinjaTrader_AlanP (See "SelectedAccount Script Link" below -- I'll call this one the Account script).
Again, works great. It detects the account name in the chart trader, then prints that name. Simple. Any time I switch accounts in that chart window, the printout text changes to match. (It spammed the prints, but I figured out a workaround to fix that. Now it only prints once per change.)
Where I'm struggling is with how to combine the two indicators. I've tried a few things, but I'm just too green still to know what I'm missing. I hoped I could incorporate the language from the Account script into the Display script and then tweak the account reference language (such as in the State.DataLoaded section, among others) in the Display script, but no dice.
I'm figuring I'll need to do at least 3 things (maybe more?):
2. Because the "xAlselector" variable is designated as a string in the Account script, I'm assuming I need a different variable specifically designated as an "Account" for the Display script to accept it in place of the user dialog menu (maybe along the lines of "accountContainer = xAlselector.SelectedAccount"?)
3. Because "State.DataLoaded" only loads once (when the chart is first opened/refreshed), I'm also figuring I'll have to put pieces of the Account script in other places (such as OnRender in the Display script, and/or add an OnBarUpdate section to it, etc) to actively "update" the account reference variables whenever the account is changed on the chart. Otherwise, the script will just cling to the account that was active when the chart was reloaded without ever updating.
I'm hoping the blending of the two scripts would be simple enough for someone (more knowledgeable than myself, lol) to just walk me through it step by step (tell me exactly what needs to change and where in the Display script, so that it can accommodate the concept from the Account script). But the things I tried to do weren't good enough, so I'm sure I was missing some key things.
Thanks very much for any help you all can give me!
I've learned a ton from countless pages across the NT Help Guide and this forum, along with sample scripts (help guide) or ecosystem scripts I could study and dissect to understand how things interact and sometimes splice together what I need. Thanks to EVERYONE who generously contributes to all those sources, helping people like me go from absolute, literal programming newb to building enough knowledge to quickly start DIYing custom indicators/strategies that have made my life easier. Love it.

Comment