Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to plot a data series that has only one data point per week

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

    How to plot a data series that has only one data point per week

    Hello,

    I would like to plot a data series in NinjaTrader that is reflecting the netto postion of the commercials from the CoT report.

    The data series has only one data point per week, as seen below:

    Date (YYYYMMDD); NettoPosition;
    ...
    ...
    20171128;-246541;
    20171205;-189890;
    20171212;-119463;
    20171219;-128217;
    20171226;-149469;
    ...
    ...


    What is the best way to import these kind of data? I imagine to have a chart that plots the data above as a line on close.

    Thanks,
    Lukas

    #2
    Hello lakman184,

    Thanks for your post and welcome to the forums!

    There would not be a way to import and plot a line automatically without creating a custom indicator script to do so.

    If you would like to create a custom indicator, one approach would be to have your values and dates in a simple text file that you manually update each week. The indicator can then read the text file and plot lines based on the values. Here is a link to a working reference sample for reading a text file: https://ninjatrader.com/support/foru...ead.php?t=3476 Alternatively, you could add a parameter to the indicator where you enter in the weekly value and then just plot that line (in case you did not want history but just the most current week value). If you would like this created for you, we can provide references to 3rd party coders.

    An alternative would be to manually draw the lines on the chart based on the dates and values that you have. For example if you were to draw line using the line tool (F2 keyboard short cut) you could draw a short line and then double click on the line to access the line properties. In the line properties, you can drop down the "data" selection and enter in the begin and end dates along with the specific value. The advantage of this approach is that you can also create the line as a global line so that it appears on all charts (of the same instrument).

    Another alternative might be this indicator in the NT8 indicator file sharing area: https://ninjatrader.com/support/foru...d=7&linkid=951
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      thanks for your quick reply!

      I have some experience in programming, thus I will try to create an indicator on my own.

      I had a look into the sample file, ty


      I have another two questions:

      1) In the sample file, a text file is just read and then the values are printed to the console. This is a good startig point, but wich kind of class do I need to store the information and then how can I plot the data series to the chart?

      I think I need a "ISeries<T>" object, but how do I assign the values from the text file to this object and how to plot it?

      Does AddPlot(Brush brush, string name) references to the name of the data series?


      2) Can I execute and / or debug my code directly in the console? Or do I have to add the custom indicator every time to a chart to test if its working fine?


      I am sorry if these questions are obvious, but I am new to NT and every start is hard.


      Thank you and best regards,
      Lukas

      Comment


        #4
        Hello Lukas,

        Thanks for your reply.

        A bit of background first to help you think how to code your indicator. When you apply the indicator to the chart, the indicator will load the chart data and begin processing the oldest to the newest data. This means you want to process your report data in the same sequence of oldest to newest (which means you may want to set up your text file in that manner).

        One approach would be comparing the date of the bar data to the oldest (first) date in your text file. If the Bar date is greater than or equal to the text date and is less than the text date + 7 days, then that would be the line from the text file to grab the value to plot. Once you have grabbed the value to plot you can then assign that value to the plot.

        You would indeed use the AddPlot() method. You can assign values to the plot in the OnBarUpdate() using Value[0] = (the number to draw the line at).

        So you can continue using the same value to plot until you have a new bar day that is greater than text date+7 days which would be a trigger to read the next date from the text file and repeat the process.

        Here is a link to working with date/time: https://ninjatrader.com/support/foru...ad.php?t=19292
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gravdigaz6, Today, 11:40 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Today, 10:49 PM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by XXtrader, Today, 11:30 PM
        0 responses
        4 views
        0 likes
        Last Post XXtrader  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        9 views
        0 likes
        Last Post funk10101  
        Working...
        X