Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time Frame Stop Adjustment

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

    Multi Time Frame Stop Adjustment

    Hello,
    Please take a look at the code bellow...I am trying to change my stop price using a Range 1 chart to trigger the stop change from the primary 5 minute chart. I keep getting an error when trying to compile...I have poured over the forums and sample strategies provided as well as the multi time frame material in the help guide....i know its something simple I am just not getting...Thanks in advance!



    protected override void Initialize()
    {
    Add(PeriodType.Range, 1);
    }

    protected override void OnBarUpdate()
    {

    if (Position.MarketPosition == MarketPosition.Long)
    {
    if (CrossAbove(Close[1][0], Position.AvgPrice + 22 * TickSize, 1) && tStop1 == false)
    {
    Do something
    }
    }

    }
    Last edited by decklin17; 10-04-2009, 07:02 PM.

    #2
    Please try using 'Closes' in your code with a multiseries context - http://www.ninjatrader-support.com/H...V6/Closes.html

    Comment


      #3
      I tried that....still produces error when compiling...

      protected override void Initialize()
      {
      Add(PeriodType.Range, 1);
      }

      protected override void OnBarUpdate()
      {

      if (Position.MarketPosition == MarketPosition.Long)
      {
      if (CrossAbove(Closes[1][0], Position.AvgPrice + 22 * TickSize, 1) && tStop1 == false)
      {
      Do something
      }
      }

      }

      Comment


        #4
        Please try just

        Code:
         Closes[1]
        You need to pass in a dataseries, not a double.

        Comment


          #5
          Bertrand,

          Why isn't 'Closes[1][0]' equivalent to 'Closes[1]' in the CrossAbove function? If it was a syntac error, then the complier should have caught it.

          This appears to be a good example of how this function wasn't very well thought out by the developers. The offset parameter is quite unnecessary since the offset could be taken from the context of dataseries.

          Sure you don't really need functions like CrossAbove() or CrossBelow() since they are quite easy to code using just two conditional statements.

          Comment


            #6
            Closes[1][0] is not a DataSeries. That is the actual double value. When using CrossAbove() you need to use DataSeries objects and to get that you would just do Closes[1]. Please see the acceptable signatures here: http://www.ninjatrader-support.com/H...rossAbove.html The issue was indeed caught by the compiler as experienced by decklin17.

            There is no need to argue the merits of methods. Many methods can easily be argued that you do not "need" them. They are all provided for the convenience of the user and ease for the non-seasoned programmers.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              That worked! Thanks Bertrand and Josh...helpfull and patient as always!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              597 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              343 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              556 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              555 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X