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

Green Day Update

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

    Green Day Update

    Hello Community,

    I am trying to add a piece of the code to only look for a long arrows or a short arrow. Right now it looks in both directions. When I am looking for longs I would like to "click" a condition box to only show up arrows and the opposite for short.

    Also is there a way to change the name of the indy? I did it inside of the code but when it was developed it is still saying GreenDay. I would like the new name to say Perfect Rotation Candle
    Attached Files

    #2
    Hello wealthcig,

    Use a public bool with the [NinjaScriptProperty] attribute to make an input for the user to select.
    [NinjaScriptProperty]
    public bool ShowLongs
    { get; set; }

    In the conditions that draw the arrow up, add a condition that bool is true.
    if (ShowLongs /* && other conditions here */)
    {
    //Draw.ArrowUp() call here;
    }


    I would recommend making a copy of a script in the NinjaScript Editor, and using a new unique name.
    Open the script in the NinjaScript Editor -> Right-click within the code area -> Save as

    Then if you wish, re-export it using that new name.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I tried to input but had trouble. I am not sure where I should put it in the code. I put it in a different place but came up with errors. Where in the code should it go?

      Comment


        #4
        Hello wealthcig,

        Thank you for your note.

        I've made a simple example demonstrating where to put bool inputs like my colleague Chelsea described that should get you going in the correct direction.

        Please let us know if we may be of further assistance to you.
        Attached Files
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thanks, Kate. I have tried to input. parameters but this is what I have come up with. Attachment below. Not sure what it means Click image for larger version

Name:	screenshot.4.jpg
Views:	211
Size:	175.5 KB
ID:	1192747

          Comment


            #6
            Hello wealthcig,

            Thank you for your reply.

            I don't see where in your script you've added the #region Properties like in the example, can you supply a screenshot of where in the script you have added these? I've highlighted that portion of the example script below:

            Code:
            namespace NinjaTrader.NinjaScript.Indicators
            {
            public class ShowLongsBoolInputExample : Indicator
            {
            protected override void OnStateChange()
            {
            if (State == State.SetDefaults)
            {
            Description = @"Enter the description for your new custom Indicator here.";
            Name = "ShowLongsBoolInputExample";
            Calculate = Calculate.OnBarClose;
            IsOverlay = true;
            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;
            ShowLongs = true;
            ShowShorts = true;
            }
            else if (State == State.Configure)
            {
            }
            }
            
            protected override void OnBarUpdate()
            {
            if (CurrentBar < 3)
            return;
            
            // if the last three bars have been up bars draw a green arrow up underneath the bar if ShowLongs is true
            if(ShowLongs && Close[0] > Open[0] && Close[1] > Open[1] && Close[2] > Open[2])
            {
            Draw.ArrowUp(this, "MyArrow" + CurrentBar, true, 0, Low[0] - (2 * TickSize), Brushes.Green);
            }
            
            // if the last three bars have been down bars draw a red arrow pointing down above the bar if ShowShorts is true
            if(ShowShorts && Close[0] < Open[0] && Close[1] < Open[1] && Close[2] < Open[2])
            {
            Draw.ArrowDown(this, "MyArrow" + CurrentBar, true, 0, High[0] + (2 * TickSize), Brushes.Red);
            }
            
            }
            
            // properties go in #region Properties like below. Outside of OnBarUpdate but inside the strategy class.
            [B]#region Properties
            [NinjaScriptProperty]
            [Display(Name="ShowLongs", Order=1, GroupName="Parameters")]
            public bool ShowLongs
            { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="ShowShorts", Order=2, GroupName="Parameters")]
            public bool ShowShorts
            { get; set; }
            #endregion[/B]
            
            }
            }
            Thanks in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Click image for larger version

Name:	screenshot.5.jpg
Views:	202
Size:	154.4 KB
ID:	1192764 Once I put it in and compile it, it disappears

              Comment


                #8
                Hello wealthcig,

                Thank you for your reply.

                You've put those in the wrong location and added additional closing curly braces to the end incorrectly.

                You need to put just those lines from #region Parameters through #endregion inside the indicator class, right after the end of OnBarUpdate. I'd take another look at the example script as this illustrates exactly where those lines need to go.

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  I will give it another go. Thanks for your support on this

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pechtri, 06-22-2023, 02:31 AM
                  9 responses
                  122 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by frankthearm, 04-18-2024, 09:08 AM
                  16 responses
                  66 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by habeebft, Today, 01:18 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by benmarkal, Today, 12:52 PM
                  2 responses
                  15 views
                  0 likes
                  Last Post benmarkal  
                  Started by f.saeidi, Today, 01:38 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X