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

Bool function not working for entries based on indicators

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

    Bool function not working for entries based on indicators

    Hello,

    I am trying to create a strategy (in strategy builder) with a set of 2 indicators, RSI, MFI, to enter a long position if value of one or both signals is below 20 and if bool=true in each set.

    Here are my conditions:

    Set1:
    bool RSI=true
    signal: If RSI is less than numeric value 20 (plot on chart=checked, bars ago=0)
    Condition for Set1: Enter Long

    Set2:
    bool MFI=true
    signal: If MFI is less than numeric value 20 (plot on chart=checked, bars ago=0)
    Condition for Set2: Enter Long

    I am using "All entries", entries per direction=1

    In strategy analyser, if MFI=true, RSI=true , it works but only for RSI, and not for MFI. I can see on the chart on analyser that MFI was 60 and it still entered a long position.

    If MFI=true, RSI=false, then MFI works fine.

    Am I doing something wrong? why are both indicators not working together when their bool conditions are both true?

    Thanks in advance!

    #2
    Hello markkm,

    What was the behavior you were expecting?

    Was only one buy order placed and you were expecting two buy orders to be placed?

    (If so, this would be due to the EntriesPerDirection being set to 1)


    If you add a print of the time to the action block of the condition set are you finding the print appears with the time of the bar when you expect?

    Below is a public link to a forum post that demonstrates using prints to understand behavior. There is a video that demonstrates this using the Strategy Builder.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for you reply - I am expecting only (1x) entry long when both conditions need are true (MFI has to be less than 20, and RSi has to be less then 20),

      You can see from the attached chart that MFI was above 20 and it still entered long.
      Attached Files

      Comment


        #4
        Hello markkm,

        If both conditions need to be true, this should be in the same condition set.

        Condition sets are evaluated independently and in order. This means if set 1 evaluates as false and set 2 evaluates as true, the actions from set 2 will be triggered even though set 1 was false.

        To confirm, an order was placed and you are not expecting the order, is this correct?

        Have you added prints to the script to see when the condition set that places the order is evaluating as true?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          To confirm, an order was placed and you are not expecting the order, is this correct?
          That is correct.

          Have you added prints to the script to see when the condition set that places the order is evaluating as true?
          No I haven't.

          If both conditions need to be true, this should be in the same condition set.
          I could've done that, but that's not my goal.


          I basically want to create a system that I can optimize later on. This system would have RSI, MFI, maybe more indicators.

          My goal at the end of the optimization is to find the best entries from indicator, or indicator sets, e.g. RSI or RSI + MFI or only MFI.

          That why I am using different sets. The problem is : after optimizing, I had found that the best iteration was MFI along with RSI. After checking, I had found that it entered an ordered when it was not supposed to.

          Is there a better way to do this?

          Comment


            #6
            Hello markkm,

            If an order is placed, the individual condition set has evaluated as true.

            You are wanting to know why the condition has evaluated as true.

            To find out, you will need to debug the script by printing the values used in the condition set.

            I recommend you add prints to a new condition set with conditions (meaning it will print on every bar)

            Print the time, print MFI(14)[0], print Position.Quantity, print MFI, print RSI(14,3).RSI[0], and print RSI.
            With this information printed, we can find why the order was placed on this bar.

            One note, is that the names used for indicators and variables should always be unique.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I go tit figured it out, It had to set few variables.
              Thank you,

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              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  
              Working...
              X