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!
See more
See less

Partner 728x90

Collapse

Programming help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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);
    }

    #2
    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
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for that Betrand, here is the code

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

      Code CS1501, Lin 57, Col 24

      Comment


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

        Code:
        [COLOR=#008000]// Calculate RSI value 
        [/COLOR][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] value = RSI([/SIZE][SIZE=2][COLOR=#800080]14, 3[/COLOR][/SIZE][SIZE=2])[[/SIZE][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][SIZE=2]];[/SIZE]
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        388 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        29 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        22 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        7 views
        0 likes
        Last Post funk10101  
        Working...
        X