Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

jphillips9

Does Anyone have the TTM Scalper Code for Esignal???

Recommended Posts

Welcome to the forum. This indicator looks better than it actually is. :)

It actually plots the scalper bar usually about 3 bars later, retrospectively. That makes it hard to use in any strategy (and hard to program if your platform doesn't support such plotting).

 

Here is the C# code from NT. Perhaps you can adapt it for Esignal.

http://www.ninjatrader-support.com/vb/showthread.php?t=2966&page=4&highlight=scalper

// Scalper v0.1 by Gumphrie, inspired by John Carter's TTMScalper
// v0.2 - removed the period parameter as pretty much useless and changed all the high/low calaculations to be one bar ahead
// v0.3 - fixed possible plotting error
// v0.4 - additional check for highest and lowest
// v0.5 - reduced cpu usage & added trigger bar alert arrows

#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Text;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.Design;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
   /// <summary>
   /// Scalper
   /// </summary>
   [Description("Scalper")]
   [Gui.Design.DisplayName("Scalper")]
   public class Scalper : Indicator
   {
       #region Variables
           private SolidBrush ScalpBarBrush = new SolidBrush(Color.Lavender);

		private int counter = 0;
		private int ExtremeBar = 0;
	    private int lastBar=0;

		private bool HighPainted = false;
		private bool LowPainted = true;
		private bool showTriggers = false;
		private double ExtremeBarHigh = 0;
           private double TriggerBarLow = 0;
		private double ExtremeBarLow = 0;
           private double TriggerBarHigh = 0;
		private int TriggerBarLowNo=0;
		private int TriggerBarHighNo=0;


		private DataSeries  scalpSeries;
		private DataSeries 	open;
		private DataSeries 	high;
		private DataSeries 	low;
		private DataSeries 	close;
       #endregion



       /// <summary>
       /// This method is used to configure the indicator and is called once before any bar data is loaded.
       /// </summary>
       protected override void Initialize()
       {
       	Overlay = true;

		scalpSeries = new DataSeries(this);

		open  = new DataSeries(this);
		high  = new DataSeries(this);
		low   = new DataSeries(this);
		close = new DataSeries(this);

       	CalculateOnBarClose = true;
       }

       /// <summary>
       /// Called on each bar update event (incoming tick)
       /// </summary>
       protected override void OnBarUpdate()
       {

		open.Set(Open[0]);
		high.Set(High[0]);
		low.Set(Low[0]);
		close.Set(Close[0]);

           if (CurrentBar <= 4)
           {
               scalpSeries.Set(0);
           }
           else
           {

			//Up 
			if (HighPainted==false)
			{

           		if ((High[1] < High[2]) && (0==ExtremeBar))
				//if ((High[1] < High[2]) && (2 == Bars.HighestBar(3)) && (0==ExtremeBar)) 
				{
               		ExtremeBar = 2; 
               		ExtremeBarHigh = High[2]; 
               		TriggerBarLow = Low[1]; 
					TriggerBarLowNo = CurrentBar-1;

				//	if (ExtremeBarLow > High[4]) ExtremeBar = 4;
                   }

           		if (High[0] > ExtremeBarHigh)
				{
               		ExtremeBar = 0; 
               		ExtremeBarHigh = 0; 
               		TriggerBarLow = 0; 
					TriggerBarLowNo = 0;
					counter=-1; 
				}

           		if (0!=ExtremeBar) counter++; 


           		if ((Close[0] < TriggerBarLow) && (0!=ExtremeBar))
				{

                		ExtremeBar = ExtremeBar + counter;
                		HighPainted = true; 	
                		counter=-1;

                       scalpSeries.Set(CurrentBar-ExtremeBar);

					ExtremeBar=0; 

                   }

               }

			//Down
			 if (HighPainted==true)
			{
				if ((Low[1] > Low[2]) &&  (0==ExtremeBar))
				//if ((Low[1] > Low[2]) && (2 == Bars.LowestBar(3)) && (0==ExtremeBar)) 
				{
                 		ExtremeBar = 2; 
                 		ExtremeBarLow = Low[2]; 
                 		TriggerBarHigh = High[1]; 
					TriggerBarHighNo = CurrentBar-1;

                 	//	if (ExtremeBarLow > Low[4]) ExtremeBar = 4;
           		}

           		if (Low[0] < ExtremeBarLow)
				{ 
                 		ExtremeBar = 0; 
                 		ExtremeBarLow = 0; 
                 		TriggerBarHigh = 0; 
					TriggerBarHighNo = 0; 
                 		counter=-1; 
           		}

				if (0!=ExtremeBar) counter++; 

				if ((Close[0] > TriggerBarHigh) && (0!=ExtremeBar))
				{
                 		ExtremeBar = ExtremeBar + counter;                 
					HighPainted = false;
                 		counter=-1; 


                   	scalpSeries.Set(CurrentBar-ExtremeBar);

					ExtremeBar=0;	

           		}

			}

		//	else scalpSeries.Set(0);
           }
		lastBar=CurrentBar;

       }

	public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
   	{
       	// Default plotting in base class. 
		//base.Plot(graphics, bounds, min, max);

		if (base.Bars == null) return;

		if (ChartControl.ChartStyleType.ToString()=="LineOnClose") return;

       	int index = -1;
		Exception caughtException;


           int barPaintWidth = ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth);
		int bars = ChartControl.BarsPainted;
           while (bars >= 0)
           {
			index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) + 1) + bars;
               if (ChartControl.ShowBarsRequired || ((index - Displacement) >= BarsRequired))
               {
				try
				{
					bool ScalpBar=false;

					for (int scalpBar=index;scalpBar<=lastBar;scalpBar++)
                       {
						if (scalpSeries.Get(scalpBar)==index)
						{
							ScalpBar=true;
							break;
						}

					}

					if (ScalpBar)
					{
						int x1 = (((ChartControl.CanvasRight - ChartControl.BarMarginRight) - (barPaintWidth / 2)) - ((ChartControl.BarsPainted - 1) * ChartControl.BarSpace)) + (bars * ChartControl.BarSpace);
						int y1 = (bounds.Y + bounds.Height) - ((int) (((high.Get(index) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
						int y2 = (bounds.Y + bounds.Height) - ((int) (((close.Get(index) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
						int y3 = (bounds.Y + bounds.Height) - ((int) (((open.Get(index) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
						int y4 = (bounds.Y + bounds.Height) - ((int) (((low.Get(index) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));

						if (ChartControl.ChartStyleType.ToString()=="OHLC")
							graphics.DrawLine(new Pen(ScalpBarBrush.Color,(int)((((double)ChartControl.BarWidth)/3)*2)),x1,y1,x1,y4);
						else if (ChartControl.ChartStyleType.ToString()=="HiLoBars")
							graphics.DrawLine(new Pen(ScalpBarBrush.Color,ChartControl.BarWidth),x1,y1,x1,y4);
						else
						{
							byte bRed = (byte)~(ChartControl.BackColor.R);
							byte bGreen = (byte)~(ChartControl.BackColor.G);
							byte bBlue = (byte)~(ChartControl.BackColor.B);
							Pen pen = new Pen(Color.FromArgb(bRed,bGreen,bBlue), 1);

							graphics.FillRectangle(ScalpBarBrush,x1-(barPaintWidth/2)+1,y1,barPaintWidth-2,y4-y1);

							if (y2>y3)
							{
								graphics.DrawLine(pen,x1,y1,x1,y3);
								graphics.DrawLine(pen,x1,y2,x1,y4);
							}
							else
							{
								graphics.DrawLine(pen,x1,y1,x1,y2);
								graphics.DrawLine(pen,x1,y3,x1,y4);
							}
							graphics.DrawLine(pen,x1-(barPaintWidth/2)+1,y3,x1+(barPaintWidth/2)-2,y3);
							graphics.DrawLine(pen,x1-(barPaintWidth/2),y2,x1+(barPaintWidth/2),y2);
							graphics.DrawLine(pen,x1-(barPaintWidth/2),y2,x1-(barPaintWidth/2),y3);
							graphics.DrawLine(pen,x1+(barPaintWidth/2),y2,x1+(barPaintWidth/2),y3);
						}
					}
					else if (showTriggers)
					{
						if ((TriggerBarLowNo>0) && (TriggerBarLowNo==index))
						{
							int x1 = (((ChartControl.CanvasRight - ChartControl.BarMarginRight) - (barPaintWidth / 2)) - ((ChartControl.BarsPainted - 1) * ChartControl.BarSpace)) + (bars * ChartControl.BarSpace);
							int y1 = (bounds.Y + bounds.Height) - ((int) ((((high.Get(index)+(2*TickSize)) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
						    DrawArrow((barPaintWidth/5)*4, graphics,x1,y1,ScalpBarBrush,false);
						}
						if ((TriggerBarHighNo>0) && (TriggerBarHighNo==index))
						{
							int x1 = (((ChartControl.CanvasRight - ChartControl.BarMarginRight) - (barPaintWidth / 2)) - ((ChartControl.BarsPainted - 1) * ChartControl.BarSpace)) + (bars * ChartControl.BarSpace);
							int y1 = (bounds.Y + bounds.Height) - ((int) ((((low.Get(index)-(2*TickSize)) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));
						    DrawArrow((barPaintWidth/5)*4, graphics,x1,y1,ScalpBarBrush,true);
						}
					}
				}
                   catch (Exception exception) { caughtException = exception; }
              	}
			bars--;					
		}
   	}


	private void DrawArrow(int arrowSize, Graphics graphics, int x, int y, SolidBrush brush, bool up)
   	{
       	Point[] points;
       	int halfSize = (int) Math.Floor((double) (((double) arrowSize) / 2));
       	Point[] upPoints = new Point[] { new Point(0, 0), new Point(arrowSize, arrowSize), new Point(halfSize, arrowSize), new Point(halfSize, arrowSize * 2), new Point(-halfSize, arrowSize * 2), new Point(-halfSize, arrowSize), new Point(-arrowSize, arrowSize), new Point(0, 0) };
       	//Point[] dnPoints = new Point[] { new Point(-halfSize, -arrowSize * 2), new Point(halfSize, -arrowSize * 2), new Point(halfSize, -arrowSize), new Point(arrowSize, -arrowSize), new Point(0, 0), new Point(-arrowSize, -arrowSize), new Point(-halfSize, -arrowSize), new Point(-halfSize, -arrowSize * 2) };
       	//Point[] upPoints = new Point[] { new Point(0, -arrowSize), new Point(arrowSize, arrowSize), new Point(0, arrowSize/2), new Point(-arrowSize, arrowSize), new Point(0, -arrowSize) };
       	Point[] dnPoints = new Point[] { new Point(-halfSize, -arrowSize * 2), new Point(halfSize, -arrowSize * 2), new Point(halfSize, -arrowSize), new Point(arrowSize, -arrowSize), new Point(0, 0), new Point(-arrowSize, -arrowSize), new Point(-halfSize, -arrowSize), new Point(-halfSize, -arrowSize * 2) };


		if (up)
       	{
           	points = upPoints;
       	}
       	else
       	{
			points = dnPoints;
       	}
       	for (int i = 0; i < points.Length; i++)
       	{
           	points[i].Offset(x, y);
       	}

		byte bRed 	= (byte)~(base.ChartControl.BackColor.R);
           byte bGreen = (byte)~(base.ChartControl.BackColor.G);
		byte bBlue 	= (byte)~(base.ChartControl.BackColor.B);

           graphics.FillPolygon(brush, points);
           graphics.DrawPolygon(new Pen(Color.FromArgb(bRed,bGreen,bBlue)), points);        	        
   	}

       #region Properties            
       /// <summary>
	/// </summary>

	[browsable(false)]
   	public string ScalpBarColorSerialize
   	{
       		get { return SerializableColor.ToString(this.ScalpBarColor); }
       		set { this.ScalpBarColor = SerializableColor.FromString(value); }
   	}

	[Description("Default Colour for Scalp Bar"), XmlIgnore, VisualizationOnly]
	[Category("Scalp Bar")]
	[NinjaTrader.Gui.Design.DisplayName("Scalp bar color")]
	public Color ScalpBarColor
       {
		get { return this.ScalpBarBrush.Color; }
       	set { this.ScalpBarBrush = new SolidBrush(value); }
       }

	[Description("Highlights the current trigger bars by displaying an arrow above or below them.")]
       [Category("Scalp Bar")]
	[NinjaTrader.Gui.Design.DisplayName("Highlight current trigger bars")]
	public bool ScalperTriggers
       {
           get { return showTriggers; }
		set { showTriggers = value; }
       }

       #endregion
   }
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
   public partial class Indicator : IndicatorBase
   {
       private Scalper[] cacheScalper = null;

       private static Scalper checkScalper = new Scalper();

       /// <summary>
       /// Scalper
       /// </summary>
       /// <returns></returns>
       public Scalper Scalper()
       {
           return Scalper(Input);
       }

       /// <summary>
       /// Scalper
       /// </summary>
       /// <returns></returns>
       public Scalper Scalper(Data.IDataSeries input)
       {

           if (cacheScalper != null)
               for (int idx = 0; idx < cacheScalper.Length; idx++)
                   if (cacheScalper[idx].EqualsInput(input))
                       return cacheScalper[idx];

           Scalper indicator = new Scalper();
           indicator.SetUp();
           indicator.CalculateOnBarClose = CalculateOnBarClose;
           indicator.Input = input;

           Scalper[] tmp = new Scalper[cacheScalper == null ? 1 : cacheScalper.Length + 1];
           if (cacheScalper != null)
               cacheScalper.CopyTo(tmp, 0);
           tmp[tmp.Length - 1] = indicator;
           cacheScalper = tmp;
           Indicators.Add(indicator);

           return indicator;
       }

   }
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
   public partial class Column : ColumnBase
   {
       /// <summary>
       /// Scalper
       /// </summary>
       /// <returns></returns>
       [Gui.Design.WizardCondition("Indicator")]
       public Indicator.Scalper Scalper()
       {
           return _indicator.Scalper(Input);
       }

       /// <summary>
       /// Scalper
       /// </summary>
       /// <returns></returns>
       public Indicator.Scalper Scalper(Data.IDataSeries input)
       {
           return _indicator.Scalper(input);
       }

   }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
   public partial class Strategy : StrategyBase
   {
       /// <summary>
       /// Scalper
       /// </summary>
       /// <returns></returns>
       [Gui.Design.WizardCondition("Indicator")]
       public Indicator.Scalper Scalper()
       {
           return _indicator.Scalper(Input);
       }

       /// <summary>
       /// Scalper
       /// </summary>
       /// <returns></returns>
       public Indicator.Scalper Scalper(Data.IDataSeries input)
       {
           if (InInitialize && input == null)
               throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

           return _indicator.Scalper(input);
       }

   }
}
#endregion

Share this post


Link to post
Share on other sites

I fully agree with carcanaques. TTM's indicators are way overpriced for something so simple. I can't believe that the scalper would provide any edge at all. It required 3 bars before showing anything and during a consolidation that means getting chopped up. TRO posted his versions of the TTM indicators, wouldn't know where they have gone though.

Here's TheRumpledOne's opinion btw.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • $ARRY Array Technologies stock great day off the 10.96 double support area, from Stocks To Watch, https://stockconsultant.com/?ARRY
    • $MSFT Microsoft stock back up top of the range, breakout watch , https://stockconsultant.com/?MSFT
    • GBTC Grayscale Bitcoin stock top of range breakout watch , https://stockconsultant.com/?GBTC
    • $FSLR First Solar stock nice bull flag breakout, from Stocks To Watch, https://stockconsultant.com/?FSLR
    • Date: 22nd May 2024. UK Inflation Drop Boosts GBP, But Analysts See Correction Signals. The NASDAQ forms its 5th bullish wave resulting in the index trading 8% higher this month alone. Investors are waiting for NVIDIA’s earnings report. The market awaits the release of the latest FOMC Meeting Minutes for further indications on the potential rate adjustments. The US Dollar Index declines to a 7-week low, but can tonight’s Meeting Minutes change the trend? Read below what economists are predicting. UK inflation declines from 3.2% to 2.3% in its largest drop since December 2023. The Pound increases as the inflation rate did not decline to 2.1% as previously GBPUSD – UK Inflation Drops But Does Not Meet Previous Expectations! The GBPUSD is trading 0.30% higher after the release of April’s UK inflation figures. The US Dollar and the Japanese Yen are the worst performing currencies of the day. Traders looking to speculate a rising Pound may benefit from these weakening currencies. The GBPJPY is trading 0.47% higher so far. However, investors should be cautious of any change in price action as the next session (European Market) opens. The UK’s inflation figure fell from 3.2% to 2.3% which is the largest drop in 2024 so far and brings the Bank of England closer to its target. This would normally pressure the currency, but there are some factors which have triggered a bullish Pound. This includes the Core Consumer Price Index which fell from 4.2% to 3.9% instead of falling to 3.6% which were the previous expectations. Also, certain sectors did not see a decline in inflation in April, which is a continued concern. For these reasons, investors have increased their exposure to the Pound, supporting the currency. Also, economists are advising that the weakening inflation rate can increase investment demand which also further supports the country’s economy and subsequently the currency. Furthermore, investors will also need to take into consideration the price condition of the US Dollar individually. Dollar traders will be focusing on tonight’s Federal Open Market Committee’s Meeting Minutes. The market will particularly be looking for clarity on how many adjustments are likely in 2024, if any at all. In addition to this, if an adjustment is likely in July, September or later in the year. If the report indicates less cuts and a delay, the US Dollar potentially can witness further demand and a change in trend. This is something which was particularly seen in April 2024. The price action of the GBPUSD is forming a bullish trend and most trend-based indicators are signalling a higher price. However, there are signs that the price may correct back to the previous range. For example, on the 4-Hour chart the price is witnessing a divergence signal. in addition to this, the price is also trading at a significant resistance level from November, December and January. Though, for the resistance level to become active, the Dollar will likely require support from the upcoming Meeting Minutes. In the short term, sell signals are likely to materialize after crossing 1.27400 and 1.27268.   USA100 – Bullish Trend, But Investor Focus On Meeting Minutes & NVIDIA Earnings The NASDAQ saw a decline in the price as the US Open was approaching, however, the price momentum quickly changed when US investors started trading. The index rose 0.30% by the end of day and was the best performing US index. During the US Session 62.5% of stocks holding a weight of more than 1.00% rose while 37.5% fell. The main price drivers which supported the upward price movement were Microsoft, Alphabet, Apple, NVIDIA and Netflix. Investors will closely be monitoring the upcoming earnings report for NVIDIA, but also the FOMC’s Meeting Minutes. A more restrictive monetary policy can pressure the stock market, but the level of pressure and downward price movement will also depend on the results of NVIDIA’s earnings. Additionally, shareholders will also focus on Intuit’s Quarterly Earnings Report tomorrow evening, but this will have a lesser effect compared to NVIDIA. A concern for intraday traders is the decline in indices around the world in markets which are currently open. For example, the DAX, FTSE100, CAC and Nikkei225 are all trading lower. In addition to this, the US 10-Year Bond Yields are trading 0.0027% higher which is additional pressure on equities. Nonetheless, technical analysis in the medium to longer term continue to point to a continued upward trend. Always trade with strict risk management. Your capital is the single most important aspect of your trading business. Please note that times displayed based on local time zone and are from time of writing this report. Click HERE to access the full HFM Economic calendar. Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding on how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Michalis Efthymiou Market Analyst HFMarkets Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.