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 > Application Technical Support > Charting

Charting Support for NinjaTrader Advanced Charting.

Reply
 
Thread Tools Display Modes
Old 08-13-2011, 09:47 AM   #1
pkinoc
Member
 
Join Date: Apr 2008
Posts: 67
Thanks: 0
Thanked 0 times in 0 posts
Default Programmatically draw a global draw object

From the sample code in help it appeared that adding a "@" to the beginning of a draw tag might do it but it doesn't work. The line I draw on one chart doesn't appear on the others. Any ideas?

Eg. DrawHorizontalLine("@TopRange", true, RangeHigh, Color.Red, DashStyle.Solid, 2);
^
pkinoc is offline  
Reply With Quote
Old 08-13-2011, 09:24 PM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for the note.

Unfortunately this is not possible to do at this time. The strategy or indicator would need to be run on each chart in this instance.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-23-2012, 08:28 AM   #3
ggerstein
Junior Member
 
Join Date: Oct 2011
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Brett,

I am having a similar problem as this gentleman. I am just trying to draw a line on a chart in the market replay connection. The code is as follows

private void drawTrendLine(){
string label = "trendLine" + drawCounter.ToString();
int startx = getstartX();
int endx = getendX();
double startY = getStartY();
double endY = getEnd();
Print("Drawing Trend Line: startx =" + startx + " endx = " + endx + " starty = " + startY + " endy = " + endY);//This prints correct values
DrawLine(label, startx, startY, endx, endY, Color.Black);

drawCounter = drawCounter+1;

} //end drawTrendLine method

Is there any reason this method should not work? Can you not draw objects in market replay or not draw them with a strategy? If either of those things are possible could you point me to a code example. I don't want to use plots because I am not using a DataSeries Object. I just want to draw the line using my own calculated values.
ggerstein is offline  
Reply With Quote
Old 01-23-2012, 10:45 AM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by ggerstein View Post
Hi Brett,

I am having a similar problem as this gentleman. I am just trying to draw a line on a chart in the market replay connection. The code is as follows

private void drawTrendLine(){
string label = "trendLine" + drawCounter.ToString();
int startx = getstartX();
int endx = getendX();
double startY = getStartY();
double endY = getEnd();
Print("Drawing Trend Line: startx =" + startx + " endx = " + endx + " starty = " + startY + " endy = " + endY);//This prints correct values
DrawLine(label, startx, startY, endx, endY, Color.Black);

drawCounter = drawCounter+1;

} //end drawTrendLine method

Is there any reason this method should not work? Can you not draw objects in market replay or not draw them with a strategy? If either of those things are possible could you point me to a code example. I don't want to use plots because I am not using a DataSeries Object. I just want to draw the line using my own calculated values.
From the style of your code, are you sure that this line:

Code:
double endY = getEnd();
is not supposed to actually read:

Code:
double endY = getEndY();
?
koganam is offline  
Reply With Quote
Old 01-23-2012, 12:39 PM   #5
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Furthermore, what exactly does not work in the code.

Do you get Print() to output if you add in Print to make sure it is working as expected?

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-23-2012, 06:08 PM   #6
ggerstein
Junior Member
 
Join Date: Oct 2011
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

Hey Brett,

Thank you for taking the time to reply. The problem is the the drawing object just does not show up on the chart. Actually you are correct about that function name. That was a typo, but those functions are really just placeholders to show the code they are not the actual functions being called.

The functions being called for startx, starty, endx, endy all work and return correct values in the output window so I know that the input passed into the DrawLine(label, startx, startY, endx, endY, Color.Black); is valid input.

What I am thinking now, but haven't tried it yet, is that I have to maybe use a Plot to draw on the chart? That I have to add an indicator of some kind for example using the Add( Indicator Object); in the Strategy and then have the Indicator do the drawing? Is that a correct understanding? I just don't know if you can call DrawLine() from directly within a Strategy. This is really the source of my question. Thank you.
ggerstein is offline  
Reply With Quote
Old 01-23-2012, 10:38 PM   #7
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by ggerstein View Post
Hey Brett,

Thank you for taking the time to reply. The problem is the the drawing object just does not show up on the chart. Actually you are correct about that function name. That was a typo, but those functions are really just placeholders to show the code they are not the actual functions being called.

The functions being called for startx, starty, endx, endy all work and return correct values in the output window so I know that the input passed into the DrawLine(label, startx, startY, endx, endY, Color.Black); is valid input.

What I am thinking now, but haven't tried it yet, is that I have to maybe use a Plot to draw on the chart? That I have to add an indicator of some kind for example using the Add( Indicator Object); in the Strategy and then have the Indicator do the drawing? Is that a correct understanding? I just don't know if you can call DrawLine() from directly within a Strategy. This is really the source of my question. Thank you.
  1. On the line that does not draw, what are the actual startX ... values?
  2. Are there any error messages in your log?
koganam is offline  
Reply With Quote
Old 01-24-2012, 06:42 AM   #8
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

You can call DrawLine from a strategy no problem.

You would need to print out your inputs and make sure everything is getting called correctly. More then likely the problem is there.

If you run out of ideas however you can always send code into support at ninjatrader dot com and I can take a quick look at it. However at this stage first step is to debug with Koganams idea's and also to start adding Prints for all the inputs and the making sure the DrawLine is being called from inside OnBarUpdate().

-Brett
NinjaTrader_Brett 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
Global Draw Objects Mindset Suggestions And Feedback 1 02-18-2011 08:28 AM
Draw object not being removed.. gg80108 Indicator Development 1 08-12-2010 07:21 AM
Global draw lines astrolobe Version 7 Beta General Questions & Bug Reports 4 06-10-2010 03:53 PM
global draw object getting changed in lower timeframe chart mmtrader Version 7 Beta General Questions & Bug Reports 3 04-20-2010 08:27 AM
request - global draw object from code ATI user Version 7 Beta General Questions & Bug Reports 1 01-11-2010 12:56 PM


All times are GMT -6. The time now is 11:48 AM.