Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Instead of BarBrushes how to I say BarOutline?
Collapse
X
-
This is more of a challenge here; I want to allow the user to be able to change the colors and even for myself without going into the code. I know it's done in the properties section. Can you please give me some direction on this part?
-
Comment
-
-
Hello trdninstyle,
Each variable/input should have unique name. Copy the code for each brush and change the name.
There are two indicators included with NinjaTrader you can use as learning examples.
Have a look at the code in the Volume profile indicator for the Volume down color, Volume netural color, and Volume up color on lines 70 through 72 and 311 through 342.
Have a look at the Volume zones indicator for the DownBarColor and UpBarColor on lines 59, 60, 196 through 206, and 223 through 233.Chelsea B.NinjaTrader Customer Service
Comment
-
Comment
-
Hello trdninstyle,
Yes, you can copy and paste. Just change the variable names and the Name property in the Display attribute.
Once the brush is created as an input, you can use this in the code where you want that color (in OnBarUpdate()).
You can assign this to the CandleOutlineBrush or BarBrush or BackgroundBrush, or whatever it is you want to color.Chelsea B.NinjaTrader Customer Service
Comment
-
I'm definitely making progress here. Please take a look at these pics. It looks as if everything should work now except when I change the colors nothing happens.
In the Volume example there is a little different wording,
Volume example; [Display(ResourceType = typeof(Custom.Resource), Name = "Opacity", Order = 0, GroupName = "NinjaScriptParameters")]
and I have; [Display(Name = "CandleOutlineDownColor", GroupName = "NinjaScriptParameters", Order = 0)]
Comment
-
Hello trdninstyle,
ResourceType = typeof(Custom.Resource) in the Display attribute is a property NinjaTrader uses for language translations. You don't have to include that, and you can just leave it out.
What properties are you assigning to these brush variables?
Are you assigning CandleOutlineBrushes[0] to this brush variable?
May we see the code where these brush variables are assigned to something?Chelsea B.NinjaTrader Customer Service
Comment
-
I copied / paste most of the code so you can discern where my error may be. Thank you.
namespace NinjaTrader.NinjaScript.Indicators.Trdnstyle
{
public class TwoBarRevUpDown : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Paints a Two Bar Reversal Up and Down Yellow White";
Name = "2BarRevUpDown";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
CandleOutlineDownBrush = Brushes.White;
CandleOutlineUpBrush = Brushes.Yellow;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
// brushColor[i]
}
}
protected override void OnBarUpdate()
{
if(CurrentBar<2) return;
if(Close[1] > Open[1] && High[0] > High[1] && Close[0] < Close[1] && BarBrushes[2] != Brushes.Yellow)
{
CandleOutlineBrushes[0] = Brushes.Yellow;
CandleOutlineBrushes[1] = Brushes.Yellow;
}
else
if(Close[1] < Open[1] && Low[0] < Low[1] && Close[0] > Close[1] && BarBrushes[2] != Brushes.White)
{
CandleOutlineBrushes[0] = Brushes.White;
CandleOutlineBrushes[1] = Brushes.White;
}
}
I copied / paste most of the code so you can discern where my error may be. Thank you.
region Properties
// Create our user definable color input
[XmlIgnore()]
[Display(Name = "CandleOutlineDownColor", GroupName = "NinjaScriptParameters", Order = 0)]
public Brush CandleOutlineDownBrush { get; set;}
// Serialize our Color object Hardcoded Brushes?
[Browsable(false)]
public string CandleOutlineDownBrushSerialize
{
get { return Serialize.BrushToString(CandleOutlineDownBrush); }
set { CandleOutlineDownBrush = Serialize.StringToBrush(value); }
}
// Create our user definable color input
[XmlIgnore()]
[Display(Name = "CandleOutlinUpColor", GroupName = "NinjaScriptParameters", Order = 0)]
public Brush CandleOutlineUpBrush { get; set;}
// Serialize our Color object Hardcoded Brushes?
[Browsable(false)]
public string CandleOutlineUpBrushSerialize
{
get { return Serialize.BrushToString(CandleOutlineUpBrush); }
set { CandleOutlineUpBrush = Serialize.StringToBrush(value); }
}
#endregion
}​
Comment
-
Hello trdninstyle,
To clarify an assignment is when you are setting a value to something.
MyVariable = MyOtherVariable;
This is an assignment.
if (MyVariable == MyOtherVariable)
{
}
This a comparison in an 'if' branching command.
MyMethodCall();
This is a method call.
Lets think it through.
What are you trying to color in your script?
On what line are you setting that value?Chelsea B.NinjaTrader Customer Service
Comment
-
What are you trying to color in your script? CandleOutline
On what line are you setting that value? Line 54, 55, under the description column
I'm missing it right now. I have to clarify an assignment, so it carries it out. It needs to know where the value is.
Comment
-
CandleOutlineBrushes[0] = Brushes.White;
CandleOutlineBrushes[1] = Brushes.White;
CandleOutlineBrushes[0] = Brushes.Yellow;
CandleOutlineBrushes[1] = Brushes.Yellow;
{
get { return Serialize.BrushToString(CandleOutlineDownBrush); } < do I place [0] in there? and [1] for the previous bar?
set { CandleOutlineDownBrush = Serialize.StringToBrush(value); }
}
Comment
-
Hello trdninstyle,
Currently, you are assigning CandleOutlineBrushes[0] to Brushes.White.
Assign CandleOutlineBrushes[0] the value of your variable instead of Brushes.White.
CandleOutlineBrushes[0] = CandleOutlineDownBrush;
Now the color of the outline will have the color that was assigned to the input variable.
Do this where where you want to use that color.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
4 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 02:00 AM |
Comment