I'm creating an indicator, that so far just needs to display various information on the price panel.
If I had maybe 3-4 variables I would like to output to the screen, what would be a good way to do this? I would like to use a function that would somehow keep it together, so that when resizing bars or scrunching the chart together, all of the values do not get too close to each other, or loose their spacing.
If anyone knows of an indicator that has done this (I can't think of any), that might get me started as well.
I just had a power outage right as I was hitting the compile button.
My PC restarts, open the chart up, and the study still works.
But.... when I went to edit the strategy, there is NOT one line of code. This is frustrating. I don't know if I'm going to recreate this damn thing again?
And here are some pics showing the script running RIGHT NOW! I don't think I can recover anything. I have a post on ninja forums, I'm hoping there is some magical directory somewhere that may have captured something?
Site Administrator Swing Trader Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
Posts: 49,984 since Jun 2009
Thanks: 32,458 given,
98,242
received
Check Round2TickSize (if I remember correctly) for easy rounding. You can also append .ToString("0.00") to the end of a variable to reformat it to two decimals for example.
As for your computer crash, check your temp folder location and check your NinjaTrader folder --- it likely creates a temp file and renames it once compiled. The compiled code is cached in the DLL it creates which is why it still works.
I am not sure where temp files are stored, you might have to check with NT support if not in your %temp% Windows path.
I asked those guys over @ ninjaForums about the crash earlier and possible recovery from somewhere, and they told me I was SOL. I recreated my indicator, and *LUCKILY* since I was getting some help from @Fat Tails about referencing his indie, I had some code snippets I posted that allowed me to recreate the script rather quickly. Otherwise it would have taken me a bit longer. I guess that's why I typically post a lot as I am scripting so that I have a point of reference to help my thought process.
And about that crash.... what are the odds? Think about it, the only reason my code disappeared was b/c my script was compiling while the computer turned off. If I had gone to hit that compile button 3 seconds earlier, or 3 seconds later, my code wouldn't have disappeared. I could have heard a noise, or dropped the remote to my radio, or gotten a phone call, or browsed an interesting topic on a web browser, or received an email that I decided to open that what have caused a delay. What are the freaking odds?!?!?!
For the rounding, I wound up using the ROUND function I guess that is native to C# not a ninja type function. I wound up going with this:
The following user says Thank You to forrestang for this post:
When you code an indicator you have several options.
-> If it is half ready, you cannot compile it, but you can save it via F4. In this case it will still be there after a power outage.
-> Once you have terminated your work you can compile via F5.
Now, the problem is there if you do not finish your work. NinjaTrader will try to compile it and you will get a compiler error. For this case I have created a subdirectory WorkInProgress in My Documents \ NinjaTrader 7\ bin\Custom\Indicator folder. I simply drag the indicator into that directory and later retrieve it to continue my work.
The following 3 users say Thank You to Fat Tails for this post:
You don't seem to connect your machines to a backup power supply (UPS) .... your machines don't seem to have power protection; Right ?
In my part of the world, I have as my power protection equipment -----> Stabilizer/Surge Protector and Inverter/Charger System (a more efficient kinda UPS); and I don't use my machines if these protection equipment are defective.
Did not reed this meesage before. When you want to display a data box it gets interesting, when you define what you want to display.
Static Display: Only the information of the last bars of the chart is used to fill the data box.
Dynamic Display: The information displayed is retrieved from the last par painted on your chart. This means that when you scroll the chart back hoizontally, the information displayed changes in line with the data displayed.
To see the difference, please have a look at the following static and dynamic indicators:
Examples
Static: NinjaTrader default Regression Channel indicator. It calculates the values from the last bar processed by OnBarUpDate(). Dynamic: Regression Channel V2 (download section). It calculates the regression channel from the last values displayed on the chart.
Static: Percentage indicator on RelativeVolume V14 indicator. Dynamic: VolatilityBands V37. The values displayed in the upper left corner are in line with the sessions and bars displayed on the chart. The indicator has a custom plot, all calculations performed are stored in DataSeries objects and then retrieved by accessing the values for the bars shown on the chart.
The following user says Thank You to Fat Tails for this post:
If I wanted to create a Data Box, that will always remain in a fixed position on the chart, AND have control over the color/font of text via some condition I have, is this possible?
-----EDIT----
Looks like it needs custom databox and override of plot function. I will have to figure this out.
i heard about a request of a textbox in the chart showing some during trading needed infos.
i had some time today and made this as a posting now for all.
this is a code-example for making a such a textbox with live-infos …
The following user says Thank You to cory for this post:
I've got the text box by itself working. I've used that before.
Two problems with that though:
1.) I have a text box with several variables in it. And I would like to be able to control the colors of each variable individually.
2.) If I create several text boxes, it will probably not maintain that nice spacing. So that if a user decides to rescale his chart, or blow it up fullscreen, the variables will overlap, or seperate, looking kinda sloppy.
I edited my post above, in that I will probably just have to learn how to create a custom data box and over ride the plot function (thats what someone suggested on the NT forum).
Correct. THe easiest way is to code an indicator with a custom plot. An example for such an indicator is the SessioVolatilityBands. It plots a small data box in the upper left corner of the chart. The data box can also be displayed in the upper right corner of the chart. Of course it is possible to plot a stand-alone data box with a different text font and different colors somewhere else on the chart.
The following user says Thank You to Fat Tails for this post: