Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SwingArm Conversion to NT8

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

    SwingArm Conversion to NT8

    Dear Support,

    Just curious if the following TOS SwingArm indicator has been converted to NT 8. This is basically the ATRTrailingStop indicator with added fib levels for measuring retracements.

    Thanks.

    Code:
    SWINGARM CODE - Update 5/27/2020
    SWINGARM CHART STUDY CODE    Collapse
    SWINGARM CHART STUDY
    CODE STARTS BELOW:
    
    # Original Code From: TD Ameritrade IP Company, Inc. (c) 2009-2020
    # Original StudyName: ATRTrailingStop
    # Type: Study
    
    #-----------------------------------
    #-----------------------------------
    # BUY & SELL CONFIRMATION LABELS ARE CREATED BY THE HULL MOVING AVERAGE TURNING POINTS STUDY AND MUST BE IN AGREEMENT WITH SWINGARM SUPPORT OR RESISTANCE ZONES TO BE VALID. (UseThinkScript.com by mashume - Upper Study). MY UPDATED CODE INCLUDES THE BUY / SELL BUBBLES. THE SETTINGS ARE: 1 MIN: 255 PERIOD; 5 MIN: 255 PERIOD; 4 HOUR 255 PERIOD, DAILY 75 PERIOD. "This settings are for futures"
    #-----------------------------------
    #-----------------------------------
    
    input trailType = {default modified, unmodified};
    input ATRPeriod = 28;
    input ATRFactor = 5;
    input firstTrade = {default long, short};
    input averageType = AverageType.WILDERS;
    
    input fib1Level = 61.8;
    input fib2Level = 78.6;
    input fib3Level = 88.6;
    
    Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);
    
    def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
    def HRef = if low <= high[1]
    then high - close[1]
    else (high - close[1]) - 0.5 * (low - high[1]);
    def LRef = if high >= low[1]
    then close[1] - low
    else (close[1] - low) - 0.5 * (low[1] - high);
    
    def trueRange;
    switch (trailType) {
    case modified:
    trueRange = Max(HiLo, Max(HRef, LRef));
    case unmodified:
    trueRange = TrueRange(high, close, low);
    }
    def loss = ATRFactor * MovingAverage(averageType, trueRange, ATRPeriod);
    
    def state = {default init, long, short};
    def trail;
    switch (state[1]) {
    case init:
    if (!IsNaN(loss)) {
    switch (firstTrade) {
    case long:
    state = state.long;
    trail = close - loss;
    case short:
    state = state.short;
    trail = close + loss;
    }
    } else {
    state = state.init;
    trail = Double.NaN;
    }
    case long:
    if (close > trail[1]) {
    state = state.long;
    trail = Max(trail[1], close - loss);
    } else {
    state = state.short;
    trail = close + loss;
    }
    case short:
    if (close < trail[1]) {
    state = state.short;
    trail = Min(trail[1], close + loss);
    } else {
    state = state.long;
    trail = close - loss;
    }
    }
    
    def BuySignal = Crosses(state == state.long, 0, CrossingDirection.ABOVE);
    def SellSignal = Crosses(state == state.short, 0, CrossingDirection.ABOVE);
    
    def ex = if BuySignal then high else if SellSignal then low else if state == state.long then Max(ex[1], high) else if state == state.short then Min(ex[1], low) else ex[1];
    
    plot TrailingStop = trail;
    
    TrailingStop.SetPaintingStrategy(PaintingStrategy.POINTS);
    TrailingStop.DefineColor("Long", Color.GREEN);
    TrailingStop.DefineColor("Short", Color.RED);
    TrailingStop.AssignValueColor(if state == state.long
    then TrailingStop.Color("Long")
    else TrailingStop.Color("Short"));
    
    plot Extremum = ex;
    Extremum.SetPaintingStrategy(PaintingStrategy.POINTS);
    Extremum.DefineColor("HH", Color.GREEN);
    Extremum.DefineColor("LL", Color.RED);
    Extremum.AssignValueColor(if state == state.long
    then Extremum.Color("HH")
    else Extremum.Color("LL"));
    Extremum.Hide();
    
    def f1 = ex + (trail - ex) * fib1Level / 100;
    def f2 = ex + (trail - ex) * fib2Level / 100;
    def f3 = ex + (trail - ex) * fib3Level / 100;
    def l100 = trail + 0;
    
    plot Fib1 = f1;
    Fib1.SetPaintingStrategy(PaintingStrategy.POINTS);
    Fib1.SetDefaultColor(Color.BLACK);
    Fib1.Hide();
    
    plot Fib2 = f2;
    Fib2.SetPaintingStrategy(PaintingStrategy.POINTS);
    Fib2.SetDefaultColor(Color.BLACK);
    Fib2.Hide();
    
    plot Fib3 = f3;
    Fib3.SetPaintingStrategy(PaintingStrategy.POINTS);
    Fib3.SetDefaultColor(Color.BLACK);
    Fib3.Hide();
    
    AddCloud(f1, f2, Color.LIGHT_GREEN, Color.LIGHT_RED, no);
    AddCloud(f2, f3, Color.GREEN, Color.RED, no);
    AddCloud(f3, l100, Color.DARK_GREEN, Color.DARK_RED, no);
    
    def l1 = state[1] == state.long and close crosses below f1[1];
    def l2 = state[1] == state.long and close crosses below f2[1];
    def l3 = state[1] == state.long and close crosses below f3[1];
    def s1 = state[1] == state.short and close crosses above f1[1];
    def s2 = state[1] == state.short and close crosses above f2[1];
    def s3 = state[1] == state.short and close crosses above f3[1];
    
    def atr = Average(TrueRange(high, close, low), 14);
    
    plot LS1 = if l1 then low - atr else Double.NaN;
    plot LS2 = if l2 then low - 1.5 * atr else Double.NaN;
    plot LS3 = if l3 then low - 2 * atr else Double.NaN;
    plot SS1 = if s1 then high + atr else Double.NaN;
    plot SS2 = if s2 then high + 1.5 * atr else Double.NaN;
    plot SS3 = if s3 then high + 2 * atr else Double.NaN;
    
    LS1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
    LS1.SetDefaultColor(Color.GREEN);
    LS1.SetLineWeight(1);
    LS1.Hide();
    LS2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
    LS2.SetDefaultColor(Color.GREEN);
    LS2.SetLineWeight(1);
    LS2.Hide();
    LS3.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
    LS3.SetDefaultColor(Color.GREEN);
    LS3.SetLineWeight(1);
    LS3.Hide();
    
    SS1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
    SS1.SetDefaultColor(Color.RED);
    SS1.SetLineWeight(1);
    SS1.Hide();
    SS2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
    SS2.SetDefaultColor(Color.RED);
    SS2.SetLineWeight(1);
    SS2.Hide();
    SS3.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
    SS3.SetDefaultColor(Color.RED);
    SS3.SetLineWeight(1);
    SS3.Hide();
    
    Alert(l1, "Price crossed below Fib1 level in long trend", Alert.BAR, Sound.Bell);
    Alert(l2, "Price crossed below Fib2 level in long trend", Alert.BAR, Sound.Bell);
    Alert(l3, "Price crossed below Fib3 level in long trend", Alert.BAR, Sound.Bell);
    Alert(s1, "Price crossed above Fib1 level in short trend", Alert.BAR, Sound.Bell);
    Alert(s2, "Price crossed above Fib2 level in short trend", Alert.BAR, Sound.Bell);
    Alert(s3, "Price crossed above Fib3 level in short trend", Alert.BAR, Sound.Bell);
    
    # *******************************************************
    # DAY TRADING SETTINGS USING 1 AND 5 MINUTE CHARTS
    
    AddLabel(yes," DAY TRADING STRATEGY : ",color.WHITE);
    AddLabel(yes, if ohlc4 > TrailingStop then "BUY MAJOR SUPPORT. BUY SWINGARM ZONES 2, 3 or 4" else "SELL MAJOR RESISTANCE. SELL SWINGARM BREAKDOWN ZONES 2, 3 or 4", if ohlc4 > TrailingStop then Color.GREEN else Color.Red);

    #2
    Hello aligator,

    Thank you for your post.

    I did a quick check on the User App Share but didn't see one by this name. I'll leave this open in case another user may have converted this particular indicator and would be willing to share that with you, or if they may be able to convert the script for you.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Did this ever get converted?

      Comment


        #4
        Yes there is a swing arms for NT8. Go to Swing Arms web site and download. https://blackflagfuturestrading.com/why-blackflag/

        Comment


          #5
          its not as nice as the one for TOS

          Comment


            #6
            Originally posted by ttom999 View Post
            Yes there is a swing arms for NT8. Go to Swing Arms web site and download. https://blackflagfuturestrading.com/why-blackflag/
            I put that into NT8 editor and there are errors in the code.

            Comment


              #7
              Originally posted by Delerium View Post

              I put that into NT8 editor and there are errors in the code.
              That likley was already an error that you had and then added this that caused the error to arise. Can you provide a screen shot of your error log?

              Comment


                #8
                Originally posted by LoganJKTrader View Post

                That likley was already an error that you had and then added this that caused the error to arise. Can you provide a screen shot of your error log?
                You know what, I was having issues because of how I was using the editor to bring it into NT8. A friend showed me how to do it properly and I had no problems compiling the code.

                It works fine. Thanks for your reply.

                Comment


                  #9
                  Originally posted by RivertonUT
                  I cant figure out how to add the code. I am in NinjaScript Editor but I don't see a way to add the code.
                  Open NinjaScript Editor. Look on the right panel where the folder tree of scripts are listed, left click on Indicators folder, choose create new indicator, in the next window that opens click generate at bottom of the window. A new script will be created called MyIndicatorN°.cs. Copy & paste the new code to the new indie. Recompile (F5) to save the changes, copy the indies name atop the namespace & close the tab In NinjaScript Editor, & rename the new file as indie name. Now load onto a chart it will be saved to your documents\...\..\bin\custom\indicators\ folder.
                  Last edited by LoganJKTrader; 01-21-2023, 07:00 PM.

                  Comment


                    #10
                    thank you for the quick reply. much appreciated, this indicator seems very similar to the "Half-Back" indicator on the futures.IO forum.
                    Last edited by RivertonUT; 01-21-2023, 07:23 PM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    638 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    366 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    107 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    569 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    572 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X