Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

building complex conditions

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

    building complex conditions

    I am trying to build a simple strategy that uses a whole bunch of conditions or cases but I cannot seem to figure out how to program them togeather.

    The overview of the program is fairly simple, something like this.

    Case #1: Between 10:30 - 12:30am, if all market prices are above the 10min MA, then set case 1 = true.

    Case #2. If condition 1 = true, and time is between 12:30 - 2:30, if market price == 10min MA, then enter long

    I can program the simple if statements through the strategy wizard but I cannot seem to get the whole strategy working. Am I going about the whole process incorrectly??

    Also, any thoughts on how to build conditions (like I did in condition #1) based on OTHER markets (ie Use the SPY for condition 1 but then execute condition #2 or AAPL or something)

    Any thoughts would be greatly appreciated.

    #2
    You would need to work with user variables for the 'linking' of conditions together, here's a sample on this - http://www.ninjatrader-support2.com/...ad.php?t=15417

    Comment


      #3
      thanks bertrand for your quick reply

      i looked back at my code, and I did do exactly what you suggested, setting a variable to 0 or 1 (true or untrue as well) but I cant seem to get the strategy to work. Perhaps it has something to do with the fact that the "cases" involved are in different time periods.

      Here is a sample of my code

      Any ideas??

      // Condition set 1
      if (Low[0] >= EMA(14)[0]
      && ToTime(Time[0]) > ToTime(3, 15, 0)
      && ToTime(Time[0]) < ToTime(5, 16, 0))
      {
      Variable0 = 1;
      }

      // Condition set 2
      if (Variable0 == 1
      && ToTime(Time[0]) > ToTime(5, 15, 0)
      && ToTime(Time[0]) < ToTime(9, 17, 0)
      && Low[0] == EMA(14)[0])
      {
      EnterLong(DefaultQuantity, "");
      }

      // Condition set 3
      if (High[0] <= EMA(14)[0]
      && ToTime(Time[0]) > ToTime(4, 15, 0)
      && ToTime(Time[0]) < ToTime(5, 16, 0))
      {
      Variable1 = 1;
      }

      // Condition set 4
      if (Variable1 == 1
      && ToTime(Time[0]) > ToTime(5, 15, 0)
      && ToTime(Time[0]) < ToTime(9, 17, 0)
      && High[0] == EMA(14)[0])
      {
      EnterShort(DefaultQuantity, "");
      }

      Comment


        #4
        eurostoxx trader, that should not be the issue, if the condition in time1 is true it would set the variable and thus it stays set to this value until you set it otherwise...I would add Print statement to check that all variables have the values you would expect them to be - http://www.ninjatrader-support2.com/...ead.php?t=3418

        Next try another condition for the EMA entry, due to rounding it's unlikely the Close is exactly the EMA value so it may never trigger to enter.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        574 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X