NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-05-2011, 02:57 PM   #1
Federico
Senior Member
 
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
Default Floating window or Floating Box

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.
Attached Images
File Type: png Using Values[].Set.png (165.5 KB, 12 views)
File Type: png Using Value.Set[Ent].png (192.9 KB, 7 views)
Last edited by Federico; 07-05-2011 at 03:52 PM.
Federico is offline  
Reply With Quote
Old 07-05-2011, 03:17 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

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
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-05-2011, 04:06 PM   #3
Federico
Senior Member
 
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
Default

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.
Federico is offline  
Reply With Quote
Old 07-05-2011, 05:10 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

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.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 07-05-2011, 05:24 PM   #5
Federico
Senior Member
 
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
Default

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]; }
}
Attached Images
File Type: png ResultsOK.png (190.3 KB, 25 views)
Last edited by Federico; 07-05-2011 at 05:26 PM.
Federico is offline  
Reply With Quote
The following user says thank you to Federico for this post:
Old 07-06-2011, 07:40 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Thanks for sharing your results here with our community members.
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 07-06-2011, 04:09 PM   #7
Federico
Senior Member
 
Join Date: Apr 2009
Posts: 108
Thanks: 3
Thanked 5 times in 5 posts
Post

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)
{
}
Federico is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 08:18 PM.