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

avoid crossing over line drawn by strategy

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

    avoid crossing over line drawn by strategy

    Hello, my strategy draws a line from one set point to another within the momentum indicator. On this amount of candles I already have a series that keeps the momentum, what I want is that if there is any crossing above or below, depending on whether it is red or green, of the line that draws my strategy, do not enter. My problem is that I can't get the double of the line. I would like to know if, just as it is given a name "lineX" that marks the entire line, I can obtain a double value over the entire series of the "lineX"
    Attached Files

    #2
    Hello RubenCazorla,

    Are you wanting a chart anchor like the StartAnchor or are you wanting the y-intercept of where a line is being crossed on a specific bar.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3

      what I want is the momentum1 of a series of example bars; bar 2 to bar 12, is less than the line drawn by the strategy within the same series of bars, if this is different, do not execute the strategy

      my series of bars would be this;

      Series<double> divmom = new Series<double>(this, MaximumBarsLookBack.TwoHundredFiftySix);
      for(int i = 2; i < 12 && i < Momentum1.Count && Momentum1[i] != null; i++)
      {
      divmom[i] = Momentum1[i];
      }
      for(int i = 0; i < 2; i++) {
      divmom[i] = Double.MaxValue;
      }

      and there is the line;

      Draw.Line(Momentum1, @"LineMom", false, 12, Momentum1[12], 0, Momentum1[2], Brushes.Green, DashStyleHelper.Solid, 1);

      Comment


        #4
        Hello RubenCazorla,

        When you say less than the line '...the momentum1... ...is less than the line drawn...' . What if the line has two anchors at different prices (drawn diagonally)? Will the line always be horizonal?

        What do you consider less than that line? Less than the first anchor of the line? Less than the second anchor of the line? Less than the y-intercept of the line on a bar between the two points?

        Is the code you have suggested the code you want?
        The code you have suggested does not appear to check if the divmom[0] is less than the line.
        Where are you getting stuck?
        Do you have code comparing the momentum1 to the line?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5

          what I want to avoid are these momentum crosses with the line that draws my strategy,
          as in the drawing it is observed
          Attached Files

          Comment


            #6
            Hello RubenCazorla,

            What do you consider crossing a line?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7

              that he does not cross the line is a condition to enter long

              Comment


                #8
                Hello RubenCazorla,

                Without you providing specifics, its hard to advise. Likely, you are wanting to check the y-intercept of a line, and then compare that bar's y intercept on that line to the price from the indicator.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Shansen, 08-30-2019, 10:18 PM
                24 responses
                942 views
                0 likes
                Last Post spwizard  
                Started by Max238, Today, 01:28 AM
                0 responses
                9 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by rocketman7, Today, 01:00 AM
                0 responses
                4 views
                0 likes
                Last Post rocketman7  
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                28 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                33 views
                0 likes
                Last Post wzgy0920  
                Working...
                X