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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        55 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        142 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        160 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        96 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X