Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trailing stop

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

    trailing stop

    hi, i have an indicator question, it's pretty basic but was wondering if someone can help me with it

    it's a stop based on a 10 period standard deviation times 1.382 or .618 above or below the most recent high or low as the exit.

    does anyone know how to do this or try? i think i have the code but it was for tradestation, might that help?

    #2
    market123, welcome to our forums! You would need to custom code this in our NinjaScript, as example and start you can take a look at the 'ATR Trailing Stop' and "Average True Range Trailing Stop' from the sharing - http://www.ninjatrader-support2.com/vb/local_links.php

    For tutorials on indicator coding please check into this - http://www.ninjatrader-support.com/H...verview18.html

    Comment


      #3
      Hi Bertrand,

      I don't know how to custom code that's why I was hoping someone could help me with that in these forums. Any other sugesstions?

      Comment


        #4
        You can of course post the code you have from TradeStation and see if someone steps in...for professional custom coding services, you can contract those consultants - http://www.ninjatrader.com/webnew/pa...injaScript.htm

        Comment


          #5
          ok, thanks, I'll post it here? Or should I post in another forum?

          Comment


            #6
            Sure, this is the right place here.

            Comment


              #7
              This system just uses a 14 period %R and Price action to determine when to enter the market and then a trailing stop based on a 10 period standard deviation times 1.382 or .618 above or below the most recent high or low as the exit.

              I'm not looking for the %R calculation or indicator, just the trailing stop part of the code converted to Ninja Trader...Any help would be greatly appreciated.

              [LegacyColorValue = true];
              inputs: Length(10), Length1(14);
              Vars: Trend(1),
              PerR( 0 ),
              StDev( 0 ),
              LastBar( 0 ),
              TrStop( 0 );
              var:
              alertTextID(-1);
              if barnumber = 1 then begin
              alertTextID = Text_New(date,time,0,"RSI");
              end;

              StDev = StdDev(C,length1);
              PerR = PercentR(length);
              If (PerR >= 70 and PerR[1] < 70) and Trend < 1 and Close > TrStop then
              Begin
              SetPlotColor(1,Blue);
              Plot1(Low - tick,"Signal");
              TrStop = L - StDev*1.382;
              Trend = 1;
              LastBar = BarNumber;if Text_GetTime(alertTextID) <> time then begin
              text_setLocation(alertTextID, date, time, 0);
              alert("PercentRLong");end;
              End;
              If (PerR <= 30 and PerR[1] > 30) and Trend > -1 and Close < TrStop then
              Begin
              SetPlotColor(1,Red);
              Plot1(High + tick,"Signal");
              TrStop = High + StDev*1.382;
              Trend = -1;
              LastBar = BarNumber;if Text_GetTime(alertTextID) <> time then begin
              text_setLocation(alertTextID, date, time, 0);
              alert("PercentRShort");end;
              End;
              If Trend = 1 then
              Begin
              If LastBar < BarNumber then
              Begin
              If TrStop = 0 then TrStop = Close;
              If Close > Close[1] then TrStop = Low - StDev * 1.382;
              If Low - High[1] > StDev then TrStop = Low - StDev * 0.618;
              If TrStop < TrStop[1] then TrStop = TrStop[1];
              End;
              Plot2(TrStop,"Stop");
              SetPlotColor(2,White);
              End;
              If Trend = -1 then
              Begin
              If LastBar < BarNumber then
              Begin
              If TrStop = 0 then TrStop = Close;
              If Close < Close[1] then TrStop = High + StDev * 1.382;
              If Low[1] - High > StDev then TrStop = High + StDev * 1.382;
              If TrStop > TrStop[1] then TrStop = TrStop[1];
              End;

              Plot2(TrStop,"Stop");
              SetPlotColor(2,Yellow);
              End;
              If PercentR(14) > 70 then
              Begin
              SetPlotColor(3,Blue);
              SetPlotColor(4,Blue);
              Plot3(High,"TREND");
              Plot4(Low,"TREND");

              End
              Else If PercentR(14) < 30 then
              Begin
              SetPlotColor(3,Red);
              SetPlotColor(4,Red);
              Plot3(High,"TREND");
              Plot4(Low,"TREND");

              End
              Else If PercentR(14) < 70 and PercentR(9) > 30 then
              Begin
              SetPlotColor(3,green);
              SetPlotColor(4,green);
              Plot3(High,"TREND");
              Plot4(Low,"TREND");
              End;

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              601 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              347 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
              559 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              558 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X