Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Beginners Woes

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

    Beginners Woes

    Hi,

    I am currently trying to code for what would be similar to the simple strategy that monitors for a breakout but am having problems.

    The scenario that i am looking for is when indicator X has been below a predefined level for a predefined period of time and then returns a value above that level a buy order is placed.

    The order is currently being executed on the value set for "voAcDays" as opposed to when it braeks the voAc level.

    Just wondering if anyone can help.

    {
    // Resets the vAHigh at the Start of every new session
    if (Bars.FirstBarOfSession)
    voAcHigh = VA().Plot0[0];

    // Stores the vAHigh from the defined amount of period of time.

    if (Bars.BarsSinceSession <= voAcDays && VA().Plot0[0] > voAcHigh)
    voAcHigh = VA().Plot0[0];

    if (VA().Plot0[0] >= voAcLevel && voAcHigh < voAcLevel);
    {
    // Entry Order used to generate Buy Orders
    EnterLong(1, "VoAc - Signal");
    }

    #2
    If you are looking for the break condition I suggest you use CrossAbove() or CrossBelow() instead of the simple equality relational checks.

    You can use Print() throughout your code to better understand and debug your logic also. Hope that helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Have been trying what you said to no avail as yet.

      Will keep working on it.

      Comment


        #4
        This certainly is a problem in your code below (there should not be a semicolon)
        if (VA().Plot0[0] >= voAcLevel && voAcHigh < voAcLevel);

        Comment


          #5
          Thank you again for the response.

          what i am looking for is something that returns a reponse for when an indicator has not been above a certain value a for certain period of time.

          ie. how would you code for the situation that momentum has not crossed above 50 in the last 180 days.

          Comment


            #6
            Check out the MRO() function.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hi,

              I have just tried the MRO() function but to no avail.

              Is it coded correctly?

              {
              int barsAgo = MRO(delegate {return VolumeAccumulation().Plot0[0] < VoAcLevel;}, 1, VoAcDays);
              // Condition set 1
              if (CrossAbove(VolumeAccumulation().Plot0, VoAcLevel, 1)
              && barsAgo == -
              1)
              {
              EnterLong(
              1000, "VoAc Entry");
              }
              }

              Comment


                #8
                What you want to do is use MRO to check that the value was lower then your VoAcLevel. To do this you want to do it reverse. You want to check that the value goes higher then the VoAcLevel. When MRO() looks back VoAcDays and doesn't return a value of the bar above the VoAcLevel that means you were below the VoAcLevel the whole time. Basically you want MRO() to return a -1 for you.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you. It works.

                  Now for more coding!

                  Comment

                  Latest Posts

                  Collapse

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