NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 12-12-2008, 11:26 PM   #1
kipper
Junior Member
 
Join Date: Jul 2008
Posts: 17
Thanks: 0
Thanked 0 times in 0 posts
Smile Programming help

Hope someone can help, I am just starting out in learning this.
I am trying to produce a Green Dot or arrow etc when the value of a 14 period RSI is above 55 and a red dot etc when moves below 45, see code I started but it comes up with an error.


[Description("Enter the description of your new custom indicator here")]
publicclass AshRSI : Indicator
{
#region Variables
// Wizard generated variables
privateint period = 14; // Default setting for Period
// User defined variables (add any user defined variables below)
#endregion
///<summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
///</summary>
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.SpringGreen), PlotStyle.Dot, "Above"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "Below"));
Add(new Line(Color.FromKnownColor(KnownColor.Lime), 55, "A"));
Add(new Line(Color.FromKnownColor(KnownColor.Red), 45, "B"));
Period = 14;
// Set line drawing thresholds which give the visual effect of
// multi colored lines based on indicator values
Plots[0].Min = 45;
Plots[1].Max = 45;
Plots[1].Min = 55;
Plots[2].Min = 55;
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{// Do not calculate if we don't have enough bars
if (CurrentBar < Period) return;

// Calculate RSI value
double value = RSI(14)[0];

// Use an if branch to set an indicator panel back ground color and bar color
if (value > 55)
{
BackColor = Color.PaleGreen;
BarColor = Color.Yellow;
}
if (value < 45)
{
BackColor = Color.Pink;
BarColor = Color.Yellow;
}

// Set the plot value
Above.Set(55);
Below.Set(45);
}
kipper is offline  
Reply With Quote
Old 12-13-2008, 04:26 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi kipper,

What is the error you are getting with your code?

Here is a link to our indicator tutorials - http://www.ninjatrader-support.com/H...verview18.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 12-13-2008, 01:57 PM   #3
kipper
Junior Member
 
Join Date: Jul 2008
Posts: 17
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks for that Betrand, here is the code

No overload for method 'RSI' takes '1' arguments

Code CS1501, Lin 57, Col 24
kipper is offline  
Reply With Quote
Old 12-14-2008, 12:12 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi kipper,
RSI also needs a second input, a smoothing factor - so please try

Code:
// Calculate RSI value 
double value = RSI(14, 3)[0];
NinjaTrader_Bertrand 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
Programming Conditions wcmaria Indicator Development 1 12-05-2008 09:52 AM
Programming Error octrout Strategy Development 1 10-22-2008 11:55 AM
Programming question sauer11155 General Programming 3 09-02-2008 11:34 AM
Stochastic Programming tomydispik General Programming 3 08-08-2008 09:39 AM
Programming references bobajob78 General Programming 1 02-11-2008 03:32 PM


All times are GMT -6. The time now is 07:33 PM.