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

DrawVerticalline

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

    DrawVerticalline

    Hello,

    I am trying to draw a Vertical line but i get 2 errors i dont understand.


    This return those errors:
    NinjaScript File Error Code Line Column
    SimplyDivVol.cs The overloaded method that best matches 'NinjaTrader.NinjaScript.DrawingTools.Draw.Vertica lLine (NinjaTrader.NinjaScript.NinjaScriptBase, string, System.DateTime, System.Windows.Media.Brush)' has invalid arguments CS1502 162 7

    NinjaScript File Error Code Line Column
    SimplyDivVol.cs Argument 3: Can not convert from 'double' to 'System.DateTime' CS1503 162 39

    Thank you
    Last edited by frankduc; 09-25-2019, 01:54 PM.

    #2
    Hello frankduc,

    Thanks for your post.

    You are receiving compile errors letting you know the syntax is invalid. Please reference the documentation for Draw.VerticalLine to see the available overloads and what needs to be entered for each parameter.

    Draw.VerticalLine - https://ninjatrader.com/support/help...rticalline.htm

    Also to note, Drawing tools should not be used in OnRender. OnRender is specifically for SharpDX rendering.

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      It is OBU
      What happen if my variable returns more than one barIndex? I suppose DVL cannot draw more than one line at a time, is there a way to draw a line for each returns in the variable?

      Comment


        #4
        Hello frankduc,

        ChartBars.ToIndex updates in OnRender and is relative to the bars that are in view. It would not be used for the same purpose in OnBarUpdate which is relative to the bars on the chart as they update.

        If you want to draw more than one object, then you can use unique tag names.

        I.E.

        VerticalLine myLine1 = Draw.VerticalLine(this, "tag1", 10, Brushes.Black);

        VerticalLine myLine2 = Draw.VerticalLine(this, "tag2", 10, Brushes.Black);

        Please let us know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          I didn't know that
          ChartBars.ToIndex
          was relative to OR, what would be the equivalent in OBU?

          I know that you can create more than one tag, bu what if your variable include more than one answer? Variable x = 1.2, 1.5, 1.9 will it draw 3 lines? I suppose you must extract someway each number and create a new variable for 1.2, 1.5, 1.9?

          Ty

          Comment


            #6
            Hello frankduc,

            There would not be an equivalent. Calculations based on what is visible should be done in OnRender and should be light in computation. Calculations based on the data itself should be done in OnBarUpdate and update as that data is fed through OnBarUpdate.

            I know that you can create more than one tag, bu what if your variable include more than one answer? Variable x = 1.2, 1.5, 1.9 will it draw 3 lines? I suppose you must extract someway each number and create a new variable for 1.2, 1.5, 1.9?
            If you have three different variables and append them to your tag's string, you would have three different strings so long as the appended variables are not the same. What needs to be understood is that a unique drawing tag will create a new drawing object, and reusing a tag will update that specific draw object. If you want them to always be unique, you will want to append values to the tag so they will always be unique.

            Please let us know if you have any questions.
            JimNinjaTrader Customer Service

            Comment


              #7
              There is something i dont get between calculation base OBU and OR.
              Here's an exemple on the chart attach. The CMA at top right corner give me on first chart 2972.55 and the VWMA returns the same and they are based on a chart with visible bars.
              Second chart show more bars (2000), CMA returns 2972.62 but VWMA returns 2973.22.
              If calculation OBU are made on the number of bars on the chart and not the number of bars visible they should both return the same answer?
              Note that the last value of the VWMA and CMA return always the same.

              TY
              Attached Files

              Comment


                #8
                Hello frankduc,

                The VWMA's used in the screenshots use the same data series, but a different period. A different number of bars are being used in the indicator's calculation which creates a different result.

                OnBarUpdate is used to calculate based on the bars on the chart, and a "Period" is used to determine how many of the most recent bars are used to calculate each new indicator plot.

                Please let me know if you have any questions.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Even if its true the period are different the CMA is a cumulative average of all the bars in the chart and the VWMA has a 5666 period which is way beyond the number of bars on the chart. They cover both equal number of bars. I tried on a another chart and as long as my CMA is in the range of visible bars the CMA return the right answer but when its out of the visible range the returns are wrong. Variables called locally could be a culprit? I am clueless at where reside the problem.

                  Comment


                    #10
                    Hello frankduc,

                    I cannot comment on how your indicator is calculating the CMA value without full understanding on your script's calculation.

                    With VWMA, you have an indicator that is using 2002 bars to develop each indicator plot and another that uses 5666 bars for each plot value. The resulting plot line between these indicators will be different.

                    It does look like your indicator is developing the same result of the VWMA that uses 5666 bars to develop the plot. If it is not clear what your indicator is calculating, I suggest reviewing the math to note what specific data is going in, and the math applied which would generate the result.

                    I look forward to being of further assistance.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Like i said if you input the same number of bars in the visible part of the chart and the same period in VWMA it will return the right answer. But if you go outside of the scope of the chart and you set a chart of 500 bars where only 250 are visible and you set up a period of 500 for the VWMA there will be an increasing difference of 2, 3, 5 points between the result of the CMA and the VWMA. It shouldn't be the case after all the CMA start at
                      ChartBars.FromIndex. The VWMA will return the right answer but my CMA is losing precision over a long period.

                      Code:
                      for(int barIndex = ChartBars.FromIndex; barIndex <= ChartBars.ToIndex; barIndex++)
                          {
                          closePrice = Bars.GetClose(barIndex);
                          volumes = Bars.GetVolume(barIndex); 
                      
                          clovol = closePrice * volumes; 
                      
                      
                          sum1 += clovol++;
                          sum2 += volumes++;
                      
                          cma = sum1 / sum2;
                      
                      
                          }

                      Comment


                        #12
                        Hello frankduc,

                        If the VWMA is added to a chart with 500 bars and the period of the VWMA is set to 500, all of those bars are included in the calculation. (This indicator uses OnBarUpdate to calculate the indicator plot value.)

                        ChartBars.FromIndex is the first visible bar and ChartBars.ToIndex is the last visible bar. In your case the value is calculated from the 250 bars that are visible. We would not recommend using OnRender for analysis because OnRender gets called frequently and is compute intensive.

                        You can add a print for ChartBars.FromIndex and ChartBars.ToIndex in OnRender and observe the BarIndexes in your data box. (Right Click in the DataBox and select Show BarIndexes)

                        The source code for the VWMA can also be observed to see how that plot is calculated.

                        Please let me know if you have any questions.
                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Gerik, Today, 09:40 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by RookieTrader, Today, 09:37 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by alifarahani, Today, 09:40 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post alifarahani  
                        Started by KennyK, 05-29-2017, 02:02 AM
                        3 responses
                        1,284 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by AttiM, 02-14-2024, 05:20 PM
                        11 responses
                        185 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X