Thanks.
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
RSI Alert
Collapse
X
-
RSI Alert
Hi, I just want a sound alert once the lower or upper limits have been crossed. LineAlert would do the job, as I could just draw the line manually, unfortunately, it seems to only work on price bars, and not the RSI upper and lower lines.
Thanks.Tags: None
-
Hello bougie,
I'm not aware of an existing indicator that does this, however it would be possible with custom programming.
NinjaTrader is based on the modern C# programming language which allows advanced charting that is extensible in that you can create custom indicators using NinjaScript.
* Click here for information on programming in NinjaScript
You would want to use the Alert() method based upon the condition that you would like.
http://www.ninjatrader.com/support/h...html?alert.htm
For Example:
Code:if(CrossAbove(High[0], RSI(20, 3),1) || CrossBelow(Low[0], RSI(20, 3),1)) Alert("myAlert", NinjaTrader.Cbi.Priority.High, "RSI Alert", "Alert1.wav", 10, Color.Black, Color.Yellow);
JCNinjaTrader Customer Service
-
Hello bougie,
Thank you for your response.
You would not paste this into the RSI but would follow the instructions below to create a new indicator with the code that JC provided.- Go to Tools > New NinjaScript > Indicator
- Next
- Name the indicator and select Generate
- Then paste the code JC created into the OnBarUpdate() method
- Then press F5 compile
Once complete you code should look like the following:
Code:#region Variables #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Overlay = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if(CrossAbove(High[0], RSI(20, 3),1) || CrossBelow(Low[0], RSI(20, 3),1)) Alert("myAlert", NinjaTrader.Cbi.Priority.High, "RSI Alert", "Alert1.wav", 10, Color.Black, Color.Yellow); } #region Properties #endregion
A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm
I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm
We also have some Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
Click here to see our NinjaScript Reference Samples
Click here to see our NinjaScript Tips
If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
Click here for a list of certified NinjaScript Consultants
Please let me know if I may be of further assistance.
Comment
-
Try opening the @RSI.cs file, deleting everything in it (so it's completely blank), then paste the below code into it:
PHP Code://
// Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//
#region Using declarations
using System;
using System.ComponentModel;
using System.Drawing;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// The RSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
/// </summary>
[Description("The RSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.")]
public class RSI : Indicator
{
#region Variables
private DataSeries avgUp;
private DataSeries avgDown;
private DataSeries down;
private int period = 14;
private int smooth = 3;
private DataSeries up;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Green, "RSI"));
Add(new Plot(Color.Orange, "Avg"));
Add(new Line(System.Drawing.Color.DarkViolet, 30, "Lower"));
Add(new Line(System.Drawing.Color.YellowGreen, 70, "Upper"));
avgUp = new DataSeries(this);
avgDown = new DataSeries(this);
down = new DataSeries(this);
up = new DataSeries(this);
}
/// <summary>
/// Calculates the indicator value(s) at the current index.
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
down.Set(0);
up.Set(0);
if (Period < 3)
Avg.Set(50);
return;
}
down.Set(Math.Max(Input[1] - Input[0], 0));
up.Set(Math.Max(Input[0] - Input[1], 0));
if ((CurrentBar + 1) < Period)
{
if ((CurrentBar + 1) == (Period - 1))
Avg.Set(50);
return;
}
if ((CurrentBar + 1) == Period)
{
// First averages
avgDown.Set(SMA(down, Period)[0]);
avgUp.Set(SMA(up, Period)[0]);
}
else
{
// Rest of averages are smoothed
avgDown.Set((avgDown[1] * (Period - 1) + down[0]) / Period);
avgUp.Set((avgUp[1] * (Period - 1) + up[0]) / Period);
}
double rsi = avgDown[0] == 0 ? 100 : 100 - 100 / (1 + avgUp[0] / avgDown[0]);
double rsiAvg = (2.0 / (1 + Smooth)) * rsi + (1 - (2.0 / (1 + Smooth))) * Avg[1];
Avg.Set(rsiAvg);
Value.Set(rsi);
}
#region Properties
/// <summary>
/// </summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries Avg
{
get { return Values[1]; }
}
/// <summary>
/// </summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries Default
{
get { return Values[0]; }
}
/// <summary>
/// </summary>
[Description("Numbers of bars used for calculations")]
[GridCategory("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
/// <summary>
/// </summary>
[Description("Number of bars for smoothing")]
[GridCategory("Parameters")]
public int Smooth
{
get { return smooth; }
set { smooth = Math.Max(1, value); }
}
#endregion
}
}
Comment
-
Originally posted by bougie View PostI've tried pasting it, getting many errors, maybe not pasting in right section of code?
[ATTACH]23554[/ATTACH]
Comment
-
Hello boldhead,
Welcome to the NinjaTrader support forums.
Assuming that you are not doing the same steps which the original poster had you should be able to just copy the syntax from post #2 into a new indicator or strategy to make an alert from the RSI. The other content in this thread is related to the users specific situation and will not likely apply toward your situation.
You can learn more about this syntax from the help guide:
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello boldhead,
The information in this post is for NinjaScript, so this assumes that you are developing a strategy or indicator already. Once you have created a strategy or indicator, you could utilize the syntax from post #2 to form an alert. The syntax is complete in that post, you would just need to make your script look the same to start working with alerts.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Haiasi, 04-25-2024, 06:53 PM
|
5 responses
75 views
0 likes
|
Last Post
by alancurry
Today, 07:00 PM
|
||
Started by ZeroKuhl, Today, 04:31 PM
|
0 responses
15 views
0 likes
|
Last Post
by ZeroKuhl
Today, 04:31 PM
|
||
Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
|
54 responses
5,337 views
0 likes
|
Last Post
by Gaterz
Today, 04:29 PM
|
||
Started by ETFVoyageur, 05-07-2024, 07:05 PM
|
11 responses
76 views
0 likes
|
Last Post
by -=Edge=-
Today, 04:27 PM
|
||
Started by _Zero_, 04-10-2020, 03:21 PM
|
145 responses
7,902 views
6 likes
|
Last Post
by johng2
Today, 04:19 PM
|
Comment