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

DataSeries Multiplier

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

    DataSeries Multiplier

    Is it possible to multiply/divide a data series?

    i.e.
    I would like the dataseries to be GBP/USD divided by EURUSD
    and I could use the dataseries on any indicator.

    Or is there a workaround?

    #2
    Hello johnnybegoode,

    private Series<double> myDoubleSeries;

    myDoubleSeries = new Series<double>(this, MaximumBarsLookBack.Infinite);

    myDoubleSeries[0] = Closes[0][0] / Closes[1][0];

    Print(SMA(myDoubleSeries, 14)[0]);

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you!

      Any way the Input Series on the chart would allow other than Indicators and DataSeries?
      Maybe there is an indicator that could do some arithmetic to get the value of myDoubleSeries[0] = Closes[0][0] / Closes[1][0];?

      Comment


        #4
        Hello johnnybegoode,

        No, you would need to select an indicator that does that calculation..
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I achieved this with a workaround. I had to solve several sub-problems which may have been specific to my data.

          In short, I performed the calculations within excel and uploaded the final produkt via historical data import in NT.


          In long, there are several steps needed. I wanted the upvol / (upvol + dvol) function data for which I got from PItrading which by itself comes in NT format.

          Then I went through several steps
          - the txt file was far too large to import into excel, so I had to create several smaller txt files from it.
          - upload the txt files in excel via "data: import: from: csv/txt" which gives a table with 6 parts
          - perform the calculations for each of the 4 price specific data points as one wants

          uploading this in NT yields several errors (given by the log txt file from NT), among them:i) invalid value: open value should be lower or equal to highest value ii) invalid input #DIV/0! from calculations or variants of this iii) my 2 text files had a divergent length of 4 lines

          - to solve iii) I compared the dates within excel using a comparing function to select them and deleted the surplus lines
          - for ii) i used the search and replace function and replaced it with a number that would be false, but valid, and close enough to not distort much given it was 1minute data and hence not each value relevant
          - for i) I had to exchange several elements of the columns: I used the "if" function to achieve a) that the column for "highest value" was indeed the highest, programmable via if (value in highest column) > (value of lowest column) print the left value, if lower the right, for both columnst b) do the same to the effect that the "open value" is the smaller number and the "closing value" the larger
          - I multiplied the decimals with 100 as the [0,1] range didnt display when I uploaded it, the new range was then [0-100].​

          - save as "txt with tab as spacing" format
          - open txt with editor and go to the edit/replace function, copy a tab-space with the mouse cursor, paste it into the upper field and put a semicolon into the lower
          - repeat for all txt files and combine in a single txt file

          - then give it a name from the NT symbol library, I chose "^VOL" (indices and futures I think have to be preceded by that edge-symbol) to upload it successfully.

          this gave me the desired indicator and this can be done for other symbols created from other calculations, too. (it was more intuitive for me than to learn the NT language which Im sure would work eventually, but was too much for my memory). maybe I forgot a sub-step, but it works. (that the indicator is correct can be checked by comparing it to tradingview where it can be directly programmed).



          PS several problems can come up when importing data into NT which include choosing the "default 24x7" time frame / trading hours etc., but one can read that up in other threads.​
          Last edited by hansintakt; 09-07-2023, 05:56 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sidlercom80, 10-28-2023, 08:49 AM
          168 responses
          2,262 views
          0 likes
          Last Post sidlercom80  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by WeyldFalcon, 12-10-2020, 06:48 PM
          14 responses
          1,429 views
          0 likes
          Last Post Handclap0241  
          Started by DJ888, 04-16-2024, 06:09 PM
          2 responses
          9 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          41 views
          0 likes
          Last Post jeronymite  
          Working...
          X