Go Back   NinjaTrader Support Forum > NinjaTrader 7 > 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: 62
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 387 times in 375 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: 62
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 387 times in 375 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: 62
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 387 times in 375 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: 62
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 387 times in 375 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: 62
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 387 times in 375 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 Development 3 02-23-2011 02:17 AM
draw vertical line pulla General Development 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 07:56 PM.

Futures, foreign currency and options 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.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.