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

Adding bool from Indicator to strategy

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

    Adding bool from Indicator to strategy

    Hello,

    I have created a indicator which works fine, basically the indicator is a MACD modify, painting a Plot.Style.Dot called Dot123 when some conditions in the macd happen.

    Now I want to use this Dot123 in my strategy. If the dot appears...
    if (MACD2.Dot.... i don't know... ){ .....}

    I am not able to do it, so I added in my MACD2 a bool when the Dot123 is created, making easy move it the strategy
    if(MACD2.mybool == true) {... }

    But the strategy doesn't compile.

    I will appreciate some help in both cases, but I believe the bool case would be easier.

    Thanks

    #2
    Hello Markines,

    Try using a public bool series.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you but it is not helping much,
      Probably I don't understand how strategy works.
      I thought if I have a variable in my new indicador, a INT or a Bool. When the conditions in my indicator happened and the mybool will be equal TRUE, I would be able to check in the strategy just written the code if (mybool = true) {....}

      But I am starting to think that I have to code in the strategy all the condition I have already coded in the Indicator to set mybool = true in order to make it happen. Or could I move the value of mybool to the strategy?

      Thanks

      Comment


        #4
        Hello Markines,

        Thank you for the reply.

        By using a Public Bool Series, you should be able to programmatically access the Bool Series value from your Indicator within your Strategy's logic.

        I've attached an example of an indicator and strategy that utilizes bool series and creates a condition that checks current bar modulus 2 to be 0. If it does equal 0, it sets the bool series to true and if false it sets the bool series to false. The strategy will call the indicator and print the value of the indicator for each bar telling you if true or false.

        Please download the attachment to your PC and navigate to the NinjaTrader Control Center. Next, select File > Utilities > Import NinjaScript and select BoolSeriesExample. Once successfully imported, you can then review the code by navigating to Tools > Edit NinjaScript and selecting the respective Indicator or Strategy code.

        Please let me know if you have any additional questions.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X