Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script to update price data from a textfile

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

    Script to update price data from a textfile

    Hi again

    I need to make a script to update the price data from a text file directly in the chart without needing to go to Historical data manager and again reload the chart to read the latest data ,

    if this is a simple process with just few lines of code or if there is similar scrips made already , will be grateful for the code ,

    if it is not please let me know where I can find documentation for making scripts ..

    Best regards


    #2
    Hello Ramtin,

    Thanks for your question.

    Price data is given in a Data Series which is created by a BarsType. The BarsType will build bars from historical data that is requested by the platform and then will create new bars from the incoming realtime data.

    Creating a BarsType that reads data from text files instead of from the incoming data from OnDataPoint would not a supported use of a BarsType, and I don't think it would help accomplish your goal.

    Could you elaborate on what you are trying to accomplish exactly?

    Do I understand correctly that you are trying to create additional bars and have the script reloaded to process those bars that you create or read from a file?

    I look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you for your answer ,

      here is what i'm trying to do

      I need to manipulate the historical data ( deleting or adding bars or changing the high ,low or close or opening price levels ) in order to evaluate the outcome of different strategies ,

      Since it is not possible to edit more than one row of data at the time in Historical Data Manager and editing must be row by row and day by days which is very time consuming

      I first export the data into a text file from Historical Data Manager and save it as Ticker.Last.txt ( ie IBM.Last.txt )

      next step I make the changes in another program outside NinjaTrader and again save the changes into the same file with the same name and same date and price format .

      next step is to loading the manipulated data into the chart and here it is what I need help with a script , so instead of again going to Historical Data Manager and import the manipulated

      IBM.Last.txt , I would like to do it with a script in the open IBM chart window using F5 , so each time i reload the script the new data from the IBM.Last.text will be read in the chart and the

      chart updated with the new manipulated data .

      Thanks








      Comment


        #4
        Hello Ramtin,

        Thanks for clarifying.

        Thinking this out, I do not believe it would be possible through the context of an indicator or BarsType.

        The BarsType determines the number of "bar slots" on the chart and the OHLC values of the data series, so even if we could read the data from an indicator, we could not modify the underlying data series.

        A BarsType also would not be helpful since it builds bars based on incoming data into the platform.

        I think your best way forward for manipulating the data would be to do as you are: Export the data, modify it, and then re-import. Creating custom symbols could help to prevent the manipulated data from being overwritten if you are connected to your data provider and perform a Reload All Historical Data operation.

        Please let me know if there is anything else I can do to help.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello Ramtin,

          Thanks for clarifying.

          Thinking this out, I do not believe it would be possible through the context of an indicator or BarsType.

          The BarsType determines the number of "bar slots" on the chart and the OHLC values of the data series, so even if we could read the data from an indicator, we could not modify the underlying data series.

          A BarsType also would not be helpful since it builds bars based on incoming data into the platform.

          I think your best way forward for manipulating the data would be to do as you are: Export the data, modify it, and then re-import. Creating custom symbols could help to prevent the manipulated data from being overwritten if you are connected to your data provider and perform a Reload All Historical Data operation.

          Please let me know if there is anything else I can do to help.
          What I think he means to ask (& I need to ask) is if its possible to script the <Import Historical Data> section of NT. Naturally NT needs to import csv prices via Import Historical Data. However is there a way to automate the csv Import function?

          Comment


            #6
            Hello rhubear,

            ImportType scripts are exposed and can be created, but these are moreso intended if you want to be able to import data with a custom format. We could not suggest a way to automate the importing of historical data and allow for a way to refresh a chart after the data has been imported.

            Documentation on ImportType scripts can be found below, and you can reference our pre-built ImportType scripts in the NinjaScript Editor.

            https://ninjatrader.com/support/help...mport_type.htm

            I look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #8
              And here is the text file

              regards




              Attached Files

              Comment


                #9
                Hello Ramtin,

                You can implement a StreamReader to read data and have that processed by an indicator, but this would not affect what is on the chart.

                The compile error is letting you know the syntax is incorrect. This is just a C# related error and you can use your favorite search engine to learn more about the compile error and how the syntax should be written.

                I have provided a link to a publicly available resource which can explain further. I had simply searched for the compile error on Google to find this resource.

                https://stackoverflow.com/questions/...ng-backslashes

                Please also note that Cbi.Core.UserDataDir.ToString() already returns the Documents\NinjaTrader 7\ path. You can print out this string to see where it goes to see what path you would be building.

                I look forward to assisting.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Hoffmann, Today, 04:17 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by demarcog, Yesterday, 02:24 PM
                8 responses
                30 views
                0 likes
                Last Post NinjaTrader_Kate  
                Started by ErikY, Today, 01:28 PM
                2 responses
                7 views
                0 likes
                Last Post ErikY
                by ErikY
                 
                Started by augustfay, Today, 01:07 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Oneobr09, Today, 12:21 PM
                1 response
                22 views
                0 likes
                Last Post NinjaTrader_Kate  
                Working...
                X