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

Script syntax for SHARED variables

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

    Script syntax for SHARED variables

    protected override void OnBarUpdate()
    {
    // When our indicator gives us a bull signal we enter long. Notice that we are accessing the
    // public BoolSeries we made in the indicator.
    if (SampleBoolSeries().BullIndication[0]) EnterLong();

    // When our indicator gives us a bear signal we enter short
    if (SampleBoolSeries().BearIndication[0]) EnterShort();


    ************************************************** ******************
    The above script is from your NT8 SampleBoolSeries indicator file.
    It references a public <bool>Series variable from SampleBoolSeries Strategy.



    Question: if I change the SampleBoolSeries Strategy script to add user-settable "Properties",
    Then what is the syntax to access a Stategy's BearIndication and BullIndication variables.

    for example:
    if (SampleBoolSeries().BearIndication[0]) <== this would be the script's syntax when the Indicator
    DOES NOT have any user-settable properties


    if (SampleBoolSeries(7,true).BearIndication[0]) <== the script's syntax when the Indicator
    DOES HAVE user-settable properties
    I UNDERSTAND that the user-settable variables must
    appear in the script in the same order that they
    appear in the Properties prompts.

    WHAT I DO NOT UNDERSTAND IS THIS: When my script shows "(7,true)"
    does that mean that the ONLY time the correct BearIndication "Value" will be read from the indicator
    is when the user-settable <property> variables are like this ===> SampleBoolSeries(7,true).BearIndication[0]

    WHAT HAPPENS IF THE USER sets the user-settable INDICATOR indicator variables in the <PROPERTIES> to 9 and false.
    Must I add a line to my INDICATOR script file for each instance of the variables for when I WANT TO USE the INDICATOR'S
    shared variable. Like this ==>

    if ( (SampleBoolSeries(7,true).BearIndication[0]) || (SampleBoolSeries(9,false).BearIndication[0]) )
    {
    do something here..
    }

    DoesNinjaTrader8 provide a different INDICATOR-script-syntax that does not require that I provide multiple lines, of code, that
    contain the actual values for each variable passed in the "Call" from the STRATEGY to the INDICATOR?
    Last edited by seefisch; 10-28-2016, 05:34 PM.

    #2
    Hello,

    I wanted to check if I am understanding the question correctly.

    Are you asking if the platform offers any other syntax to call indicators by that may be less complex than what you are currently using?

    If so the NinjaScript does not offer anything specific like this, but you could store the indicators as a variable to reduce its syntax potentially.

    Can you provide a sample of what you would expect the platform to provide instead of the samples you had provided? If I can better understand your expectation, I could likely suggest a solution.

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

    Comment


      #3
      Many thanks for your time.

      Jesse -- yes you answered my questions.

      I CAN see how I could store the values as a variable.

      I have decided to make multiple script files by setting fixed values for each of the variables that were in the Properties and then compiling. Repeat for different settings. It just isn't worth the amount of time FOR THIS project I was just hoping against hope that I could find an easier way.

      Thanks for you expert knowledge.
      Curt

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by adeelshahzad, Today, 03:54 AM
      5 responses
      32 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by stafe, 04-15-2024, 08:34 PM
      7 responses
      32 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by merzo, 06-25-2023, 02:19 AM
      10 responses
      823 views
      1 like
      Last Post NinjaTrader_ChristopherJ  
      Started by frankthearm, Today, 09:08 AM
      5 responses
      20 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      43 views
      0 likes
      Last Post jeronymite  
      Working...
      X