Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing an Indicators Script

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

    Changing an Indicators Script

    Greetings, I have added a spread indicator that takes two assets(inputs) and deducts one from the other in any amount I enter.

    While I would prefer if it divides the inputs.

    Example: 1 MNQ - 1 MES

    Change example 1 MNQ / 1 MES

    I am trying to figure out through the NinjaScript editor on how to change into dividing the inputs, without any luck.

    I have attached it below. Would appreciate any ideas on how to.
    Attached Files

    #2
    Hello KyriakosCyprus,

    To do math between two series you would just use the series you wanted in the equation, for example

    Closes[0][0] / Closes[1][0]

    As a side note using AddDataSeries with variables and logic like you have will fail to work in some tools, please keep that in mind as the results you view may be inaccurate. It is only suggested to hard code the secondary instrument, this is noted in the help guide:


    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided.

    Comment


      #3
      Thank you but where should I insert the msg, as i understand this is the line that does the math. Screenshot below.

      Attached Files

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      77 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      45 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      168 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      101 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      165 views
      2 likes
      Last Post CaptainJack  
      Working...
      X