Ninja script question - Text Placement on Chart - futures io
futures io futures trading



Ninja script question - Text Placement on Chart


Discussion in NinjaTrader

Updated by IanC55
      Top Posters
    1. looks_one markbb10 with 9 posts (1 thanks)
    2. looks_two sg72 with 4 posts (4 thanks)
    3. looks_3 Stevea94 with 2 posts (1 thanks)
    4. looks_4 utilizator with 1 posts (1 thanks)
      Best Posters
    1. looks_one sg72 with 1.0 thanks per post
    2. looks_two Epistemophilic with 1.0 thanks per post
    3. looks_3 Stevea94 with 0.5 thanks per post
    4. looks_4 markbb10 with 0.1 thanks per post
    1. trending_up 446 views
    2. thumb_up 9 thanks given
    3. group 7 followers
    1. forum 18 replies
    2. attach_file 2 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Thread Tools Search this Thread
 

Ninja script question - Text Placement on Chart

  #1 (permalink)
Morristown NJ USA
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
 
Posts: 91 since Aug 2012
Thanks: 36 given, 41 received

Ninja script question - Text Placement on Chart

Hello All,

First I am not a programmer but I have been learning and doing OK on that path.

I have written a script that does some correlation work of several other indicators and I want to
print out various output of that correlation on the chart, or in a table or in the MA.

I just want a list of the five outputs that are basically just a red or green long, short indication.

Currently I am using the Draw.TextFixed() call but this limits me to the four corners of the chart
for placement of the text.

What would I use to place the output in a list at some predefined area of the chart

Output one - Long
Output two - Short
Output three - Long

etc.


As always thanks for the input.

Mark

Reply With Quote

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
ThinkOrSwim
Moving average with Lag reduction
NinjaTrader
Linux?
ThinkOrSwim
 
 
  #2 (permalink)
Moncton Canada
 
 
Posts: 3 since Nov 2017
Thanks: 0 given, 2 received

Hi markbb10, I suggest to first try to output your values to Output window, as shown in the attached image.
From there, you can copy& paste the values in your text editor (Notepad, Wordpad, MS Word etc) and save them.
I hope this helps.

Attached Thumbnails
Click image for larger version

Name:	topic.806937.png
Views:	33
Size:	53.7 KB
ID:	298815  
Reply With Quote
The following user says Thank You to utilizator for this post:
 
  #3 (permalink)
Morristown NJ USA
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
 
Posts: 91 since Aug 2012
Thanks: 36 given, 41 received


Hi Utilizer,

Thanks for the suggestion but this will not accomplish what I am looking for. These values are
changing on every candle, so I want an easy way to visually look at all 5 conditions and
be able to ascertain an entry. Copying and pasting values will not work.

I have all the code written to produce the data I am just looking for the code to use to print those
values on the chart in a table.

Thanks again for your reply.

Mark

Reply With Quote
 
  #4 (permalink)
Bucharest, Romania
 
 
Posts: 1 since Apr 2020
Thanks: 0 given, 1 received


markbb10 View Post
Hi Utilizer,

Thanks for the suggestion but this will not accomplish what I am looking for. These values are
changing on every candle, so I want an easy way to visually look at all 5 conditions and
be able to ascertain an entry. Copying and pasting values will not work.

I have all the code written to produce the data I am just looking for the code to use to print those
values on the chart in a table.

Thanks again for your reply.

Mark

Hi Mark,

I haven't actually tried it, but there's this NinjaTrader support link which I think might be helpful (I assume you are using Ninja Trader 8):

https://ninjatrader.com/support/helpGuides/nt8/?using_sharpdx_for_custom_chart_rendering.htm

Under SharpDX Text Rendering section - I believe it might do sort of what you are trying to achieve, or at least close - place some text at some arbitrary (x,y) coordinates.

Hope this helps,
Sorin

Reply With Quote
The following user says Thank You to NT2005 for this post:
 
  #5 (permalink)
Newbury, UK
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader, Kinetick
Trading: NQ, CL, 6E
 
Posts: 64 since Oct 2015
Thanks: 1 given, 113 received


markbb10 View Post
Hello All,

First I am not a programmer but I have been learning and doing OK on that path.

I have written a script that does some correlation work of several other indicators and I want to
print out various output of that correlation on the chart, or in a table or in the MA.

I just want a list of the five outputs that are basically just a red or green long, short indication.

Currently I am using the Draw.TextFixed() call but this limits me to the four corners of the chart
for placement of the text.

What would I use to place the output in a list at some predefined area of the chart

Output one - Long
Output two - Short
Output three - Long

etc.


As always thanks for the input.

Mark

Not sure if this will help - this code uses the .NET grid overlay stuff which I borrowed from someone else - I forget who.

I wanted on chart buttons but it also implements text. Essentially, the screen is split into predefined grid of cells and buttons/text can be created in any cell.

The code was never polished so apologies if it's not that clear.

The other way - probably simpler - which I also use, is to draw a block of text (Draw.Text) every bar at a fixed bar on the screen. I use a -ve bar offset so it appears at the right edge. Works for me.

All the best.

Steve

Attached Files
Register to download File Type: cs smaButtonTest.cs (29.6 KB, 6 views)
Reply With Quote
The following user says Thank You to Stevea94 for this post:
 
  #6 (permalink)
Morristown NJ USA
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
 
Posts: 91 since Aug 2012
Thanks: 36 given, 41 received

Thank you all for the suggestions. This will give me some direction to research, very much appreciated.

Mark

Reply With Quote
 
  #7 (permalink)
Orange County, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
 
Posts: 10 since Sep 2018
Thanks: 2 given, 7 received

