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

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
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              26 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, Yesterday, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              191 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,230 views
              0 likes
              Last Post xiinteractive  
              Working...
              X