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

Strategy Tracks Symbol on Chart, But Trades Different Symbol

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

    Strategy Tracks Symbol on Chart, But Trades Different Symbol

    Hello NT8 Support,

    My strategy customizes the Chart Trader window behavior and is able to trade either the symbol on the chart to which it is applied (the default for Chart Trader), or trade a different symbol while continuing to take data from the chart symbol. For example, chart ES but trade MES "in the background" instead of ES.

    Question please: When trading the alternate symbol (MES in the above example), the Chart Trader order lines do not appear on the chart -- obviously because the chart symbol is not actually being traded by the custom code.

    Is there a way to make the Chart Trader order lines visible through code, then adjust their position on the chart based on what the strategy is actually doing? Just like Chart Trader would do if the symbol for orders matched the chart symbol? Again, in the example above the ES and MES prices track each other, so even if the customized Chart Trader strategy sent orders for MES, the order lines could still be drawn on the ES chart the strategy uses for its decision-making.

    So to make visible and control the Chart Trader's order lines, what are the Entry, Stop, and Target order line object names / classes that would be referenced in code?

    Any code snippets you can share would be appreciated. If anything here needs clarification, please contact me.

    Thank you.

    #2
    Hello D Trader,

    Thanks for your question.

    This would be a bit complicated to accomplish as you would want to draw your own order markers from your strategy with custom rendering and you would need to have these custom order markers remember their coordinates so you can detect if a mouse click is on the order marker and then put the order marker in a "Moving" mode so the order can be moved.

    The mouse portion can be ignored if you are simply looking for indication of where the order resides.

    You can use OnOrderUpdate to read order updates and use this this to update variables that would then be used for custom rendering to show the custom order markers.

    OnOrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

    To get more acquainted with SharpDX rendering, please see the Help Guide article below, and please see the SampleCustomRender indicator that comes with NinjaTrader.



    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you NinjaTrader_Jim.

      Actually, I was not looking for the guide on how to render drawing objects. Rather, the actual object names in Chart Trader when it draws its own order markers.

      For example,
      chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("C hartWindowChartTraderControl") as ChartTrader;

      ...will give me the ChartTrader object. From there I can address specific items inside ChartTrader like grdMain, which holds all the individual controls such as Instrument, TIF, account, order qty, etc.

      So my question is -- now that I have the ChartTrader object to work with, what control name should I use to reference the order markers?

      Alternately, if the order markers are rendered as needed by ChartTrader, are there any exposed ChartTrader methods that can be called to control drawing of order markers from within my strategy?

      Thanks again.

      Comment


        #4
        Hello D Trader,

        We don't provide any documentation for creating/using Chart Trader Order Markers in NinjaScript and it would fall into the unsupported category. If other community members have ventured down this path and have had success, then they are welcome to share their insight. (You are free to use unsupported code, but as that code is not documented, we do not have much to give insight on how the code should be used.)

        The best we could suggest would be to recreate the functionality using what is documented/supported. In this case we could give direction for having the custom Order Markers drawn with SharpDX rendering, storing coordinate information with variables associated with your custom Order Markers, using Mouse events to detect where the user clicks and moves the mouse, and then handling the mouse behaviors to move your custom order markers when clicked and update the orders accordingly.

        If you have additional questions taking this path, please feel free to follow up here.



        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks again Jim.

          If you have sample SharpDX and related code that does the following, it would save much trial and error:

          "we could give direction for having the custom Order Markers drawn with SharpDX rendering, storing coordinate information with variables associated with your custom Order Markers, using Mouse events to detect where the user clicks and moves the mouse, and then handling the mouse behaviors to move your custom order markers when clicked and update the orders accordingly."

          Even code to simply draw the order markers to look/act like those in ChartTrader would be a huge time saver. Based on other work I have done, I believe I can trap the mouse events and correlate to open orders/positions if there is nothing specific to that.

          Comment


            #6
            Hello D Trader,

            I don't have a specific example for drawing order markers, but I could suggest recreating the order marker with a combination of the following:

            DrawLine for drawing the line between the order marker's label and the right side of the ChartPanel

            FillRectangle to draw the label for the order marker. (You can use FillGeometry to create a custom shape like we see in the order markers if you want an order marker that looks similar to ours.)

            DrawTextLayout to draw the text on the order marker.

            The three SharpDX drawing methods can be referenced in our SampleCustomRender example which comes with NinjaTrader. The documentation linked in post #2 can give further direction for using SharpDX and best practices to follow.

            I look forward to assisting.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by dustydbayer, Today, 01:59 AM
            0 responses
            1 view
            0 likes
            Last Post dustydbayer  
            Started by inanazsocial, Today, 01:15 AM
            0 responses
            3 views
            0 likes
            Last Post inanazsocial  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            5 responses
            22 views
            0 likes
            Last Post trilliantrader  
            Started by Davidtowleii, Today, 12:15 AM
            0 responses
            3 views
            0 likes
            Last Post Davidtowleii  
            Started by guillembm, Yesterday, 11:25 AM
            2 responses
            10 views
            0 likes
            Last Post guillembm  
            Working...
            X