![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
|
Hello.
Please, excuse me for my English. It's possible to create a NinjaScript that display a floating window like Data Box? If it's not possible, it's possible to create a floating Box (rectangle) with drag and drop caabilities? Or How to display data in Data Box without drawing these on the chart? For example, the Range of the current bar. This is an indicator of Position Size and I need to display in the Data Box the EntryPoint, Stop, StopSize, Risk, and Number of contratcts. All this data is already display on the upper left corner of the chart and my Idea is to display this data in the Data Box instead on the upper left corner of the chart. I use the Value.Set(Ent) and the entry is displayed into the Data Box, but I don't know how to display several data. Here is the code snippet: protected override void Initialize() { Add(new Plot(new Pen(Color.DarkGreen,2), PlotStyle.Line, "Range")); Add(new Plot(new Pen(Color.DarkGreen,2), PlotStyle.Line, "Entry")); Overlay = true; CalculateOnBarClose = false; DisplayInDataBox = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. MaxRiskPerTrade = Math.Round(capital * maxDayRiskPercent / 100 / numTradesPerDay, 2); Max = High[0]; Min = Low[0]; Rng = Mx-Mn; Ent = Max + TickSize; Stp = Min - TickSize; tStp = Rng + (2 * TickSize); RiskFor1c = (tStp / TickSize* valueTick) + commission; Value.Set(Rng); // Values[0].Set(Rng) Value.Set(Ent); // Values[0].Set(Ent) } The Value.Set only work with one data, the last, and when I use Values[0] and Values[1] the data is showed in Data Box but the chart is see like the attached image. Thank you. Thank you.
Last edited by Federico; 07-05-2011 at 03:52 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Federico,
For a supported technique to see values in the data box but not plotted: Set the indicator plot color to the same color as the chart background. Our framework is built with C#, so a lot of this you are capable of doing. We do not provide support for general C# -- only the NinjaScript items documented in our help guide and reference samples here on the forums. For a start on undocumented/ unsupported NinjaScript, the following thread may be helpful: http://www.ninjatrader.com/support/f...ad.php?t=22435
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
|
Hi Ryan.
Thank you for your quick response. Really do not want to program with not supported techniques. I completed my post after you send me your answer. Pleas, Could you check my post again? Im using supported techniques to show my results in data box without showing up on the chart. Thank you again. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
This is more of a workaround than a programming technique. You can set the color of the indicator as the same color as the chart. Set your indicator plot to White rather than dark green and you'll see data box value but no visible lines.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
|
Thank you very much again Ray.
I solved the problem. I Attached the result. I create a Properties as DataSeries for each value on my results and then Set the properties values with my calculations. The other problem on the chart was solved setting AutoScale to false. This is the code Snippet: protected override void Initialize() { Add(new Plot(Color.DarkGreen, "Entry")); Add(new Plot(Color.Red, "Stop")); Add(new Plot(Color.Goldenrod, "Range")); Overlay = true; CalculateOnBarClose = false; DisplayInDataBox = true; AutoScale = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. MaxRiskPerTrade = Math.Round(capital * maxDayRiskPercent / 100 / numTradesPerDay, 2); Max = High[0]; Min = Low[0]; Rng = Mx-Mn; Ent = Max + TickSize; Stp = Min - TickSize; tStp = Rng + (2 * TickSize); RiskFor1c = (tStp / TickSize* valueTick) + commission; Entry.Set(Ent); Stop.Set(Stp); Range.Set(Rn); } In Properties I Added: [Browsable(false)] [XmlIgnore] public DataSeries Entry { get { return Values[0]; } } [Browsable(false)] [XmlIgnore] public DataSeries Stop { get { return Values[1]; } } [Browsable(false)] [XmlIgnore] public DataSeries Range { get { return Values[2]; } }
Last edited by Federico; 07-05-2011 at 05:26 PM.
|
|
|
|
|
The following user says thank you to Federico for this post: |
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
|
Thanks for sharing your results here with our community members.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Bertrand for this post: |
|
|
|
#7 |
|
Senior Member
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
|
I forgot indicate that I do not plot the plots, that means I leave empty the public override Plot Method.
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) { } |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Floating Trend Box | honkin | Miscellaneous Support | 2 | 06-01-2011 08:23 PM |
| Floating customizable toolbar | trader65 | Charting | 2 | 06-06-2008 04:07 AM |
| Floating-Point Arithmetic | nico_p | General Programming | 4 | 04-11-2008 02:48 AM |
| detached-floating toolbar | trader65 | Charting | 1 | 01-26-2008 07:52 AM |
| Floating-Point Arithmetic | NinjaTrader_Josh | Tips | 0 | 11-06-2007 05:05 PM |