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

Swing Point High/Lows, Convert from TS

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

    Swing Point High/Lows, Convert from TS

    can anyone help with converting this code from tradestation into ninja trader. it is very close the the indicator already in ninja called "swing" but the conditions are a bit different. also it plots different. i have it plotting a single dot in TS instead of the dotted lines that the "swing" indicator plots. the problem with the "swing indicator" is that it plots too many swing highs/lows. i would greatly appreciate the help in converting over. also i am attaching a photo of how it appears in tradestation.


    {Confirmation Entries
    This plots swing highs/lows with a strength of 2 bars on each side, on the condition that there is a
    close above/below the high/low the bar after the said swing bar.
    }

    inputs:
    buyColor(Green),
    sellColor(Red);
    variables:
    highBarsAgo(1),
    possibleHighBarsAgo(1),
    possibleHigh(-2),
    hightoBeat(-1),
    barsSincePaint(1),
    lowBarsAgo(1),
    possibleLowBarsAgo(1),
    possibleLow(10000001),
    lowtoBeat(10000000),
    triggerPriceSell(-1),
    triggerPriceBuy(1000000),
    trend(1),
    _UP(1),
    _DOWN(-1),
    _ON(1),
    _OFF(-1);


    //************************************************** *
    //****** Find and plot the highest swing high *******
    //************************************************** *

    if trend = _UP then begin
    if swingHighBar(1,H,2,barsSincePaint+2) > -1 then begin
    possibleHighBarsAgo = swingHighBar(1,H,2,barsSincePaint+2);
    possibleHigh = H[possibleHighBarsAgo];
    end;

    if possibleHigh >= hightoBeat then begin
    highBarsAgo = possibleHighBarsAgo;
    hightoBeat = possibleHigh;
    triggerPriceSell = L[HighBarsAgo - 1];
    end;

    if C < triggerPriceSell and
    highest(high,highBarsAgo) < hightoBeat then begin
    plot1[highBarsAgo](H[highBarsAgo],"",sellColor);
    alert("Scalper Sell");
    trend = _DOWN;
    barsSincePaint = highBarsAgo-1;
    hightoBeat = -1;
    lowtoBeat = 10000000;
    triggerPriceBuy = 10000000;
    triggerPriceSell = -1;
    highBarsAgo = 1;
    possibleHigh = -2;
    end;

    end;

    //************************************************** *
    //****** Find and plot the lowest swing low *********
    //************************************************** *

    if trend = _DOWN then begin
    if swingLowBar(1,L,2,barsSincePaint+2) > -1 then begin
    possibleLowBarsAgo = swingLowBar(1,L,2,barsSincePaint+2);
    possibleLow = L[possibleLowBarsAgo];
    end;

    if possibleLow <= lowtoBeat then begin
    lowBarsAgo = possibleLowBarsAgo;
    lowtoBeat = possibleLow;
    triggerPriceBuy = H[LowBarsAgo - 1];
    end;

    if C > triggerPriceBuy and
    lowest(L,lowBarsAgo) > lowtoBeat then begin
    plot1[lowBarsAgo](L[lowBarsAgo],"",buyColor);
    alert("Scalper Buy");
    trend = _UP;
    barsSincePaint = lowBarsAgo-1;
    possibleLow = 10000001;
    lowtoBeat = 10000000;
    hightoBeat = -1;
    triggerPriceBuy = 10000000;
    triggerPriceSell = -1;
    lowBarsAgo = 1;
    end;

    end;

    barsSincePaint = barsSincePaint+1;
    if trend = _UP then highBarsAgo = highBarsAgo + 1;
    if trend = _DOWN then lowBarsAgo = lowBarsAgo + 1;
    Attached Files

    #2
    Hey, did you ever accomplish the conversion? I'm currently looking for the same modification.

    Comment


      #3
      Originally posted by samironthemove View Post
      Hey, did you ever accomplish the conversion? I'm currently looking for the same modification.
      Why; when NT already has an indicator that does the same thing? It is called the Swing indicator. You can even set the strength that you desire, instead of it being hardcoded to a value of 2.

      Comment


        #4
        The thing I don't like about the NT Swing is that it plots multiple dots. I would like to see one black dot at each swing only. I'm also not sure what the Strength parameter is for. Could you explain? I have no coding knowledge obviously but is it possible to modify the NT Swing to what I have in mind? Thank you

        Comment


          #5
          Originally posted by samironthemove View Post
          The thing I don't like about the NT Swing is that it plots multiple dots. I would like to see one black dot at each swing only. I'm also not sure what the Strength parameter is for. Could you explain? I have no coding knowledge obviously but is it possible to modify the NT Swing to what I have in mind? Thank you
          Per the original poster: "This plots swing highs/lows with a strength of 2 bars on each side, on the condition that there is a close above/below the high/low the bar after the said swing bar." So strength is the number of bars on each side of the swing, the number used to qualify the swing. If you want a strength of 2, then change the parameter to read so.

          It should be possible to edit the existing indicator to do that which you want. Or you can seek to acquire this one. Your choice. ref: http://ninjatrader.com/support/forum...57&postcount=2

          Comment


            #6
            Originally posted by samironthemove View Post
            The thing I don't like about the NT Swing is that it plots multiple dots. I would like to see one black dot at each swing only. I'm also not sure what the Strength parameter is for. Could you explain? I have no coding knowledge obviously but is it possible to modify the NT Swing to what I have in mind? Thank you
            You are correct samironthemove. Regardless of how you change the value for the Strength, as suggested by koganam, you would still see repeated highs and lows, depending on the time frame and strength value you are using.

            I think perhaps you can use the ZigZigUTC_v5 indicator. It has an extra criteria in addition to the strength (number of bars before and after the swing high or low) that requires the last bar forming the swing to close below or above of the swing bar, respectively. This filter eliminates some of the extra "dots."

            Cheers!

            Comment


              #7
              Originally posted by aligator
              Hi koganam,

              The logic for NT Swing indicator is wrong. See my response to your post here:

              http://ninjatrader.com/support/forum...279#post443279
              You must not have looked at the link that I posted in response to your post, and in this thread. That indicator, optionally, does as you say. Heck, you can even if you choose, see all the points that got negated if you want (they are shown in a different color, which you can specify).

              Comment


                #8
                Originally posted by samironthemove View Post
                The thing I don't like about the NT Swing is that it plots multiple dots. I would like to see one black dot at each swing only. I'm also not sure what the Strength parameter is for. Could you explain? I have no coding knowledge obviously but is it possible to modify the NT Swing to what I have in mind? Thank you
                samironthemove,

                Can you please post a screenshot of your TS indicator applied to a most recent 5 minutes (or whatever) chart of any of the futures, ES, NQ, CL, etc. so that we can confirm a conversion matches your code? Make sure the instrument, date, period, etc. and time and price axis are shown on your screenshot.

                Thanks.

                On a second look at ZigZagUTC_5, I beleive it is what you want. If you use Strength of 2, it is the same as strength of 5 on NT Swing indicator and does not repeat highs or lows.

                Cheers!
                Last edited by aligator; 01-10-2016, 05:24 PM.

                Comment


                  #9
                  Originally posted by koganam View Post
                  You must not have looked at the link that I posted in response to your post, and in this thread. That indicator, optionally, does as you say. Heck, you can even if you choose, see all the points that got negated if you want (they are shown in a different color, which you can specify).
                  You are correct, I did not. I deleted that post. But to be clear, the logic for NT Swing is not for a true swing.

                  Chreers!

                  Comment


                    #10
                    alligator, I found the ZigZagUTG and when I set it to only plot the dots it is exactly what I was looking for Thank you!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Kaledus, Today, 01:29 PM
                    3 responses
                    9 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by frankthearm, Yesterday, 09:08 AM
                    14 responses
                    47 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by gentlebenthebear, Today, 01:30 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post gentlebenthebear  
                    Started by PaulMohn, Today, 12:36 PM
                    2 responses
                    17 views
                    0 likes
                    Last Post PaulMohn  
                    Started by Conceptzx, 10-11-2022, 06:38 AM
                    2 responses
                    56 views
                    0 likes
                    Last Post PhillT
                    by PhillT
                     
                    Working...
                    X