Could you help me with this plot??? - futures io
futures io futures trading



Could you help me with this plot???


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Could you help me with this plot???

(login for full post details)
  #1 (permalink)
cadiz
 
Experience: Beginner
Platform: NinjaTrader
Broker: interactive brokers
Trading: stocks
 
Posts: 4 since Nov 2009
Thanks: 2 given, 1 received

Hi, everyone!

I would like to plot when rsi crosses 40 line, but I'm failing in something and I don't know where is failing. Could you help me?

I paste:
 
Code
                            
public class _Alerts_MiRSI 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"MiRSI"));
            
Add(new Plot(Color.Orange"Avg"));

            
Add(new Line(System.Drawing.Color.DarkViolet20"Lower20"));
            
Add(new Line(System.Drawing.Color.DarkViolet80"Upper80"));
            
Add(new Line(System.Drawing.Color.Red60"Lower60"));
            
Add(new Line(System.Drawing.Color.Red40"Upper40"));
            
Add(new Line(System.Drawing.Color.Blue50"Upper50"));
            
            
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line"Alarma"));
            

            
avgUp                = new DataSeries(this);
            
avgDown                = new DataSeries(this);
            
down                = new DataSeries(this);
            
up                    = new DataSeries(this);

            
PriceTypeSupported    true;
        }

        
/// <summary>
        /// Calculates the indicator value(s) at the current index.
        /// </summary>
        
protected override void OnBarUpdate()
        {
            if (
CurrentBar == 0)
            {
                
down.Set(0);
                
up.Set(0);
                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(downPeriod)[0]);
                
avgUp.Set(SMA(upPeriod)[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 rs      avgUp[0] / (avgDown[0] == avgDown[0]);
            
double rsi      100 - (100 / (rs));
            
double rsiAvg = (2.0 / (Smooth)) * rsi + (- (2.0 / (Smooth))) * Avg[1];

            
Avg.Set(rsiAvg);
            
Value.Set(rsi);
            
            
Alarma.Set(rsi[1] < Upper40[1]&&rsi[0] > Upper40[0] ? 0);
        }

        
#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")]
        [
Category("Parameters")]
        public 
int Period
        
{
            
get { return period; }
            
set period Math.Max(2value); }
        }

        
/// <summary>
        /// </summary>
        
[Description("Number of bars for smoothing")]
        [
Category("Parameters")]
        public 
int Smooth
        
{
            
get { return smooth; }
            
set smooth Math.Max(1value); }
        }
        
        
            
            
        
        
        
#endregion
    
}
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    public 
partial class Indicator IndicatorBase
    
{
        private 
_Alerts_MiRSI[] cache_Alerts_MiRSI null;

        private static 
_Alerts_MiRSI check_Alerts_MiRSI = new _Alerts_MiRSI();

        
/// <summary>
        /// The MiRSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        
public _Alerts_MiRSI _Alerts_MiRSI(int periodint smooth)
        {
            return 
_Alerts_MiRSI(Inputperiodsmooth);
        }

        
/// <summary>
        /// The MiRSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        
public _Alerts_MiRSI _Alerts_MiRSI(Data.IDataSeries inputint periodint smooth)
        {
            
check_Alerts_MiRSI.Period period;
            
period check_Alerts_MiRSI.Period;
            
check_Alerts_MiRSI.Smooth smooth;
            
smooth check_Alerts_MiRSI.Smooth;

            if (
cache_Alerts_MiRSI != null)
                for (
int idx 0idx cache_Alerts_MiRSI.Lengthidx++)
                    if (
cache_Alerts_MiRSI[idx].Period == period && cache_Alerts_MiRSI[idx].Smooth == smooth && cache_Alerts_MiRSI[idx].EqualsInput(input))
                        return 
cache_Alerts_MiRSI[idx];

            
_Alerts_MiRSI indicator = new _Alerts_MiRSI();
            
indicator.BarsRequired BarsRequired;
            
indicator.CalculateOnBarClose CalculateOnBarClose;
            
indicator.Input input;
            
indicator.Period period;
            
indicator.Smooth smooth;
            
indicator.SetUp();

            
_Alerts_MiRSI[] tmp = new _Alerts_MiRSI[cache_Alerts_MiRSI == null cache_Alerts_MiRSI.Length 1];
            if (
cache_Alerts_MiRSI != null)
                
cache_Alerts_MiRSI.CopyTo(tmp0);
            
tmp[tmp.Length 1] = indicator;
            
cache_Alerts_MiRSI tmp;
            
Indicators.Add(indicator);

            return 
indicator;
        }

    }
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
    public 
partial class Column ColumnBase
    
{
        
/// <summary>
        /// The MiRSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        
[Gui.Design.WizardCondition("Indicator")]
        public 
Indicator._Alerts_MiRSI _Alerts_MiRSI(int periodint smooth)
        {
            return 
_indicator._Alerts_MiRSI(Inputperiodsmooth);
        }

        
/// <summary>
        /// The MiRSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        
public Indicator._Alerts_MiRSI _Alerts_MiRSI(Data.IDataSeries inputint periodint smooth)
        {
            return 
_indicator._Alerts_MiRSI(inputperiodsmooth);
        }

    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public 
partial class Strategy StrategyBase
    
{
        
/// <summary>
        /// The MiRSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        
[Gui.Design.WizardCondition("Indicator")]
        public 
Indicator._Alerts_MiRSI _Alerts_MiRSI(int periodint smooth)
        {
            return 
_indicator._Alerts_MiRSI(Inputperiodsmooth);
        }

        
/// <summary>
        /// The MiRSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        
public Indicator._Alerts_MiRSI _Alerts_MiRSI(Data.IDataSeries inputint periodint smooth)
        {
            if (
InInitialize && input == null)
                throw new 
ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return 
_indicator._Alerts_MiRSI(inputperiodsmooth);
        }

    }
}
#endregion 
Thank you in advance
Greetings from Spain, andaluz.

Attached Files
Register to download File Type: cs AlertsMiRSi.cs (8.1 KB, 7 views)
Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Second Entry Indicator (Looking for testers/feedback)
NinjaTrader
Regarding Multicharts strategy trigger
MultiCharts
Help Needed: TOS Options Chain IV & IMPL MOVE Calcul …
ThinkOrSwim
Work with historical tcks data on MUltichart NET PowerLa …
MultiCharts
Indicators for pair trading MES and M2K
Platforms and Indicators
 
 
(login for full post details)
  #3 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received


(1) You used Alarma.Set, but you have not defined any DataSeries for it. Actually Alarma[] only takes the values 0 or 1, so you would need to define a BoolSeries under properties:

public BoolSeries Alarma
{
get{return values[2];}
}

(2) Also you have not defined any DataSeries Upper40[]. If you add a new line, this does not create a dataseries, if you add a new plot, you would need to declare the dataseries under properties....

(3) There is no dataseries rsi[], but you have called this dataseries Default, so you need to use Default!

The code for line 102 should therefore read

Alarma.Set(Default[1] < 40 && Default[0] > 40);

which sets a Boolean value to Alarma....

Have not checked this, but you should be able to work it out...

Reply With Quote
The following user says Thank You to Fat Tails for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Could you help me with this plot???


Last Updated on May 30, 2010


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts