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

Turn Indicator into Drawing Tool

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

    Turn Indicator into Drawing Tool

    Hello NT Community,

    I have the lifetime membership for NT8 and with it comes the OrderFlow Indicator Suite. The Order Flow Volume Profile comes as an indicator and a drawing tool. I am more interested in the drawing tool version. Unfortunately there is no source code available for either version and I am really interested in creating an indicator that can be drawn onto the chart over a discretionary range. Has anyone come up with something that can do this? My C# abilities are not quite there yet to creatively come up with a way to do this.

    #2
    Hello Don22Trader1,

    Thank you for your post.

    You are correct that the Order Flow Volume Profile (both the indicator and drawing tool) is not exposed for NinjaScript access. I am not aware of any existing scripts that would be similar to the drawing tool, though this thread will certainly remain open for other members of the forum community to chime in if they'd like.

    Thank you for using NinjaTrader. Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      I have advanced trying to complete this drawing tool. I would like some feedback on my approach if possible.

      I began the project as a drawing tool. The idea is to calculate the delta percentage of a user highlighted range that should update tick by tick if the last highlighted bar is the current one, just like the order flow volume profile drawing tool. The logic to capture mouse actions and getting selection points is finished but I am stuck on the delta% calculation. I cannot reference the volumetric bars data. I have included the using statement for namespace NinjaTrader.NinjaScript.BarsTypes; but I am still receiving errors like "The name 'CurrentBar', 'barsType', (and other bar data types/values) does not exist in the current context". Is there an issue with referencing bar types and bars data within a drawing tool?

      Comment


        #4
        Hello Don22Trader1,

        DrawingTools do not have data series and do not have an OnBarUpdate() override method and will not have a CurrentBar property (as these type of scripts do not process each bar's information in OnBarUpdate).

        You can access the chart bars as a Bars object (and not a series) with GetAttachedToChartBars.


        You can get bar values from the Bars object with Bars.GetValueAt(), Bars.GetClose(), etc.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Don22Trader1,

          CurrentBar only exists in the context of a indicator or strategy that is accessing the volumetric bars, in a drawing object there is no concept of CurrentBar. You have specific bar indexes in a drawing tool which relate to the anchors you made. To access the volumetric data you would need to use the bar indexes in place of CurrentBar if you are referring to the help guide samples for volumetric series. To access volumetric data from a drawing tool you need to use the following code:


          Code:
          ChartBars chartBars = GetAttachedToChartBars();
          NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType = chartBars.Bars.BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;
          
          if (barsType == null)
          return;
          
          int yourAnchorsIndex = 10;
          
          if( barsType.Volumes.Count()>= yourAnchorsIndex)
          {
              Print("Total Volume: " + barsType.Volumes[yourAnchorsIndex].TotalVolume);
          }
          JesseNinjaTrader Customer Service

          Comment


            #6
            So I kept advancing and unfortunately ran into a Problem.

            When I got further along, I tested out my drawing tool onto a chart. It's not complete but it performed as expected. After I went to Draw Objects to remove the drawing, I received an error message that read:

            "Unhandled exception: The '+' character, hexadecimal value 0x2B, cannot be included in a name." It only appears when I add my drawing tool to the chart and then remove it.

            I followed the tests found in this Forum Conversation by NinjaTrader_Kennedy https://forum.ninjatrader.com/forum/...e-1-position-1

            I managed to get to the second test, Test the Workspace Files:, I moved my workspace file to my desktop, and followed procedure. The platform opened fine. When I moved the file back to my desktop and opened ninjatrader again, the program opened fine but my workspaces are gone now. I'm not sure how to get them back without recreating them.

            I would appreciate any help to get me back on track.

            Comment


              #7
              I got the workspaces back,
              The file did something funky when I drag and dropped, but managed to get them back.

              My concern is that error code that is still popping up when I place my drawing and then delete it, or when I place the drawing then open drawing objects menu and just exit out without doing anything else.
              Last edited by Don22Trader1; 12-01-2023, 08:26 AM.

              Comment


                #8
                Hello Don22Trader1,

                Below is a link to a sample custom drawing tool.


                Are you able to reproduce with this sample?

                If not, it will be necessary to reduce and isolate code to determine the specific line of code causing the error.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I downloaded and used that custom line tool and it worked fine. It did not produce that error I was getting. Okay I will look through my script thoroughly and try to find what is causing this error.
                  Thank you for your patience.

                  Comment


                    #10
                    Okay, figured out what it was. When I created the basic framework in the DrawingTool Wizard, it wrote

                    Code:
                    namespace NinjaTrader.NinjaScript.DrawingTools
                    {
                       public class DeltaPercentage : DrawingTool
                       {
                          OnStateChange()
                          GetCursor()
                          ...
                          ...
                       }
                    For some reason without realizing, after trying to reference other drawing tools for inspiration, I added another class called: public class DeltaPercentageTool : DrawingTool {} within the already existing public class DeltaPercentage : Drawing Tool.

                    Code:
                    namespace NinjaTrader.NinjaScript.DrawingTools
                    {
                       public class DeltaPercentage : DrawingTool
                       {
                          public class DeltaPercentageTool : DrawingTool
                          {
                                OnStateChange()
                                GetCursor()
                                ...
                                ...
                          }
                       }
                    When I deleted that second class the error went away.

                    I appreciate the help and patience from the NT team.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Shai Samuel, 07-02-2022, 02:46 PM
                    4 responses
                    93 views
                    0 likes
                    Last Post Bidder
                    by Bidder
                     
                    Started by DJ888, Yesterday, 10:57 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by MacDad, 02-25-2024, 11:48 PM
                    7 responses
                    158 views
                    0 likes
                    Last Post loganjarosz123  
                    Started by Belfortbucks, Yesterday, 09:29 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post Belfortbucks  
                    Started by zstheorist, Yesterday, 07:52 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post zstheorist  
                    Working...
                    X