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

Trigger not on high or low bar

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

    Trigger not on high or low bar

    In some weird way the trigger in my strategy i am devoloping is not showing on the high or low bar if an indicator is within the limits.
    For now I am drawing an extra vertical line if the conditions are right. I know the up and down arrow are on the bottom, 0 line, of the chart.

    The arrows did show in the chart above and under the trigger bar, but not now.

    This is the code:
    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(RSI(5, 3).Avg, 30, 1)
    && CrossAbove(DoubleStochastics(10).K, 15, 2))
    {
    DrawArrowUp("My up arrow" + CurrentBar, false, 0, High[0] + 2 * TickSize, Color.Lime);
    DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.ForestGreen);
    }

    // Condition set 2
    if (CrossBelow(RSI(5, 3).Avg, 70, 1)
    && CrossBelow(DoubleStochastics(10).K, 85, 3))
    {
    DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + 2, Color.Red);
    DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.Crimson);
    }
    }
    And is it possible when a condition is triggered that on an other index a long or short position is triggered?

    #2
    Hello richier,

    Thanks for your post.

    I noticed that the DrawArrowDown code contains, Low[0] + 2 but does not contain a multiple of * TickSize like your other arrow code does. Depending on the price value, adding 2 to it may place the arrows way away.

    If you want the Red arrow to appear below the low of the bar then you could change your code to Low[0] - 2 *TickSize to draw the arrow 2 ticks below the low of the bar.

    If this does not resolve the issue, please post a screenshot so I can see what you are seeing.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I tried the * TickSize. Didn't work.
      Here is the screenshot:
      Attached Files
      Last edited by richier; 04-27-2016, 11:46 AM.

      Comment


        #4
        Hello richier,

        Thanks for your reply.

        It appears your attachment isn't working. To manage an attachment make sure you click on "go advanced" an then click on "manage attachments" to load a picture.

        With the change made to your code I have attached a screenshot of what I see here. Is this what you are expecting?
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello richier,

          Thanks for your post and thanks for fixing the picture.

          As you can see by mine the arrows are plotting. What I would suggest is that you remove the strategy from the chart, open the strategy again ensure that you have the * Ticksize in place, compile or finish the strategy then reapply it to a chart. I don't have access to the same instrument you are using so I cannot truly replicate but I don't see anything in your code that would inhibit showing the arrows.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Oke on the attachments, but I can't find the 'go advanced' icon. I can only manage attachments.

            What you see is what I want to see. Again a screenshot and the code:
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {

            CalculateOnBarClose = true;
            }

            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
            // Condition set 1
            if (CrossAbove(RSI(5, 3).Avg, 30, 1)
            && CrossAbove(DoubleStochastics(10).K, 15, 2))
            {
            DrawArrowUp("My up arrow" + CurrentBar, false, 0, High[1] + 2 * TickSize, Color.Lime);
            DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.ForestGreen);
            }

            // Condition set 2
            if (CrossBelow(RSI(5, 3).Avg, 70, 1)
            && CrossBelow(DoubleStochastics(10).K, 85, 3))
            {
            DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + -2 * TickSize, Color.Red);
            DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.Crimson);
            }

            // Condition set 3
            if (CrossAbove(RSI(5, 3).Avg, 30, 1))
            {
            DrawDiamond("My diamond" + CurrentBar, false, 0, High[0] + 2, Color.ForestGreen);
            }

            // Condition set 4
            if (CrossBelow(RSI(5, 3).Avg, 70, 1))
            {
            DrawDiamond("My diamond" + CurrentBar, false, 0, Low[0] + -2, Color.Red);
            }
            }
            Attached Files

            Comment


              #7
              Hi Paul,

              Thanx for your patience, but still the arrows don't show. Reloaded the script severall times, turned it on and of (even throwing away the script and rebuidling it).

              I'm at a standstill don't know what I am doing wrong.

              Comment


                #8
                This is the whole code in pdf.
                Attached Files

                Comment


                  #9
                  Hello richier,

                  Thanks for your replies.

                  In the added conditions you still need to add +2 * TickSize to be correct for any instrument (instead of +2).

                  Note: It is possible that the draw object are behind the candles, please left click on the candles to get selection handles (black squares on the candles) then using Ctrl and shift held down, roll the scroll wheel on your mouse to adjust the "z" axis of the drawing objects. reference: http://ninjatrader.com/support/movie...rt-Z-Order.htm

                  If that does not resolve the issue, I've recreated your script and I have attached it. Please download and then import via File>Utilities>import

                  Apply it to a chart and advise if you see something like the attached. (Note if you edit the script it will only open in code view, sorry).
                  Attached Files
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello Paul,
                    Again thanks for your patience. I don't know why but at the end (with lossing some other handdrawn markers) I closed the whole chart and reopend it.

                    Now it is working fine.
                    Some loop in the systmen, when it runs in an error and even when you correct it the chart will not budge.

                    But thanks, also for your quick replys!

                    Comment


                      #11
                      Last question:
                      Is it possible when a condition is triggered (the arrows) that on another index a future position can be entered (within the strategy) long or short?

                      Comment


                        #12
                        Hello Richier,

                        Thanks for your post.

                        Yes it is possible but not through the strategy wizard. You would need to add a data series to your strategy and then code your entry/exists based on which dataseries you were wanting to place orders. This is the best reference on the subject: http://ninjatrader.com/support/helpG...nstruments.htm
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks again.

                          TIme to study.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by junkone, Today, 11:37 AM
                          2 responses
                          15 views
                          0 likes
                          Last Post junkone
                          by junkone
                           
                          Started by frankthearm, Yesterday, 09:08 AM
                          12 responses
                          44 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by quantismo, 04-17-2024, 05:13 PM
                          5 responses
                          35 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by proptrade13, Today, 11:06 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by love2code2trade, 04-17-2024, 01:45 PM
                          4 responses
                          36 views
                          0 likes
                          Last Post love2code2trade  
                          Working...
                          X