NexusFi: Find Your Edge


Home Menu

 





ADDING OPACITY CONTROL AS A PARAMETER FOR AN INDICATOR


Discussion in NinjaTrader

Updated
    1. trending_up 938 views
    2. thumb_up 3 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

ADDING OPACITY CONTROL AS A PARAMETER FOR AN INDICATOR

  #1 (permalink)
 
Bullywig's Avatar
 Bullywig 
Chicago
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: FDAX, NQ, HG, SI, CL
Posts: 68 since Oct 2015
Thanks Given: 42
Thanks Received: 22

I created a simple indicator that backpaints on the chart; I was able to add opacity control to it, but need to know how to add the parameter so it will show up when the indicator is open, and you can then adjust the opacity on a scale from 0-100? Can someone point me in the right direction. I am beginning to learn how to code, and could use some help. Thanks in advance.

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Strategy stop orders partially filled
EasyLanguage Programming
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

At the Class level... I.e., where you add global variables, add an int for you opacity like so...

 
Code
	public class NameOfIndicator: Indicator
	{
             private int myOpacity = 50;
	........


Here, I'm adding an arbitrary rectangle, starting 5 bars ago, to the current bar, with a height of the CURRENT bars range. This would probably be somewhere in your OnBarUpdate() block. Note I've added the opacity variable we created into the Draw.Rectangle() method.

 
Code
Draw.Rectangle(this, "tag1", false, 5, Low[0], 0, High[0], Brushes.PaleGreen, Brushes.PaleGreen, myOpacity );

Finally, to turn this variable into a user input, in the parameter section below the OnBarUpdate(), we add our UserInput defintion, like so:
 
Code
[Range(0, int.MaxValue)]
[Display(ResourceType = typeof(Custom.Resource), Name = "Box Opacity(0-99)", Description = "", GroupName = "Parameters", Order = 1)]
public int MyOpacity 
{	
            get { return myOpacity ; }
            set { myOpacity = value; }
}
Note above, you can add a Name of whatever you want, and that will be what the user input sees(here, the user we see Box Opacity(0-99) in the user input). Note the different capitalizations of the variable name, "myOpacity."


Also of note... if you ever struggle to create these things from scratch, or struggle to find these things in the documentation... you can always create a dummy indicator, using the builder tool, create the type of user input you need... and just copy the created code into the indicator you are working on.

Reply With Quote
Thanked by:




Last Updated on March 31, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts