Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

buy sell arrow

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

    buy sell arrow

    hi
    i want buy arrow in rsi when grater than 70.
    also my alert sound work fine but arrow move forward when price change.
    how can i fix it ?

    please look below script.

    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class RsiAlert : Indicator
    {
    double rsi_m1;




    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "RsiAlert";
    Calculate = Calculate.OnPriceChange;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {

    AddDataSeries(null,BarsPeriodType.Minute,1);
    AddPlot(new Stroke(Brushes.SpringGreen, 2), PlotStyle.TriangleUp, "Buysignal");
    AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.TriangleDown, "SellSignal");





    }
    }

    protected override void OnBarUpdate()
    {



    if (CurrentBars[0] < 5|| CurrentBars[1] < 5 )

    return;


    if (BarsInProgress ==1) //multi time 1 min

    {

    rsi_m1 = RSI(14, 3)[0];

    if(rsi_m1 > 70)
    Alert("myAlert", Priority.High, "BUY SIGNAL",
    NinjaTrader.Core.Globals.InstallDir+@"\sounds\buys ell alert.wav", 1
    , Brushes.Black, Brushes.Yellow);



    Draw.ArrowUp(this, "tag1", true, 0, Low[0] - 4*TickSize, Brushes.Green);




    }





    //Add your custom indicator logic here.
    }
    }
    }

    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private RsiAlert[] cacheRsiAlert;
    public RsiAlert RsiAlert()
    {
    return RsiAlert(Input);
    }

    public RsiAlert RsiAlert(ISeries<double> input)
    {
    if (cacheRsiAlert != null)
    for (int idx = 0; idx < cacheRsiAlert.Length; idx++)
    if (cacheRsiAlert[idx] != null && cacheRsiAlert[idx].EqualsInput(input))
    return cacheRsiAlert[idx];
    return CacheIndicator<RsiAlert>(new RsiAlert(), input, ref cacheRsiAlert);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.RsiAlert RsiAlert()
    {
    return indicator.RsiAlert(Input);
    }

    public Indicators.RsiAlert RsiAlert(ISeries<double> input )
    {
    return indicator.RsiAlert(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.RsiAlert RsiAlert()
    {
    return indicator.RsiAlert(Input);
    }

    public Indicators.RsiAlert RsiAlert(ISeries<double> input )
    {
    return indicator.RsiAlert(input);
    }
    }
    }

    #endregion


    #2
    Hello f.saeidi,

    Thank you for your post.

    Your condition is checking if the RSI is greater than 70. As long as that condition is true, each call of OnBarUpdate() will result in the logic within the condition being executed. The Arrow will continue to be updated as long as the RSI is greater than 70. Are you saying that you want the arrow to only be drawn once when the RSI reaches a value greater than 70? In that case, you may need to change your condition to check when RSI crosses above 70 with CrossAbove():


    Please let us know if we may be of further assistance.

    Comment


      #3
      now i can get buy signal and arrow.
      but problem is when for first time rsi > 70 i can get arrow
      but for second time when rsi >70 previous arrow was clear and shift to right side.
      Last edited by f.saeidi; 04-02-2024, 02:39 PM.

      Comment


        #4
        in fact for example when 4 times rsi > 70 i must see 4 time buy arrow
        but i can see only 1 arrow and shift to right side.

        Comment


          #5
          Hello f.saeidi,

          Thank you for your reply.

          You are currently drawing the arrow with one tag called "tag1"
          Draw.ArrowUp(this, "tag1", true, 0, Low[0] - 4*TickSize, Brushes.Green);

          If you'd like multiple arrows to be drawn, you need to use a unique tag for each one. Otherwise, when using the same tag, the same object is simply updated/modified. You could append the CurrentBar index to create unique arrows:
          Draw.ArrowUp(this, "tag1" + CurrentBar.ToString(), true, 0, Low[0] - 4*TickSize, Brushes.Green);

          The Tag is described here as "A user defined unique id used to reference the draw object.

          For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time."Please let us know if we may be of further assistance.

          Comment


            #6
            Thnx for your notes.
            Can I add one window?
            For example when buy arrow active one window open and write instrument name with buy condition.

            Comment


              #7
              Originally posted by f.saeidi View Post
              Thnx for your notes.
              Can I add one window?
              For example when buy arrow active one window open and write instrument name with buy condition.
              To create a window that will open via NinjaScript, that would require you to script an AddOn window and initiate that AddOn window from your script when the desired conditions are met. This has been discussed in the thread here:


              Please let us know if we may be of further assistance.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              656 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              371 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              579 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X