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

Changing variables within an Indicator from another indicator with Buttons

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

    #16
    Hello DTSSTS,

    This would be because the rollover for these instruments is December 9th.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      I had rolled them over, I found in the data management that the update of futures was not checked, so I updated and rebooted, and Now is correct, thanks

      Comment


        #18
        NinjaTrader_ChelseaB

        In post#6 that is another great example. I am trying to convert from EnterLong to SubmitOrderUnmanaged.

        I think I had it work this AM and then not since.

        It appears that SubmitOrderUnmanaged may not work, I created a toggle to go back and forth between managed and unmanaged.

        I prefer to use the unmanaged orders as I have better luck with catching errors especially the new GUID for the OCO.


        Code:
        if (IsUnmanagedINPUT){
        Print ("SubmitOrderUnmanaged IsUnmanaged="+IsUnmanaged+" IsUnmanagedINPUT="+IsUnmanagedINPUT);
        SubmitOrderUnmanaged(1, OrderAction.Buy, OrderType.Market, 1, 0, 0, string.Empty, "Long market");
        }else{
        Print ("SubmitOrderUnmanaged IsUnmanaged="+IsUnmanaged+" IsUnmanagedINPUT="+IsUnmanagedINPUT);
        EnterLong("Long market");
        }

        I have tried to figure it out with Visual Studio debugging
        System.IndexOutOfRangeException
        HResult=0x80131508
        Message=Index was outside the bounds of the array.
        Source=NinjaTrader.Core
        StackTrace:
        at NinjaTrader.NinjaScript.StrategyBase.SubmitOrderUn managed(Int32 selectedBarsInProgress, OrderAction orderAction, OrderType orderType, Int32 quantity, Double limitPrice, Double stopPrice, String oco, String signalName)
        at NinjaTrader.NinjaScript.Strategies.ChartOrderButto nsStrategyExampleSubmitOrderUnmanaged.OnButtonClic k(Object sender, RoutedEventArgs rea) in c:\Users\bart\Documents\NinjaTrader 8\bin\Custom\Strategies\BTW\ChartOrderButtonsStrat egyExampleSubmitOrderUnmanaged.cs:line 245
        at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
        at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args)
        at System.Windows.Controls.Primitives.ButtonBase.OnCl ick()
        at System.Windows.Controls.Button.OnClick()
        at System.Windows.Controls.Primitives.ButtonBase.OnMo useLeftButtonUp(MouseButtonEventArgs e)
        at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target)
        at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs)
        at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
        at System.Windows.UIElement.ReRaiseEventAs(Dependency Object sender, RoutedEventArgs args, RoutedEvent newEvent)
        at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
        at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target)
        at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs)
        at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised)
        at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args)
        at System.Windows.UIElement.RaiseTrustedEvent(RoutedE ventArgs args)
        at System.Windows.Input.InputManager.ProcessStagingAr ea()
        at System.Windows.Input.InputManager.ProcessInput(Inp utEventArgs input)
        at System.Windows.Input.InputProviderSite.ReportInput (InputReport inputReport)
        at System.Windows.Interop.HwndMouseInputProvider.Repo rtInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
        at System.Windows.Interop.HwndMouseInputProvider.Filt erMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
        at System.Windows.Interop.HwndSource.InputFilterMessa ge(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
        at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
        at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o)
        at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs)
        at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

        Comment


          #19
          I took post#6 code, I added unmanaged tag
          Code:
          if (State == State.SetDefaults)
          {
          isUnmanaged = true;
          }
          I changed from EnterLong to SubmitOrderUnmanaged in the simplest form
          Code:
          if (button == longMarketButton)
          {
          //EnterLong("Long market");
          //SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity); most simple entry
          SubmitOrderUnmanaged(1, OrderAction.Buy, OrderType.Market, 1);
          }
          I would really like to use this but I get this Error

          Click image for larger version  Name:	IndexBoundsIssue.png Views:	0 Size:	3.3 KB ID:	1203252
          Last edited by BartMan; 05-28-2022, 06:04 PM.

          Comment


            #20
            BartMan The error "Index was outside the bounds of the array" means the code is trying to use an object in an array that has an index greater than the number of elements in the array.

            Your code shows you are selecting BarsInProgress with an index of 1, i.e. the second data series in your strategy. BarsInProgress starts at zero for the first (possibly only) data series. Perhaps this is what is causing the error?

            Thanks.
            Multi-Dimensional Managed Trading
            jeronymite
            NinjaTrader Ecosystem Vendor - Mizpah Software

            Comment


              #21
              jeronymite thanks, great Idea but that does not appear to be it I printed out the bars CurrentBars[0]=34743 CurrentBar=34743

              here is the full code I disabled the limit and conditional entry just to be sure. ChartOrderButtonsStrategyExampleIndexError.zip

              Comment


                #22
                jeronymite I changed the 1 to a 0 and it worked, I had copied that line from working code with with 2 data series, where series 0 is 5 min series 1 is tick data. You were right, THANKS!

                from
                Code:
                SubmitOrderUnmanaged([COLOR=#e74c3c]1,[/COLOR] OrderAction.Buy, OrderType.Market, 1);
                to
                Code:
                SubmitOrderUnmanaged([COLOR=#27ae60]0[/COLOR], OrderAction.Buy, OrderType.Market, 1);

                Comment


                  #23
                  Can I get some pointers here w/o detrailing the thread, as the function of buttons on chart .zip already added to the chart is how I have built my script. My idea is set a new value of bars period when a chart button is clicked, fast access to a different bars period on the current BarsPeriodType.

                  Can I get some help to determine what syntax I can use to point to the default data series' bars period & update Bars Period Value on a click then refresh the entire chart, my example is minute bars type.

                  Comment


                    #24
                    I do not have the knowledge to direct answer most of your questions. I did create some buttons to trade ONE symbol from the chart of another which I need much help with.

                    IF you are trying to change 1 minute data from the main chart to another I am not sure that could ever be done and should not be done with a variable.

                    IF YOU have a 1 minute chart or a secondary dataseries for 1 minute and are applying an indicator like SMA to an 8 period to a chart and want to click a button and change that to a 20 period I would think you could do that.

                    Are you trying to plot an indicator OR trying to use and indicator in a strategy and want the button to alter the strategy?

                    Comment


                      #25
                      I thought my reply was quite direct. t
                      My idea is to ustilize buttons on the chart window, in the chart space, to be able to set a list of variables that can be changed on load in, in the property grid. Assume these variables are ins and each set a button to a period of minutes. When loaded the default data series' BarsPeriod value is updated and the entire chart is refreshed.

                      Comment


                        #26
                        OK I quite directly cannot help you with that.

                        Good Luck

                        Comment


                          #27
                          Originally posted by LoganJKTrader View Post
                          Can I get some pointers here w/o detrailing the thread, as the function of buttons on chart .zip already added to the chart is how I have built my script. My idea is set a new value of bars period when a chart button is clicked, fast access to a different bars period on the current BarsPeriodType.

                          Can I get some help to determine what syntax I can use to point to the default data series' bars period & update Bars Period Value on a click then refresh the entire chart, my example is minute bars type.
                          Hello LoganJKTrader,

                          Thank you for your note.

                          There is no supported or documented method/property to programmatically make changes to the primary series. If you'd like to change the primary series, which would result in the script recalculating, then you could change it via the Data Series window or use the Interval Selector dropdown menu to make the change. You may also use the keyboard to type in the change then press enter to submit the change. For more details on changing a data series:
                          https://ninjatrader.com/support/help...price_data.htm
                          (See the sub-section How to change a Data Series)

                          Thank you for using NinjaTrader.
                          Last edited by NinjaTrader_Emily; 05-31-2023, 08:40 AM.
                          Emily C.NinjaTrader Customer Service

                          Comment


                            #28
                            Originally posted by NinjaTrader_Emily View Post

                            Hello LoganJKTrader,

                            Thank you for your note.

                            There is no supported or documented method/property to programmatically make changes to the primary series. If you'd like to change the primary series, which would result in the script recalculating, then you could change it via the Data Series window or use the Interval Selector dropdown menu to make the change. You may also use the keyboard to type in the change then press enter to submit the change. For more details on changing a data series:


                            Thank you for using NinjaTrader.
                            The link in your post leads to a broken url
                            I have an example of something, is there a list of values in the drop down that I can target to click or focus click the drop down then select the barsPeriod type and then set the value in that menu programmatically?

                            Comment


                              #29
                              Originally posted by LoganJKTrader View Post

                              The link in your post leads to a broken url
                              I have an example of something, is there a list of values in the drop down that I can target to click or focus click the drop down then select the barsPeriod type and then set the value in that menu programmatically?
                              Hello LoganJKTrader,

                              Thank you for your note.

                              I have edited the link in my previous reply to the following and ask that you review the "How to change a Data Series" sub-section:


                              I'm not sure I fully understand what you are describing in your question. If possible, please provide an example of what you are looking to achieve/how it would behave so I may better understand and assist you.

                              I look forward to your reply.
                              Emily C.NinjaTrader Customer Service

                              Comment


                                #30
                                Hello,
                                I'm trying to use the SampleWPFModifications.zip template to enter a stop entry long using Button 1 from the Chart Trader buttons. I thought it would just be adding the EnterLongStopMarket() command at the location where the yellow arrow is pointing below, but I keep getting the error 'The name 'EnterLongStopMarket' does not exist in the current context.' Is it giving me this error because this is an indicator and not a strategy? How would I go about using this button to enter a long stop market order?

                                Click image for larger version

Name:	image.png
Views:	184
Size:	40.9 KB
ID:	1255781

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by rhyminkevin, Yesterday, 04:58 PM
                                5 responses
                                62 views
                                0 likes
                                Last Post dp8282
                                by dp8282
                                 
                                Started by realblubb, Today, 09:28 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post realblubb  
                                Started by AaronKoRn, Yesterday, 09:49 PM
                                1 response
                                18 views
                                0 likes
                                Last Post Rikazkhan007  
                                Started by ageeholdings, Today, 07:43 AM
                                0 responses
                                12 views
                                0 likes
                                Last Post ageeholdings  
                                Started by pibrew, Today, 06:37 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post pibrew
                                by pibrew
                                 
                                Working...
                                X