Adding Horizontal Line to indicator /Ninjascript - futures io
futures io futures trading



Adding Horizontal Line to indicator /Ninjascript


Discussion in NinjaTrader

Updated by jgivler
    1. trending_up 337 views
    2. thumb_up 6 thanks given
    3. group 3 followers
    1. forum 3 replies
    2. attach_file 1 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)

 
Search this Thread
 

Adding Horizontal Line to indicator /Ninjascript

(login for full post details)
  #1 (permalink)
Las Vegas, NV
 
 
Posts: 2 since Feb 2019
Thanks: 0 given, 1 received

I am trying to customize the ninjascript code on a stock RVI indicator in NT8. All I want to do is add 3 more horizontal lines. So that I have the 70, 60, 40, 30 levels marked. The stock RVI indicator has one horizontal line, called the signal line, that functions as one of them. How can I add in 3 more horizontal lines, with specific width, dash style and color? I've tried manually adding code in and nothing happens.

Secondly, although I have created a copy of the original code and saved as a new indicator, when I go to the chart to add the indicator, it is not an option in the list. Do I have to do something after writing a new indicator code to make it be added to the indicator list?

Thanks!

Reply With Quote

Can you help answer these questions
from other members on futures io?
Capping Size in Tradestation
TradeStation
QDEL
Stocks and ETFs
Is TradeStation for me?
TradeStation
Macros for flatten and reverse
TradeStation
FX Futures have been nagging me for a while
Currencies
 
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Calgary, Alberta
 
Experience: Advanced
Platform: NinjaTrader 8
Broker: Kinetick
Trading: ES
 
JonnyBoy's Avatar
 
Posts: 1,448 since Apr 2012
Thanks: 601 given, 3,202 received


jgivler View Post
I am trying to customize the ninjascript code on a stock RVI indicator in NT8. All I want to do is add 3 more horizontal lines. So that I have the 70, 60, 40, 30 levels marked. The stock RVI indicator has one horizontal line, called the signal line, that functions as one of them. How can I add in 3 more horizontal lines, with specific width, dash style and color? I've tried manually adding code in and nothing happens.

Secondly, although I have created a copy of the original code and saved as a new indicator, when I go to the chart to add the indicator, it is not an option in the list. Do I have to do something after writing a new indicator code to make it be added to the indicator list?

Thanks!

The absolute easiest way to do this is is to add the lines you want to the panel you want via the Constant lines indicator that comes stock with NT8. Else, you can just copy the RVI indicator and add the code to give you the lines.

ES 09-20 (2000 Tick) 2020_09_09 (4_37_03 PM)

--------------------------------------------------------
- Trade what you see. Invest in what you believe -
--------------------------------------------------------
Reply With Quote
The following 2 users say Thank You to JonnyBoy for this post:
 
(login for full post details)
  #3 (permalink)
Market Wizard
Quebec
 
Experience: Intermediate
Platform: NinjaTrader wt Rancho Dinero's profiling tools
Broker: AMP/CQG
Trading: ES, NQ, YM
 
trendisyourfriend's Avatar
 
Posts: 3,904 since Oct 2009
Thanks: 3,536 given, 4,989 received


Add the lines which are in Bold and compile your script or just press F5 to compile then you should see it in your list of indicators. Basically, each time you add a line via the AddLine command, Ninja adds it in a special collection names Lines[] which holds all the lines created in the script. Since there was already one line to represent the 50 level and the two other lines then the Lines[] collection contains 3 items.

You can modify the properties of a line by using this collection like this:

Lines[1].Width = 2;
Lines[1].DashStyleHelper = DashStyleHelper.Dash;

You can learn a bit more by visiting this page:
https://ninjatrader.com/support/helpGuides/nt8/lines.htm

 
Code
		protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description					= NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionRVI;
				Name						= "myNewRVI";
				IsSuspendedWhileInactive	= true;
				Period						= 14;
				IsOverlay					= false;

				AddPlot(Brushes.Goldenrod,		NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameRVI);
				AddLine(Brushes.DarkGray,	50,	NinjaTrader.Custom.Resource.RVISignalLine);
				AddLine(Brushes.Yellow,	30,	"above50");
				AddLine(Brushes.Cyan,	70,	"below50");
			}

			else if (State == State.Configure)
			{
				savedCurrentBar	= -1;
				dnAvgH			= dnAvgL = upAvgH = upAvgL = lastDnAvgH
								= lastDnAvgL = lastUpAvgH = lastUpAvgL = 0;
				Lines[1].Width = 2;
				Lines[1].DashStyleHelper = DashStyleHelper.Dash;
				Lines[2].Width = 2;
				Lines[2].DashStyleHelper = DashStyleHelper.Dash;
		}

Reply With Quote
The following 2 users say Thank You to trendisyourfriend for this post:
 
(login for full post details)
  #4 (permalink)
Las Vegas, NV
 
 
Posts: 2 since Feb 2019
Thanks: 0 given, 1 received

Thank you guys so much! I learned from both of you. Really appreciate that you took the time to help!!!

Best,
J

Reply With Quote
The following 2 users say Thank You to jgivler for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Adding Horizontal Line to indicator /Ninjascript


September 10, 2020


Upcoming Webinars and Events
     



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