NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript File Sharing > NinjaScript File Sharing Discussion

NinjaScript File Sharing Discussion Discussion for shared NinjaScript files.

Reply
 
Thread Tools Display Modes
Old 12-18-2007, 09:35 PM   #1
jeremymgp
Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
Default Color Stochastic/2-line Indicator

Hello,

Does anyone have a Color Stochastic, any colored 2-line indicator, or a tutorial for coloring indicators with more than one line? Color's a huge help for determining "has that indicator really turned?" and I'm going bananas trying to convert the Sample color SMA template. Thanks for your help,

Cheers,
Jeremy
jeremymgp is offline  
Reply With Quote
Old 12-19-2007, 12:14 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Check out this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3227

There is also a similar tutorial here: http://www.ninjatrader-support.com/H...tml?Overview25
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-19-2007, 07:29 AM   #3
jeremymgp
Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi,

Thanks for the tutorials, I've tried to hash the two together & set up my 3 Plot lines for the rising/neutral/falling D-line but the indicator is full of errors.

In lines like
"DRisingPlot.Set(1, Stochastics(Period)[1]);"
I've changed it to
"DRisingPlot.Set(1, Stochastics(K, D, Smooth)[1]);"
but this is a guess & I only need the D-line colored.

Quote:
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "DRising"));
Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "DNeutral"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DFalling"));
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "KLine"));
Add(new Line(Color.FromKnownColor(KnownColor.DarkOrchid), 80, "Eightyline"));
Add(new Line(Color.FromKnownColor(KnownColor.DarkOrchid), 20, "Twentyline"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}

protected override void OnBarUpdate()
{
DRising.Set(Close[0]);
DNeutral.Set(Close[0]);
DFalling.Set(Close[0]);
KLine.Set(Close[0]);

if (CurrentBar < 1)
return;

if (Rising(Stochastics(K, D, Smooth)))
{
DRisingPlot.Set(1, Stochastics(K, D, Smooth)[1]);
DRisingPlot.Set(Stochastics(K, D, Smooth)[0]);
}

else if (Falling(Stochastics(K, D, Smooth)))
{
DFallingPlot.Set(1, Stochastics(K, D, Smooth)[1]);
DFallingPlot.Set(Stochastics(K, D, Smooth)[0]);
}

else
{
DNeutralPlot.Set(1, Stochastics(K, D, Smooth)[1]);
DNeutralPlot.Set(Stochastics(K, D, Smooth)[0]);
}


}
This is all over the place but I'm learning till I get this, any pointers much appreciated,

Thanks,
Jeremy
jeremymgp is offline  
Reply With Quote
Old 12-20-2007, 12:29 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Did you add the plots into the Properties? Check out the Properties section in the reference sample. You will need those.
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-20-2007, 06:34 AM   #5
jeremymgp
Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Josh, I entered the plots into the Indicator wizard, but apart from that the only "Properties" section I can find is the large "Properties" section at the very bottom of the code which is by default hidden from the user. As I understand it the samples make no reference to editing this area directly. My misunderstanding, thanks for your patience,

Jeremy
jeremymgp is offline  
Reply With Quote
Old 12-20-2007, 02:10 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You will need to expand that big Properties section. If you don't mind you could post up the current rendition of your code. After I see what you have right now I can provide you with some pointers to get you going. Cheers.
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-29-2007, 08:19 AM   #7
jeremymgp
Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Josh,

Thanks for the help, good news is I've finally managed to make a smoothed StochRSI and plot it in color. Before I was looking at the entire indicator code, but then discovered the [+] buttons at the side of the code to popup the Properties section only, so I've made some progress.

Only thing now is in my color version the smooth line is not plotted, it's the StochRSI line that is both plotted and colored.

I'd like the smooth line to be plotted and colored, and StochRSI line plotted only.

Here's my code:

Quote:
namespace NinjaTrader.Indicator
{
[Description("Sample SMA plotted with three colors.")]
[Gui.Design.DisplayName("StochRSI_SmoothedColor")]
public class StochRSI_SmoothedColor : Indicator
{
#region Variables
private int period = 14;
private int smooth = 4;
#endregion

protected override void Initialize()
{
Add(new Plot(Color.Green, "StochRSI"));
Add(new Plot(Color.LimeGreen, PlotStyle.Line, "Rising"));
Add(new Plot(Color.Red, PlotStyle.Line, "Falling"));
Add(new Plot(Color.Yellow, PlotStyle.Line, "Neutral"));

CalculateOnBarClose = true;
Overlay = false;
}

protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;

if (Rising(StochRSI_Smoothed(Period, Smooth)))
{
RisingPlot.Set(1, StochRSI_Smoothed(Period, Smooth)[1]);

RisingPlot.Set(StochRSI_Smoothed(Period, Smooth)[0]);
}

else if (Falling(StochRSI_Smoothed(Period, Smooth)))
{
FallingPlot.Set(1, StochRSI_Smoothed(Period, Smooth)[1]);

FallingPlot.Set(StochRSI_Smoothed(Period, Smooth)[0]);
}

else
{
NeutralPlot.Set(1, StochRSI_Smoothed(Period, Smooth)[1]);

NeutralPlot.Set(StochRSI_Smoothed(Period, Smooth)[0]);
}
}

#region Properties

[Browsable(false)]
[XmlIgnore()]
public DataSeries RisingPlot
{
get { return Values[1]; }
}

[Browsable(false)]
[XmlIgnore()]
public DataSeries FallingPlot
{
get { return Values[2]; }
}

[Browsable(false)]
[XmlIgnore()]
public DataSeries NeutralPlot
{
get { return Values[3]; }
}

[Description("Numbers of bars used for calculations")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}

[Description("Smoothing period for SMA")]
[Category("Parameters")]
public int Smooth
{
get { return smooth; }
set { smooth = Math.Max(1, value); }
}
#endregion
}
}
Many thanks for your help and Happy New Year ,

