NexusFi: Find Your Edge


Home Menu

 





Scalping indicator - shows preset profit and stop loss targets the current bar.


Discussion in Traders Hideout

Updated
    1. trending_up 1,492 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 2 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
 edsall 
Montclair, NJ
 
Experience: Intermediate
Platform: NT 8
Trading: Index Futures
Posts: 16 since Nov 2013
Thanks Given: 0
Thanks Received: 1

Looking for an NT indicator for scalping. It will display a preset profit target and stop loss next to the current bar as well as bar size and wick size. I scalp the NQ 1 minute chart. Being able to see where those targets and stop losses would be on the current bar would be very helpful. I have looked all over the web without success. Has anybody seen something like this?

I remember Mack having something like this on his website but don't remember if it is adjustable and I am not a member anymore. FYI


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
OneChronos Launches First Combinatorial Auction FX Venue …
Currencies
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 BERN Algos 
Bologna Italy
 
Experience: Advanced
Platform: nt8
Broker: NinjaTrader
Trading: futures
Posts: 58 since Jun 2022
Thanks Given: 12
Thanks Received: 54


edsall View Post
Looking for an NT indicator for scalping. It will display a preset profit target and stop loss next to the current bar as well as bar size and wick size. I scalp the NQ 1 minute chart. Being able to see where those targets and stop losses would be on the current bar would be very helpful. I have looked all over the web without success. Has anybody seen something like this?


Hi edsall,
I hope the following simple code helps.
In the indicator properties, Setup, select Calculate
-> On each tick to have a real time plot on the forming bar
-> On bar close to have a stable plot linked to the close of the previous bar

Feel free to modify and adapt to your needs



 
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

//////////////////////////////////////////////////////////////////////////////////
// TPandSLdrawing - by BERN ALGOS - January 2023 - Rev01
//
// This indicator draws TP and SL lines over the chart, calculated as below:
// - Take Profit as per ATR values, period programmable by a parameter (default: 5)
// - Risk/Reward ratio, programmable by a parameter from 1/10 to 10 (default: 2)
//////////////////////////////////////////////////////////////////////////////////

namespace NinjaTrader.NinjaScript.Indicators
{
	public class TPandSLdrawing : Indicator
	{
		private ATR				MyATR;
		private	double 			actual_ATRsqrt;
		private	double 			_TP;
		private	double 			_SL;
		private	double 			actual_TP;
		private	double 			actual_SL;		
		
		protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description									= @"TPandSLdrawing";
				Name										= "TPandSLdrawing";
				Calculate									= Calculate.OnBarClose;
				IsOverlay									= true;
				DisplayInDataBox							= false;
				DrawOnPricePanel							= true;
				DrawHorizontalGridLines						= true;
				DrawVerticalGridLines						= true;
				PaintPriceMarkers							= false;
				IsAutoScale									= false;

				IsSuspendedWhileInactive					= true;
				
				P_ATR_Period								= 5; // default ATR period
				P_RiskRewardRatio							= 2; // default Risk/Reward Ratio
			}
			else if (State == State.Configure)
			{
			}
			else if (State == State.DataLoaded)
			{
				MyATR		= ATR(Input, P_ATR_Period);
			}
		}

		protected override void OnBarUpdate()
		{
			if (CurrentBars[0] < P_ATR_Period)  return;
			
			DrawOnPricePanel = true;
			_TP = (int)(MyATR[0]/TickSize);			// Take Profit Ticks
			_SL = (int)(_TP*P_RiskRewardRatio);		// Stop Loss Ticks
			actual_TP = Close[0]+_TP*TickSize;
			actual_SL = Close[0]-_SL*TickSize;
			
			Draw.Line(this, "TP_line1", false, 0, Close[0], -2, actual_TP, Brushes.Green, DashStyleHelper.Solid, 1);
			Draw.Line(this, "TP_line2", false, -2, actual_TP, -4, actual_TP, Brushes.Green, DashStyleHelper.Solid, 1);
			Draw.Line(this, "TP_line3", false, -2, actual_TP, P_ATR_Period, actual_TP, Brushes.Green, DashStyleHelper.DashDotDot,1);
			Draw.Text(this,  "TP_text1", "TP ticks= " + _TP.ToString(), -6, actual_TP, Brushes.White);

			Draw.Line(this, "SL_line1", false, 0, Close[0], -2, actual_SL, Brushes.Red, DashStyleHelper.Solid, 1);
			Draw.Line(this, "SL_line2", false, -2, actual_SL, -4, actual_SL, Brushes.Red, DashStyleHelper.Solid, 1);			
			Draw.Line(this, "SL_line3", false, -2, actual_SL, P_ATR_Period, actual_SL, Brushes.Red, DashStyleHelper.DashDotDot,1);			
			Draw.Text(this,  "SL_text1", "SL ticks= " + _SL.ToString(), -6, actual_SL, Brushes.White);
		}
		
	#region Properties
		[NinjaScriptProperty]
		[Range(1, 25)]
		[Display(Name="P_ATR_Period", Order=1, GroupName="Parameters")]
		public int P_ATR_Period
		{ get; set; }

		[NinjaScriptProperty]
		[Range(0.1, 10)]
		[Display(Name="P_RiskRewardRatio", Order=2, GroupName="Parameters")]
		public double P_RiskRewardRatio
		{ get; set; }
		
	#endregion
	}
}


Attached Files
Elite Membership required to download: TPandSLdrawing.zip
Reply With Quote
  #3 (permalink)
 edsall 
Montclair, NJ
 
Experience: Intermediate
Platform: NT 8
Trading: Index Futures
Posts: 16 since Nov 2013
Thanks Given: 0
Thanks Received: 1


Algos,

Thank you so much for taking the time to write the indicator. I know this is simple code for all of you fellow coders. But not for me. I attempted to write this several times and could not figure it out. Thanks to you, I know can modify this a bit and it will accomplish my needs.


Started this thread Reply With Quote




Last Updated on January 8, 2023


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts