• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help plz...Three day low trailing stop

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

    Help plz...Three day low trailing stop

    I have tried dozen of times to create a strategy where long stop exit will be triggered when it touches the previous 3-day low. I would be grateful if someone could help.

    #2
    Hello JT1230,

    You can use Lows, which will hold an array of DataSeries objects holding historical bar low prices. A DataSeries object is added to this array when calling the Add() method in a Custom Strategy. Add a Daily Data Series to your chart so you reference daily bars.
    I have included the Lows Help Guide to assist you further.

    Code:
    Add(PeriodType.Day, 1); protected override void OnBarUpdate() { stopPrice = Low[ 0]; if(Low[ 0] <= LowestBar(Lows[ 1], 3)) { ExitLongStop(stopPrice); } }



    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      What does it meant by [ the name "ExitLongStop" does not exist in the current context] ?

      Comment


        #4
        Hello JT1230,


        Could you please reply with your script attached, so that I may investigate this behavior further?


        You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.



        You could post the script to your forum reply, or send an email to platformsupport [at] ninjatrader [dot] com with the script as an attachment. In the email please include a link to this forum thread.
        Shawn B.NinjaTrader Customer Service

        Comment


          #5
          I think the error appears because "ExitLongStop" is for NT7 and "ExitLongStopMarket" is for NT8, please correct me if I'm wrong. And I cant seem to be able to do a backtest using this strategy

          Comment


            #6
            Hello JT1230,
            This is correct, if you are in NT8 you would need to use ExitLongStopMarket(). If you are still unable to backtest your strategy, use the steps outlined in my previous post to send us your script.
            Shawn B.NinjaTrader Customer Service

            Comment


              #7
              Is it possible for us to make three day high-low trailing stop instead of stick, percent and price?

              Comment


                #8
                Hello,
                Hello,


                To do this, set your SetTrailStop() value to the three day low.


                Code:
                protectedoverridevoid Initialize() { Add(PeriodType.Day, 1); }
                protectedoverride void OnBarUpdate() {
                stopPrice = Low[ 0]; if(Low[ 0] <= LowestBar(Lows[ 1], 3)) { SetTrailStop( "" , CalculationMode.Price, stopPrice, false ); }

                I have included the SetTrailStop() Help Guide to assist you further.
                Shawn B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by imalil, Today, 04:28 PM
                0 responses
                2 views
                0 likes
                Last Post imalil
                by imalil
                 
                Started by bboyle1234, Today, 03:47 PM
                0 responses
                1 view
                0 likes
                Last Post bboyle1234  
                Started by caveat_lector, Today, 03:46 PM
                0 responses
                3 views
                0 likes
                Last Post caveat_lector  
                Started by fx.practic, Today, 03:29 PM
                0 responses
                3 views
                0 likes
                Last Post fx.practic  
                Started by Captain Jack, Today, 02:53 PM
                0 responses
                5 views
                0 likes
                Last Post Captain Jack  
                Working...
                X