Kind Regards,
Jeremy
jeremymgp is offline  
Reply With Quote
Old 12-29-2007, 12:14 PM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi jeremymgp,

I am unfamiliar with the implementation of StochRSI since it is probably a custom indicator you have.

When you do the .Set stuff you want it done on the plot you want. So for instance (I am just guessing what it is for your indicator), if you wanted to plot the smooth line you might do something like this:
Code:
RisingPlot.Set(StochRSI_Smoothed(Period, Smooth).Smooth[0])
I am assuming to access the smooth line you use .Smooth for your indicator.
Now to just simply plot StochR_Smoothed you need to add another Values set in the Properties.
Code:
[Browsable(false)] 
[XmlIgnore()]
public DataSeries StochRSmooth
{
    get { return Values[0]; }
}
Then now in your OnBarUpdate() you want to do:
Code:
StochRSmooth.Set(StochRSI_Smoothed(Period, Smooth)[0]);
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-04-2008, 09:05 AM   #9
jeremymgp
Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
Default

Yippee, looks like I've done it. Only weird thing is when I save the indicator, copy it into a zip file, then try to import the zipped indicator, I can't get the indicator to show in the:
Control Center > Tools > Edit NinjaScript > Indicator box.

However if I right click a chart and click Indicators, I can select the indicator fine.

Just don't want to distribute this if the zip file isn't 100% OK.

Thanks,
Jeremy
jeremymgp is offline  
Reply With Quote
Old 01-04-2008, 09:15 AM   #10
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

To distribute...

http://www.ninjatrader-support.com/H...6/Export1.html
NinjaTrader_Ray is offline  
Reply With Quote
Old 01-05-2008, 06:10 AM   #11
jeremymgp
Member
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 times in 0 posts
Default

Hello everyone,

Please find attached a color Stochastics indicator, it seems several people have shown interest in this and it also serves as a handy template for anyone wanting to color code indicators with more than one plot.

A huge thanks to Ray and Josh for their prompt and accurate response to my questions, hope this helps and good luck trading everyone,

Kind Regards,
Jeremy
Attached Files
File Type: zip Stochastics_Color.zip (10.3 KB, 300 views)
jeremymgp is offline  
Reply With Quote
Old 01-05-2008, 12:27 PM   #12
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Thanks for the contribution jeremymgp. We appreciate it.
NinjaTrader_Josh 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
Automatic Trend Line Indicator Greg1 Charting 6 07-23-2009 07:48 AM
Stochastic Indicator PorkChop Indicator Development 4 11-07-2007 06:59 PM
Indicator line goes to zero when CalculateOnBarClose set to True ThePatientOne Indicator Development 1 08-30-2007 11:42 AM
Line "names" in Indicator Box change to "Line" after modification higler Charting 3 05-02-2007 06:05 AM


All times are GMT -6. The time now is 12:10 AM.