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 algospoke, Yesterday, 06:40 PM
                2 responses
                19 views
                0 likes
                Last Post algospoke  
                Started by ghoul, Today, 06:02 PM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                45 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                21 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                181 views
                0 likes
                Last Post jeronymite  
                Working...
                X