Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TTM_Scalper Alert, Ninjaprice action and Swing

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

    TTM_Scalper Alert, Ninjaprice action and Swing

    I loved using the scalper arrows in Thinkorswim, they work great on my tick charts. I managed to find similar indicators in the ninja trader ecosystem but found that Swing uses an ATR input, this causes a delay that I find frustrating while scalping on these tick charts.

    I do not know how to code and I really would like have Ninja print the swing lows/highs on my chart without using ATR, just the close of the previous bars. I cant even find a similar indicator that I could purchase.

    Thinkorswim defines this as follows
    The TTM_ScalperAlert comprises two plots, Pivot High and Pivot Low. Pivot High is shown as an arrow above the first bar in a series of 3 lower Closes (Sell signal). Pivot Low is shown as an arrow under the first bar in a series of 3 higher Closes (Buy signal).

    Could this be coded? would someone be able to help me do this? I have seen NINJAPRICE action which is great but that too uses ATR. "price action swing" found on futures.io also doesn't fit my needs. Any help would be greatly appreciated.

    #2
    Hello Perr0Grande,

    If you have looked over the user app share files and nothing matches you would likely need to hire a developer to create the item for you. You can contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.

    Comment


      #3
      I would love a list of affiliates. It would be nice to streamline all my charts to one platform. I reached out to simpler trading, and they aren't allowed to use ninja trader license keys. thank you!

      Comment


        #4
        This indicator is pretty lagging, how do you use, if you don't mind?

        PHP Code:
        #region Using declarations
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Gui;
        using NinjaTrader.Gui.Chart;
        using NinjaTrader.Gui.SuperDom;
        using NinjaTrader.Gui.Tools;
        using NinjaTrader.Data;
        using NinjaTrader.NinjaScript;
        using NinjaTrader.Core.FloatingPoint;
        using NinjaTrader.NinjaScript.DrawingTools;
        #endregion
        
        
        
        
        
        //This namespace holds Indicators in this folder and is required. Do not change it.
        namespace NinjaTrader.NinjaScript.Indicators
        {
            public class TTM_ScalperAlert : Indicator
            {
                private List<string> arrowTags = new List<string>();
                private System.Media.SoundPlayer player;
                private int consecutiveHigherValues = 0;
                private int consecutiveLowerValues = 0;
                private int signalBarIndex = 0;
                
                protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        Description                 = @"TTM Scalper Alert shows arrows on pivot highs and lows based on consecutive higher/lower values";
                        Name                        = "TTM_ScalperAlert";
                        Calculate                   = Calculate.OnBarClose;
                        IsOverlay                   = true;
                        DisplayInDataBox            = false;
                        DrawOnPricePanel            = true;
                        DrawHorizontalGridLines     = true;
                        DrawVerticalGridLines       = true;
                        PaintPriceMarkers           = true;
                        ScaleJustification          = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                        IsSuspendedWhileInactive    = true;
                        
                        // Default input parameters
                        RequiredConsecutiveValues   = 3;
                        MaxArrows                   = 50;
                        PlaySoundOnAlert            = false;
                        PivotHighColor              = Colors.Red;
                        PivotLowColor               = Colors.Green;
                        PriceComparisonType         = ComparisonTypes.Close;
                    }
                    else if (State == State.Configure)
                    {
                        // Initialize sound player if needed
                        if (PlaySoundOnAlert)
                            player = new System.Media.SoundPlayer(NinjaTrader.Core.Globals.InstallDir + @"\sounds\Alert1.wav");
                    }
                    else if (State == State.Terminated)
                    {
                        // Clean up resources
                        foreach (string tag in arrowTags)
                        {
                            if (!string.IsNullOrEmpty(tag))
                                RemoveDrawObject(tag);
                        }
                        arrowTags.Clear();
                        
                        if (player != null)
                        {
                            player.Dispose();
                            player = null;
                        }
                    }
                }
        
                protected override void OnBarUpdate()
                {
                    // We need at least 2 bars to start comparison
                    if (CurrentBar < 1)
                        return;
                    
                    // Get the values to compare based on user selection
                    double currentValue = GetComparisonValue(0);
                    double previousValue = GetComparisonValue(1);
                    
                    // Compare values
                    if (currentValue > previousValue)
                    {
                        // Higher value - increment counter
                        consecutiveHigherValues++;
                        
                        // Store the signal bar index when we're on the first higher value
                        if (consecutiveHigherValues == 1)
                            signalBarIndex = CurrentBar;
                        
                        // Reset counter for lower values
                        consecutiveLowerValues = 0;
                        
                        // Check if we've reached the required number of consecutive higher values
                        if (consecutiveHigherValues == RequiredConsecutiveValues)
                        {
                            // Buy signal - Pivot Low
                            int firstBarOffset = CurrentBar - signalBarIndex;
                            
                            // Create an arrow at the first bar of the sequence
                            string tag = "PivotLow_" + Time[firstBarOffset].Ticks;
                            Draw.ArrowUp(this, tag, true, firstBarOffset, Low[firstBarOffset] - TickSize,
                                    new SolidColorBrush(PivotLowColor));
                            
                            // Add to our tracking list
                            arrowTags.Add(tag);
                            
                            // Play sound if enabled
                            if (PlaySoundOnAlert && player != null)
                                player.Play();
                            
                            // Manage arrow limit
                            ManageArrowLimit();
                        }
                    }
                    else if (currentValue < previousValue)
                    {
                        // Lower value - increment counter
                        consecutiveLowerValues++;
                        
                        // Store the signal bar index when we're on the first lower value
                        if (consecutiveLowerValues == 1)
                            signalBarIndex = CurrentBar;
                        
                        // Reset counter for higher values
                        consecutiveHigherValues = 0;
                        
                        // Check if we've reached the required number of consecutive lower values
                        if (consecutiveLowerValues == RequiredConsecutiveValues)
                        {
                            // Sell signal - Pivot High
                            int firstBarOffset = CurrentBar - signalBarIndex;
                            
                            // Create an arrow at the first bar of the sequence
                            string tag = "PivotHigh_" + Time[firstBarOffset].Ticks;
                            Draw.ArrowDown(this, tag, true, firstBarOffset, High[firstBarOffset] + TickSize,
                                    new SolidColorBrush(PivotHighColor));
                            
                            // Add to our tracking list
                            arrowTags.Add(tag);
                            
                            // Play sound if enabled
                            if (PlaySoundOnAlert && player != null)
                                player.Play();
                            
                            // Manage arrow limit
                            ManageArrowLimit();
                        }
                    }
                    else
                    {
                        // Equal values - reset both counters as the sequence is broken
                        consecutiveHigherValues = 0;
                        consecutiveLowerValues = 0;
                    }
                }
                
                // Get the comparison value based on user selection
                private double GetComparisonValue(int barsAgo)
                {
                    switch (PriceComparisonType)
                    {
                        case ComparisonTypes.Close:
                            return Close[barsAgo];
                        case ComparisonTypes.High:
                            return High[barsAgo];
                        case ComparisonTypes.Low:
                            return Low[barsAgo];
                        default:
                            return Close[barsAgo]; // Default to Close
                    }
                }
                
                private void ManageArrowLimit()
                {
                    // Check if we need to remove old arrows
                    if (arrowTags.Count > MaxArrows)
                    {
                        // Remove oldest arrows until we're within limit
                        while (arrowTags.Count > MaxArrows)
                        {
                            string oldestTag = arrowTags[0];
                            RemoveDrawObject(oldestTag);
                            arrowTags.RemoveAt(0);
                        }
                    }
                }
        
                #region Properties
                [Display(Name = "Required Consecutive Values", Description = "Number of consecutive higher/lower values required for signal", GroupName = "Parameters", Order = 1)]
                [Range(2, 10)]
                public int RequiredConsecutiveValues { get; set; }
                
                [Display(Name = "Maximum Arrows", Description = "Maximum number of arrows to display on chart", GroupName = "Parameters", Order = 2)]
                [Range(1, 1000)]
                public int MaxArrows { get; set; }
                
                [Display(Name = "Price Comparison Type", Description = "Choose which price value to use for comparison", GroupName = "Parameters", Order = 3)]
                [TypeConverter(typeof(ComparisonTypesTypeConverter))]
                public ComparisonTypes PriceComparisonType { get; set; }
                
                [Display(Name = "Play Sound on Alert", Description = "Play sound when new signal is generated", GroupName = "Parameters", Order = 4)]
                public bool PlaySoundOnAlert { get; set; }
                
                [Display(Name = "Pivot High Color", Description = "Color for sell signals", GroupName = "Visual", Order = 1)]
                [XmlIgnore]
                public Color PivotHighColor { get; set; }
        
                [Browsable(false)]
                public string PivotHighColorSerialize
                {
                    get { return Serialize.BrushToString(new SolidColorBrush(PivotHighColor)); }
                    set { PivotHighColor = ((SolidColorBrush)Serialize.StringToBrush(value)).Color; }
                }
                
                [Display(Name = "Pivot Low Color", Description = "Color for buy signals", GroupName = "Visual", Order = 2)]
                [XmlIgnore]
                public Color PivotLowColor { get; set; }
        
                [Browsable(false)]
                public string PivotLowColorSerialize
                {
                    get { return Serialize.BrushToString(new SolidColorBrush(PivotLowColor)); }
                    set { PivotLowColor = ((SolidColorBrush)Serialize.StringToBrush(value)).Color; }
                }
                #endregion
                
                #region Enum Definitions
                
                // Enum for price comparison types
                public enum ComparisonTypes
                {
                    Close,
                    High,
                    Low
                }
                
                // Type converter for ComparisonTypes
                public class ComparisonTypesTypeConverter : TypeConverter
                {
                    public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
                    {
                        return true;
                    }
        
                    public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
                    {
                        return new StandardValuesCollection(new[]
                        {
                            ComparisonTypes.Close,
                            ComparisonTypes.High,
                            ComparisonTypes.Low
                        });
                    }
        
                    public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
                    {
                        return true;
                    }
                }
                #endregion
            }
        }&#8203;
        
        &#8203; 
        
        Last edited by MiCe1999; 04-29-2025, 05:55 PM.

        Comment


          #5
          Wow is that the code? So i do all my entries on the DOM using vol profile and limit order clusters. If im trading MNQ i will use 1600 tick chart and use basic price swing high and lows for emergency stops. If i see hi/lo structure change i will start to get out of the trade using a couple different methods. I'm also looking at some Oscillators and a couple footprints. I like how the arrows show me basic structure while i focus on the dom. Very fast scalping.

          Comment


            #6
            Cool. Yes, the code is based on your description and has a few more options which I though would be useful: sets a limit to max number of arrows (too many arrows slow down the charts), a choice to detect consecutive lows, highs or close and sequence can be from 2 to 10 (might be good for renko or range type).

            Are arrows supposed to alternate or mark every consecutive pattern?

            Last edited by MiCe1999; 04-29-2025, 07:56 PM.

            Comment


              #7
              EDIT: updated indicator does both and loads much faster by skipping most historical bars and shows diff between consecutive lows and highs:
              Attached Files
              Last edited by MiCe1999; 04-30-2025, 07:34 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by abelsheila, 05-14-2025, 07:38 PM
              2 responses
              34 views
              0 likes
              Last Post hglover945  
              Started by nailz420, 05-14-2025, 09:14 AM
              1 response
              73 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
              0 responses
              353 views
              1 like
              Last Post NinjaTrader_Brett  
              Started by domjabs, 05-12-2025, 01:55 PM
              2 responses
              67 views
              0 likes
              Last Post domjabs
              by domjabs
               
              Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
              1 response
              87 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X