If I understand correctly, I think you're just looking for a flexible placement of text on the actual chart. If that's the case, then why don't you use Draw.Text() instead of Draw.TextFixed()? With Draw.Text() you can line up the text above/below a given bar where it belongs and offset it as desired.

https://ninjatrader.com/support/helpGuides/nt8/?draw_text.htm

If you're looking to generate a multi-line text and print it all at once, then you can use string.Format and string concatenation (using + sign) and use the linefeed character \r (backslash r) to insert new lines in your text string.

Here's a sample code snippet:

string format = "{0,4:F0} ({1,5:P1})" ;
string disptext = "Price stats:" ;
disptext += "\rR1=" + string.Format( format , u1+l1 , (double)(u1+l1)/(double)total ) ;
disptext += "\rR2=" + string.Format( format , u1+u2+l1+l2 , (double)(u1+u2+l1+l2)/(double)total ) ;

This will produce something like below:

Price stats:
R1=8354 (36.6%)
R2=15288 (67.0%)

You can look up the string.Format incantations online.

Hope this helps.

Reply With Quote
The following 2 users say Thank You to sg72 for this post:
 
  #8 (permalink)
Morristown NJ USA
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
 
Posts: 91 since Aug 2012
Thanks: 36 given, 41 received

Thank you all for your replies.

I am experimenting with Draw.Text. I have this line of code running and acting as expected.
If I change the "candles back" parameter to 23 versus 22 it does not print. Can anyone explain
why? I have about 100 candles on the chart

Draw.Text(this,"drawtag1","Weis Wave - Red",22,Close[0],Brushes.Black); - This works
Draw.Text(this,"drawtag1","Weis Wave - Red",23,Close[0],Brushes.Black); - This does not

So confusing

Reply With Quote
 
  #9 (permalink)
Los Angeles
 
Experience: Advanced
Platform: NT8, Python, and TOS
Trading: NQ, ES & CL
 
Posts: 22 since Oct 2010
Thanks: 19 given, 26 received


markbb10 View Post
Hello All,

First I am not a programmer but I have been learning and doing OK on that path.

I have written a script that does some correlation work of several other indicators and I want to
print out various output of that correlation on the chart, or in a table or in the MA.

I just want a list of the five outputs that are basically just a red or green long, short indication.

Currently I am using the Draw.TextFixed() call but this limits me to the four corners of the chart
for placement of the text.

What would I use to place the output in a list at some predefined area of the chart

Output one - Long
Output two - Short
Output three - Long

etc.


As always thanks for the input.

Mark

I hope this helps.

 
Code
protected override void OnBarUpdate()
{
  if (CurrentBar < 20) {return}

  MyTextBox(TextForBox());    
}


protected string TextForBox()
{
  // add text here
  string yourText = "";
  return yourText;  
}

protected void MyTextBox(string textThatGoesInTheBox)
{
  TextFixed myTF = Draw.TextFixed(this, "MyText", textThatGoesInTheBox, TextPosition.TopRight);
  myTF.TextPosition = TextPosition.TopRight;
  myTF.AreaBrush = Brushes.DimGray;
  myTF.AreaOpacity = 90;
  myTF.TextBrush = Brushes.Black;
}

/* Instantiate a TextFixed object
TextFixed myTF = Draw.TextFixed(this, "tag1", "Text to draw", TextPosition.TopRight);
 
// Change the object's TextPosition
myTF.TextPosition = TextPosition.Center;

TextPosition Possible values are:
TextPosition.BottomLeft
TextPosition.BottomRight
TextPosition.Center
TextPosition.TopLeft
TextPosition.TopRight*/


Last edited by Epistemophilic; May 10th, 2020 at 10:35 AM.
Reply With Quote
The following user says Thank You to Epistemophilic for this post:
 
  #10 (permalink)
Morristown NJ USA
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
 
Posts: 91 since Aug 2012
Thanks: 36 given, 41 received


I want to thank everyone for their ideas and guidance. I am slowly learning more but I would be lying if I did not say it is driving me crazy.

Here is my latest issue. I have a short code snippet that will print the status of a indicator depending on the value of the variable called trend at a defined location on the chart.

In the format below I get printing of the status correctly in the defined locations. Please note that the first if statement is a Draw.TextFixed call and the second is Draw.Text.

if (trend == 1)
Draw.TextFixed(this,"status","Weis Wave is Green", TextPosition.TopRight,Brushes.White, ChartControl.Properties.LabelFont,Brushes.Black,Brushes.Green,100);

if (trend == -1)
Draw.Text(this,"drawtag1",false,"Weis Wave - Red",18,Close[0],-80,Brushes.Red,myFont,TextAlignment.Center,Brushes.Red,Brushes.LightGray,80);

If I change the first If statement to a Draw.Text, using proper syntax the indicator will compile without error but produces NOTHING on the screen. I have never seen anything more frustrating. Below is the code sequence that will compile but prints no data on the chart.

if (trend == 1)
Draw.Text(this,"drawtag1",false,"Weis Wave - Green",18,Close[0],-70, Brushes.Green,myFont, TextAlignment.Center,Brushes.Green,Brushes.LightGray,80);

if (trend == -1)
Draw.Text(this,"drawtag1",false,"Weis Wave - Red",18, Close[0],-80, Brushes.Red, myFont, TextAlignment.Center,Brushes.Red,Brushes.LightGray,80);

This prints nothing

Reply With Quote



futures io Trading Community Platforms and Indicators NinjaTrader > Ninja script question - Text Placement on Chart




Upcoming Webinars and Events
 

Understanding Order Flow Stop Runs & Icebergs w/Bookmap

May 28
 

Free BloodHound Licenses to everyone!

June
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts