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

Newbie needs help

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

    #31
    Hello dorony,

    Thank you for your response.

    To get the strategy to enter as the bar is forming and when it meets the condition you will need to run with Calculate set to OnPriceChange: https://ninjatrader.com/support/help.../calculate.htm

    However, when the strategy calculates over historical data then it does so on the close of the bar. So you would still see historical executions on the bar after the condition. Please visit the following link for more details: https://ninjatrader.com/support/help...ime_vs_bac.htm

    Please let me know if you have any questions.

    Comment


      #32
      Thank you.

      One last thing, how do I code the charts and strategy to run on Pre and Post Market time as well.

      Additionally, how to only have the strategy to start and end during market hours.

      P.S. If I change my code to OnPriceChange, do I have to adjust any of my code?

      Comment


        #33
        Hello dorony,

        Thank you for your response.

        The market hours are controlled by the Trading Hours Template selected for the chart in the Data Series menu. Please visit the following links for more information:
        If you want the data to be available for Pre and Post market yet want the strategy to run only at certain hours then you need to implement a time filter. We have a sample of this available at the following link: https://ninjatrader.com/support/foru...ead.php?t=3226

        You should not need to adjust the code you have shown in this thread when using Calcualte.OnPriceChange. However, I would recommend testing the change in your strategy on the Sim101 account first.

        Please let me know if you have any questions.

        Comment


          #34
          Thank you so much!

          Now I am trying to create an indicator to plot an arrow when ever two consecutive candles lows are greater than or equal to the 5sma.

          I think I did it right, but for some reason the plot is only working sometimes when I clearly see that it should plot in more places.

          Any reason why it isn't plotting in all its supposed places?

          CODE BELOW

          private SMA SMA5;
          private ArrowDown MyArrowDown;

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Enter the description for your new custom Indicator here.";
          Name = "fiveminsmahold";
          Calculate = Calculate.OnEachTick;
          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)
          {
          SMA5 = SMA(Close, 5);
          }
          }

          protected override void OnBarUpdate()
          {

          if (CurrentBars[0] < 5)
          return;

          if ((Low[0] >= SMA5[0])
          && (Low[1] >= SMA5[1]))
          {
          ArrowDown MyArrowDown = Draw.ArrowDown(this, "My down arrow", true, 0, High[0] + (2 * TickSize), Brushes.Green);
          }
          }
          }
          Attached Files

          Comment


            #35
            Hello dorony,

            Thank you for your post.

            This is due to your tag in your Arrow. You are re-using the same tag and thus it is moving the arrow to a new bar each time the condition is true. You instead want unique arrows by setting unique tags. For example:
            Code:
            ArrowDown MyArrowDown = Draw.ArrowDown(this,[B] "My down arrow " + CurrentBar[/B], true, 0, High[0] + (2 * TickSize), Brushes.Green);
            CurrentBar will be different on each bar and will cause a new arrow to draw for each bar the condition is true on.

            Please let me know if you have any questions.

            Comment


              #36
              This worked. Awesome and Thanks.

              The reason I created this indicator is so I can use it with Market Analyzer to scan for stocks that are currently trading in the same fashion.

              If I wanted it to scan for stocks in which this Indicator is True. How would I have to adjust my code?

              The reason I ask is when I try to add this to the Market Analyzer as is, I don't see a way to have it filter when true when all it gives me is the ability to say greater less than and such.

              Comment


                #37
                Hello dorony,

                Thank you for your post.

                You would need to develop this as an indicator. You would also need to have a plot that is used and set to a specific value if a condition is true. You then check for this value of the plot in a Cell or Filter Condition in the Market Analyzer.

                So for example let's say no signal means the plot is set to 0, long condition sets the plot to 1 and short condition sets the plot to 2. Then in the Market Analyzer add this indicator as an Indicator Column and apply a Filter Condition to filter out those that do not meet a certain value or a Cell Condition to set the cell to a specific color when a condition is true.

                Please let me know if you have any questions.

                Comment


                  #38
                  Thank you for your response.

                  Here is an image of how I coded the indicator.

                  How do I rearrange it to be set as true or false?
                  Attached Files

                  Comment


                    #39
                    Hello dorony,

                    Thank you for your response.

                    You would want to set a Plot to a value that you would check in the Market Analyzer Filter or Cell Conditions.

                    Please visit the following link on Plots: https://ninjatrader.com/support/help...us/addplot.htm

                    Please let me know if you have any questions.

                    Comment


                      #40
                      Hello,

                      I tried to develop an if and else statement with the documentation you provided.

                      Is this how it should be. Not sure if it is workable in Market Analyzer yet.
                      Attached Files

                      Comment


                        #41
                        Hello dorony,

                        Thank you for your response.

                        Have you developed an indicator with a plot before? Please take a look at the code for the SMA for a basic example of using Plot.

                        Please let me know if you have any questions.

                        Comment


                          #42
                          Hey

                          I think I got it!

                          I only need one plot and 2 values to distinguish whether its true or false.

                          Could you please let me know if the Image (code) I attached is logically correct?

                          I then go to Market Analyzer, add a column with "Plot 1" either showing 0 or 1.

                          0 means that the conditions is true, while 1 means the condition is false?

                          Is this correct?
                          Attached Files

                          Comment


                            #43
                            Hello dorony,

                            That is correct. Good work on this item.

                            Please let me know if I may be of further assistance.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by benmarkal, Yesterday, 12:52 PM
                            3 responses
                            22 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by helpwanted, Today, 03:06 AM
                            1 response
                            16 views
                            0 likes
                            Last Post sarafuenonly123  
                            Started by Brevo, Today, 01:45 AM
                            0 responses
                            11 views
                            0 likes
                            Last Post Brevo
                            by Brevo
                             
                            Started by aussugardefender, Today, 01:07 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post aussugardefender  
                            Started by pvincent, 06-23-2022, 12:53 PM
                            14 responses
                            244 views
                            0 likes
                            Last Post Nyman
                            by Nyman
                             
                            Working...
                            X