Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ORB strategy

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

    #31
    Hello caspian,

    Thank you for your reply.

    First, I see you have created this as a strategy script. As previously mentioned, this would need to be done with an indicator that calls AddPlot():


    The indicator would then be available to add to the Market Analyzer as an indicator column:


    I also see you are trying to access high and low prices in OnStateChange during State.DataLoaded:
    Code:
    else if (State == State.DataLoaded)
    {
    // Calculate IB range from 09:15 am to 10:15 am
    ibHigh = Highs[1][1];
    ibLow = Lows[1][1];
    }


    This is not possible and I would expect it to cause errors. Although data has been loaded at that point, it is not being processed yet so having a barsAgo reference does not make any sense until STate.Historical and State.Realtime. For more information, please see the OnStateChange() page here:


    Thank you for your time and patience.

    Comment


      #32
      i am using chatgpt to make this. can you copy paste the code i sent and add the changes you mentioned please.

      Comment


        #33
        Originally posted by caspian View Post
        i am using chatgpt to make this. can you copy paste the code i sent and add the changes you mentioned please.
        From our experience at this time, ChatGpt is not quite adequate to generate valid compilable NinjaScripts that function as the user has intended. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor, and use the code generated by ChatGpt as more as suggestions and guide when coding the script yourself, than using the actual code generated.

        While it is not within our support model to correct these scripts at user request, we would be happy to provide insight for any direct, specific inquiries you may have if you would like to create this script yourself. As I have mentioned, our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

        This thread is open to other forum users who would like to correct this script for you, or you can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one-on-one educational services.

        Thank you for your patience and understanding.​

        Comment


          #34
          affiliate consultants

          Comment


            #35
            Hello caspian,

            Thank you for your interest in NinjaTrader.

            You can search our list of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more:

            https://ninjatraderecosystem.com/search-results/?fwp_category=programming-services

            You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third-party services for NinjaTrader, all pricing and support information will need to be obtained through the consultant.

            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem, LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
            Christopher S.NinjaTrader Customer Service

            Comment


              #36
              please provide the list

              Comment


                #37
                the link cant be reached

                Comment


                  #38
                  the link is not working

                  Comment


                    #39
                    Hello caspian,

                    Below is the updated link.

                    Search trading apps & services to cusomize your NinjaTrader platform with trading indicators, signals and strategies.

                    Comment


                      #40
                      Hi Emily.its giving me this error below are the codes
                      NinjaScript File Error Code Line Column
                      ORBEXT.cs The type or namespace name 'MarketAnalyzerColumn' could not be found (are you missing a using directive or an assembly reference?) CS0246 99 43


                      region Using declarations
                      using System;
                      using System.ComponentModel;
                      using System.Windows.Media;
                      using NinjaTrader.Cbi;
                      using NinjaTrader.Data;
                      using NinjaTrader.Gui.Chart;
                      using NinjaTrader.NinjaScript;
                      using NinjaTrader.NinjaScript.Indicators;
                      using NinjaTrader.NinjaScript.Strategies;
                      #endregion

                      namespace NinjaTrader.NinjaScript.Indicators
                      {
                      [Description("Detects if the latest close crosses above the first-hour high of the trading session")]
                      public class CloseCrossesAboveFirstHourHigh : Indicator
                      {
                      private double firstHourHigh;

                      protected override void OnStateChange()
                      {
                      if (State == State.SetDefaults)
                      {
                      Description = "Detects if the latest close crosses above the first-hour high of the trading session";
                      Name = "CloseCrossesAboveFirstHourHigh";
                      Calculate = Calculate.OnBarClose;
                      IsOverlay = false;
                      }
                      else if (State == State.DataLoaded)
                      {
                      firstHourHigh = Highs[0][0];
                      }
                      }

                      protected override void OnBarUpdate()
                      {
                      if (CurrentBar == 0)
                      return;

                      if (Close[0] > firstHourHigh)
                      {
                      // Crossed above the first-hour high
                      Draw.Dot(this, "CrossAbove", true, 0, High[0] + TickSize, Brushes.Green);
                      }
                      }
                      }
                      }

                      namespace NinjaTrader.NinjaScript.Strategies
                      {
                      public class ORBEXT : Strategy
                      {
                      private CloseCrossesAboveFirstHourHigh closeCrossesAboveFirstHourHigh;

                      protected override void OnStateChange()
                      {
                      if (State == State.SetDefaults)
                      {
                      Description = "Strategy based on the CloseCrossesAboveFirstHourHigh indicator";
                      Name = "ORBEXT";
                      Calculate = Calculate.OnBarClose;
                      EntriesPerDirection = 1;
                      EntryHandling = EntryHandling.AllEntries;
                      IsExitOnSessionCloseStrategy = true;
                      ExitOnSessionCloseSeconds = 30;
                      IsFillLimitOnTouch = false;
                      MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                      OrderFillResolution = OrderFillResolution.Standard;
                      Slippage = 0;
                      StartBehavior = StartBehavior.WaitUntilFlat;
                      TimeInForce = TimeInForce.Gtc;
                      TraceOrders = false;
                      RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                      StopTargetHandling = StopTargetHandling.PerEntryExecution;
                      BarsRequiredToTrade = 20;

                      AddPlot(Brushes.Green, "Long");
                      AddPlot(Brushes.Red, "Short");
                      }
                      else if (State == State.Configure)
                      {
                      closeCrossesAboveFirstHourHigh = Indicators.GetIndicator<CloseCrossesAboveFirstHour High>();
                      }
                      }

                      protected override void OnBarUpdate()
                      {
                      if (BarsInProgress != 0) return;

                      if (CurrentBars[0] < 1)
                      return;

                      if (Position.MarketPosition == MarketPosition.Flat)
                      {
                      if (closeCrossesAboveFirstHourHigh != null && closeCrossesAboveFirstHourHigh.CrossAbove[0])
                      {
                      EnterLong();
                      }
                      }
                      else if (Position.MarketPosition == MarketPosition.Long)
                      {
                      if (Close[0] < Low[1])
                      {
                      ExitLong();
                      }
                      }
                      }
                      }
                      }​

                      Comment


                        #41
                        Originally posted by caspian View Post
                        Hi Emily.its giving me this error below are the codes
                        NinjaScript File Error Code Line Column
                        ORBEXT.cs The type or namespace name 'MarketAnalyzerColumn' could not be found (are you missing a using directive or an assembly reference?) CS0246 99 43


                        region Using declarations
                        using System;
                        using System.ComponentModel;
                        using System.Windows.Media;
                        using NinjaTrader.Cbi;
                        using NinjaTrader.Data;
                        using NinjaTrader.Gui.Chart;
                        using NinjaTrader.NinjaScript;
                        using NinjaTrader.NinjaScript.Indicators;
                        using NinjaTrader.NinjaScript.Strategies;
                        #endregion

                        namespace NinjaTrader.NinjaScript.Indicators
                        {
                        [Description("Detects if the latest close crosses above the first-hour high of the trading session")]
                        public class CloseCrossesAboveFirstHourHigh : Indicator
                        {
                        private double firstHourHigh;

                        protected override void OnStateChange()
                        {
                        if (State == State.SetDefaults)
                        {
                        Description = "Detects if the latest close crosses above the first-hour high of the trading session";
                        Name = "CloseCrossesAboveFirstHourHigh";
                        Calculate = Calculate.OnBarClose;
                        IsOverlay = false;
                        }
                        else if (State == State.DataLoaded)
                        {
                        firstHourHigh = Highs[0][0];
                        }
                        }

                        protected override void OnBarUpdate()
                        {
                        if (CurrentBar == 0)
                        return;

                        if (Close[0] > firstHourHigh)
                        {
                        // Crossed above the first-hour high
                        Draw.Dot(this, "CrossAbove", true, 0, High[0] + TickSize, Brushes.Green);
                        }
                        }
                        }
                        }

                        namespace NinjaTrader.NinjaScript.Strategies
                        {
                        public class ORBEXT : Strategy
                        {
                        private CloseCrossesAboveFirstHourHigh closeCrossesAboveFirstHourHigh;

                        protected override void OnStateChange()
                        {
                        if (State == State.SetDefaults)
                        {
                        Description = "Strategy based on the CloseCrossesAboveFirstHourHigh indicator";
                        Name = "ORBEXT";
                        Calculate = Calculate.OnBarClose;
                        EntriesPerDirection = 1;
                        EntryHandling = EntryHandling.AllEntries;
                        IsExitOnSessionCloseStrategy = true;
                        ExitOnSessionCloseSeconds = 30;
                        IsFillLimitOnTouch = false;
                        MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                        OrderFillResolution = OrderFillResolution.Standard;
                        Slippage = 0;
                        StartBehavior = StartBehavior.WaitUntilFlat;
                        TimeInForce = TimeInForce.Gtc;
                        TraceOrders = false;
                        RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                        StopTargetHandling = StopTargetHandling.PerEntryExecution;
                        BarsRequiredToTrade = 20;

                        AddPlot(Brushes.Green, "Long");
                        AddPlot(Brushes.Red, "Short");
                        }
                        else if (State == State.Configure)
                        {
                        closeCrossesAboveFirstHourHigh = Indicators.GetIndicator<CloseCrossesAboveFirstHour High>();
                        }
                        }

                        protected override void OnBarUpdate()
                        {
                        if (BarsInProgress != 0) return;

                        if (CurrentBars[0] < 1)
                        return;

                        if (Position.MarketPosition == MarketPosition.Flat)
                        {
                        if (closeCrossesAboveFirstHourHigh != null && closeCrossesAboveFirstHourHigh.CrossAbove[0])
                        {
                        EnterLong();
                        }
                        }
                        else if (Position.MarketPosition == MarketPosition.Long)
                        {
                        if (Close[0] < Low[1])
                        {
                        ExitLong();
                        }
                        }
                        }
                        }
                        }​
                        Hello caspian,

                        As I previously mentioned, ChatGpt is not quite adequate to generate valid compilable NinjaScripts that function as the user has intended. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor, and use the code generated by ChatGpt as more as suggestions and guide when coding the script yourself, than using the actual code generated. For example, the snippet you have posted uses both the indicators and strategies namespaces:
                        namespace NinjaTrader.NinjaScript.Indicators
                        namespace NinjaTrader.NinjaScript.Strategies

                        This would not be valid for NinjaScript to generate the necessary code. Please use the NinjaScript Editor to open a new indicator or strategy via the wizard and post in the necessary code. For more information on using the NinjaScript Wizard:


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

                        Comment


                          #42
                          HI EMILY. https://ninjatrader.com/support/help...?ns_wizard.htm THE INDICATOR GET HIGHLOW BY TIME RANGE. CAN YOU CREATE A VIDEO BY ADDING ADDITIONAL CODES. SUCH AS IF THE CLOSE CROSSES ABOVE THE HIGH OF THE RANGE SIMILARLY IF THE CLOSE PRICE CROSSES BELOW THE LOW OF THE RANGE LOW. IT SHOULD SHOW INITIAL BALANCE RANGE BREAK HIGH OR IB LOW BREAK. PLEASE PLEASE PLEASE EMILY.

                          Comment


                            #43
                            Originally posted by caspian View Post
                            HI EMILY. https://ninjatrader.com/support/help...?ns_wizard.htm THE INDICATOR GET HIGHLOW BY TIME RANGE. CAN YOU CREATE A VIDEO BY ADDING ADDITIONAL CODES. SUCH AS IF THE CLOSE CROSSES ABOVE THE HIGH OF THE RANGE SIMILARLY IF THE CLOSE PRICE CROSSES BELOW THE LOW OF THE RANGE LOW. IT SHOULD SHOW INITIAL BALANCE RANGE BREAK HIGH OR IB LOW BREAK. PLEASE PLEASE PLEASE EMILY.
                            Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one-on-one educational support in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates.

                            That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior. Further, debugging code created by AI tools such as ChatGPT typically goes beyond the boundaries of what our support team offers. If you would like more information about getting started with NinjaScript and using the Strategy Builder to develop your strategies, please see the following post:


                            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. This information has already been provided to you in post number 35 of this thread:
                            How would I go about making an orb strategy? I assume I would assign a custom double series I would set my custom series to only be the first 15 minutes I would set it to enter long if price goes above the high of the custom series and go short when it breaks below the low of the custom series? Does it look like my screenshots


                            Thank you for using NinjaTrader.​

                            Comment


                              #44
                              is there a ninja trader indicator to scan for candlestick patterns which can be added on market analyzer to display candlesticks pattern?

                              Comment


                                #45
                                Is there a indicator to detect gamma on a options chart

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                59 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                134 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                75 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                50 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X