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

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-24-2012, 03:13 PM   #1
Randwulf
Member
 
Join Date: Aug 2008
Posts: 50
Thanks: 3
Thanked 1 time in 1 post
Question Shorter vertical line with DrawLine

Go ahead & smile then, show me the error of my ways...

I'm trying to draw a short vertical line from a strategy using:

DrawLine("Line" + CurrentBar, false, 0, High[0] + 5*TickSize, 0, Low[0] - 5*TickSize, Color.Cyan, DashStyle.Dot, 2)

If I set the bool to "true" it shows the vertical lines but, they are way too long.
If I then hold the Ctrl key and move the chart up and down, the lines stay put (As expected since I set autoscale to "true"
However, setting autoscale to false causes the lines to disappear.... ?

Thx in advance
Randwulf is offline  
Reply With Quote
Old 04-24-2012, 03:27 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 380 times in 370 posts
Default

Randwulf,

I would suggest changing the size of

High[0] + 5*TickSize

and

Low[0] - 5*TickSize

You have your "bars ago" settings both to 0 so it should be a vertical line. In this case, the Low and High code above sets the lengths of the line. Right now you would have High - Low + 10 ticks, so if you reduce the number of ticks it should make a smaller line.

As far as your other issue, I am unable to replicate currently. Do you possibly have a simple toy strategy that does this I may test?
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-24-2012, 03:52 PM   #3
Randwulf
Member
 
Join Date: Aug 2008
Posts: 50
Thanks: 3
Thanked 1 time in 1 post
Default

Thx 4 the reply AdamP,

I don't understand how I would have High - Low + 10 Ticks... ?
I read that as drawing a line from "0" on the X axis & High + 5 Ticks on the Y axis
to "0" on the X axis & Low - 5 Ticks on the Y axis.
Is this incorrect ?

protected override void OnBarUpdate()
{
// Condition set 1
if (High[0] > KeltnerChannel(3.5, 50).Midline[0]
&& Low[0] < KeltnerChannel(3.5, 50).Midline[0])
{
DrawLine("My line" + CurrentBar, 0, High[0] + 5 * TickSize, 0, Low[0] + -5 * TickSize, Color.White);
}
}
Randwulf is offline  
Reply With Quote
Old 04-24-2012, 03:59 PM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 380 times in 370 posts
Default

Randwulf,

The length of the line would be the top point : High[0] + 5*TickSize

Minus the low point, which is : Low[0] - 5*TickSize

So the length would be : ( High[0] + 5*TickSize ) - ( Low[0] - 5*TickSize )
which is equal to : High[0] + 5*TickSize - Low[0] + 5*TickSize
which finally is : High[0] - Low[0] + 10*TickSize

This only works because you have a vertical line. It may be you have this number set too high, which is why the line looks bigger than you expect.

Are you trying to draw this indicator between the two parts of the keltner channel? What is the purpose of this line?
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-24-2012, 04:08 PM   #5
Randwulf
Member
 
Join Date: Aug 2008
Posts: 50
Thanks: 3
Thanked 1 time in 1 post
Default

Thx again AdamP,

I was just wanting a line to accentuate the straddle bar but, running from
KeltnerChannel(3.5, 50).Upper[0] to KeltnerChannel(3.5, 50).Lower[0]
would certainly work....

Just tried substituting those points instead but, lines still not appearing..
Randwulf is offline  
Reply With Quote
Old 04-25-2012, 07:05 AM   #6
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 380 times in 370 posts
Default

Randwulf,

Could you possibly post your code for review?
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-25-2012, 11:47 AM   #7
Randwulf
Member
 
Join Date: Aug 2008
Posts: 50
Thanks: 3
Thanked 1 time in 1 post
Default

AdamP,

I created a test strategy with the wizard using only the 1 condition and 1 output..
The code below is the only code it created when I "View Code".

protected override void OnBarUpdate()
{
// Condition set 1
if (High[0] > KeltnerChannel(3.5, 50).Midline[0]
&& Low[0] < KeltnerChannel(3.5, 50).Midline[0])
{
DrawLine("My line" + CurrentBar, false, 0, KeltnerChannel(3.5, 50).Lower[0],
0, KeltnerChannel(3.5, 50).Upper[0], Color.White, DashStyle.Solid, 2);
}
}
Randwulf is offline  
Reply With Quote
Old 04-25-2012, 11:57 AM   #8
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 380 times in 370 posts
Default

Randwulf,

I am currently unable to replicate the disappearing lines. I would suggest upgrading your ninjatrader to the latest version perhaps and trying again. If you run this on a brand new chart without any extra indicators / strategies, does it still have the same behavior?

http://www.ninjatrader.com/download-registration.php
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-25-2012, 02:15 PM   #9
Randwulf
Member
 
Join Date: Aug 2008
Posts: 50
Thanks: 3
Thanked 1 time in 1 post
Default

AdamP,

If you were able to create a vertical line from top to bottom of a channel then,
it's obviously something on my end.
I will try fresh and report back.
Thank you again for the support & great product.
Randwulf is offline  
Reply With Quote
Old 04-25-2012, 02:16 PM   #10
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 380 times in 370 posts
Default

Randwulf,

Thanks for your kind words.

If you happen to come across some replication steps, please let me know.
NinjaTrader_AdamP 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
Vertical Line ryebank General Programming 3 02-23-2011 02:17 AM
draw vertical line pulla General Programming 14 01-14-2011 10:57 AM
DrawLine line disappearing TAJTrades Indicator Development 3 10-01-2010 09:46 AM
Draw vertical line hegh2000 Indicator Development 4 03-11-2009 07:03 AM
Vertical line across all panels snaphook Suggestions And Feedback 1 12-08-2008 09:30 AM


All times are GMT -6. The time now is 05:27 PM.

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.