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

Strategy Builder variable reference

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

    Strategy Builder variable reference

    I have created an entry strategy in Builder where one of the conditions refers to a set of conditions that occur during premarket hours. See images below. For some reason the premarket filter is not screening the entries and gives me entries regardless of the PreMktCriteria being = 1. I may be missing something? Please advice. Thank you any suggestions welcomed.


    Click image for larger version

Name:	PMktCrit01.jpg
Views:	260
Size:	109.0 KB
ID:	1195278Click image for larger version

Name:	PMktCrit02.jpg
Views:	258
Size:	119.4 KB
ID:	1195279Click image for larger version

Name:	PMktCrit03.jpg
Views:	252
Size:	131.3 KB
ID:	1195280
    Attached Files

    #2
    Hello designer01,

    From the images it looks like the default needs set to 0 instead of 1, that would prevent the condition in set 2 from happening until set 1 was true.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse, I tried changing to 0 same issue. I also tried bool as in image 01 default as "PreMktCriteria bool false" with no change.

      Comment


        #4
        Hello designer01,

        You will need to use a Print as an action to better understand when your condition is becoming true.

        the way the condition is set up would work as the following:
        Set 1: checks for a time range and HMA condition, if true it sets the variable to 1
        Set 2: checks the HMA condition and if the variable equals 1, if true enters.

        Once your set 1 becomes true once then the set 2 will be allowed any time going forward. If you meant to prevent entries in any other use case then you still need to add other logic to do that. You can reset the variable back to 0 when the condition should no longer be allowed.

        An example of what may be happening could be that on a historical day the variable is set to true, then all future days the variable is still true leading to set 2 being checked all the time. You would have to make an additional set if the strategy runs more than 1 day to reset that variable on the first bar of the session.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse, Thanks I had to unlock the code and insert an else statement and it works.
          I could not figure out how to do it in Builder, is there an option for an else statement in Builder see code below.
          Code:
            // Set 1
          if ((Times[0][0].TimeOfDay > new TimeSpan(9, 29, 0))
          && (Times[0][0].TimeOfDay < new TimeSpan(9, 31, 0))
          && (Close[0] > HMA1[0]))
          {
          BackBrush = Brushes.SandyBrown;
          PreMktCriteria = true;
          }
          else if ((Times[0][0].TimeOfDay > new TimeSpan(9, 29, 0))
          && (Times[0][0].TimeOfDay < new TimeSpan(9, 31, 0))
          && (Close[0] < HMA1[0]))
          {
          PreMktCriteria = false;
          }

          Comment


            #6
            Hello designer01,

            There is not an option for an else statement in the builder. The alternative would be to make an always true set which comes before the first condition.

            For example set 1 would set PreMktCriteria to false with no conditions or with a different set of hours to check. In set 2 you can check the condition which sets it to true. That would leave it false for all bars where set 2 is not true. This of course depends on your overall goal and how that PreMktCriteria variable should operate.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse, I did 2 separate if statements sets as shown in the code above, no need to have the else as you said. Works good. Thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by burtoninlondon, Today, 12:38 AM
              0 responses
              10 views
              0 likes
              Last Post burtoninlondon  
              Started by AaronKoRn, Yesterday, 09:49 PM
              0 responses
              14 views
              0 likes
              Last Post AaronKoRn  
              Started by carnitron, Yesterday, 08:42 PM
              0 responses
              11 views
              0 likes
              Last Post carnitron  
              Started by strategist007, Yesterday, 07:51 PM
              0 responses
              14 views
              0 likes
              Last Post strategist007  
              Started by StockTrader88, 03-06-2021, 08:58 AM
              44 responses
              3,983 views
              3 likes
              Last Post jhudas88  
              Working...
              X