NexusFi: Find Your Edge


Home Menu

 





Need Custom Range Indicator


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one lolu with 2 posts (0 thanks)
    2. looks_two moolob with 2 posts (0 thanks)
    3. looks_3 Sawtooth with 1 posts (0 thanks)
    4. looks_4 websouth with 1 posts (0 thanks)
    1. trending_up 1,818 views
    2. thumb_up 0 thanks given
    3. group 6 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
SOAP7
Bucharest - Romania
 
Posts: 14 since Mar 2020
Thanks Given: 2
Thanks Received: 8

Can someone help with a study that draws two white lines at the High and Low of a candle, if the next 4 candles are completely inside its range? Lines should have approx. length of 5 bars. If it's easier it can also just color the first candle or otherwise visually indicate. See image example of two white lines to indicate a small range.

Is this possible to do within SC or do I need to find someone to code this as a study? Thanks


Attached Thumbnails
Click image for larger version

Name:	range exampel.jpg
Views:	57
Size:	16.0 KB
ID:	342573  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
The May 31 Binary: 60% Trump Declares Iran Ops Over, Onl …
Prediction Markets & Event Contracts
Cboe Files for Near 24x5 Equities Trading -- December 20 …
Traders Hideout
UCL Final Kicks Off at Noon ET: PSG at 56.5% as Iran May …
Prediction Markets & Event Contracts
 
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)
 Sawtooth 
Prescott AZ USA
 
Experience: Advanced
Platform: SierraChart
Broker: EdgeClear, FCM:Phillip, Data:Denali, Routing:Teton
Trading: YM RTY ES NQ
Posts: 480 since Nov 2009
Thanks Given: 222
Thanks Received: 608


Quoting 
Is this possible to do within SC or do I need to find someone to code this as a study? Thanks

This would require a custom ACSIL study.


Reply With Quote
  #3 (permalink)
 
lolu's Avatar
 lolu 
Lagos, Nigeria
 
Experience: Intermediate
Platform: NinjaTrader, SierraChart
Trading: Euro Currency & Oil
Frequency: Daily
Duration: Hours
Posts: 2,555 since Jun 2009
Thanks Given: 1,050
Thanks Received: 1,679



SOAP7 View Post
Can someone help with a study that draws two white lines at the High and Low of a candle, if the next 4 candles are completely inside its range? Lines should have approx. length of 5 bars. If it's easier it can also just color the first candle or otherwise visually indicate. See image example of two white lines to indicate a small range.

Is this possible to do within SC or do I need to find someone to code this as a study? Thanks

Hi,

Please, how do you use the concept in this indicator ?

lolu


Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
moolob
Braunschweig, Germany
 
Posts: 2 since Sep 2022
Thanks Given: 1
Thanks Received: 0

Hi, you can use the built-in Color Bar Based On Alert Condition Study to achieve this.

In the Alert Conditions Tab, enter this:

 
Code
AND(
 H > H[1],
 H > H[2],
 H > H[3],
 H > H[4],
 L < L[1],
 L < L[2],
 L < L[3],
 L < L[4]
)
Cheers!

PS: If you are interested, I can post the code for an ACSIL study to draw lines like in your example.


Reply With Quote
  #5 (permalink)
 
lolu's Avatar
 lolu 
Lagos, Nigeria
 
Experience: Intermediate
Platform: NinjaTrader, SierraChart
Trading: Euro Currency & Oil
Frequency: Daily
Duration: Hours
Posts: 2,555 since Jun 2009
Thanks Given: 1,050
Thanks Received: 1,679

Thanks for your response.

You seem to be talking in Sierra dialect; I use NinjaTrader 8. So, could you please translate your Sierra logic code snippet to NinjaTrader 8, or in just a simple English description.

lolu


Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
moolob
Braunschweig, Germany
 
Posts: 2 since Sep 2022
Thanks Given: 1
Thanks Received: 0


lolu View Post
Thanks for your response.

You seem to be talking in Sierra dialect; I use NinjaTrader 8. So, could you please translate your Sierra logic code snippet to NinjaTrader 8, or in just a simple English description.

lolu

Sorry, I don't know how to do this in NT. You probably need to code this. The OP was asking for a Sierra Chart solution for this.


Reply With Quote
  #7 (permalink)
 
websouth's Avatar
 websouth 
Pensacola, FL
Market Wizard
 
Experience: Intermediate
Platform: graph paper
Trading: The shiny stuff
Posts: 1,223 since Jul 2009
Thanks Given: 1,118
Thanks Received: 1,340


moolob View Post
Sorry, I don't know how to do this in NT. You probably need to code this. The OP was asking for a Sierra Chart solution for this.


Grok is your friend.... This may indie may be backwards to your intent but you can have Grok mod it however you like.

q: hey Grok can you make an engulfing bar indicator which will draw white extension lines at the highs and lows of the engulfing bar based on how many bars you set it to look for. n=2 would would draw lines when engulfs at least 2 bars, etc. in ninjatrader 8 script.

a: Below is a NinjaTrader 8 script for an engulfing bar indicator that draws white extension lines at the highs and lows of an engulfing bar when it engulfs at least n bars, as specified by the user. The script uses the NinjaScript framework to detect bullish and bearish engulfing patterns and draw horizontal lines extending to the right.

#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
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

namespace NinjaTrader.NinjaScript.Indicators
{
public class EngulfingBarIndicator : Indicator
{
private int barsToEngulf;

protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Draws lines at highs/lows of engulfing bars based on number of bars engulfed.";
Name = "EngulfingBarIndicator";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = false;
PaintPriceMarkers = false;
barsToEngulf = 2; // Default number of bars to engulf
}
}

protected override void OnBarUpdate()
{
if (CurrentBar < barsToEngulf) return; // Ensure enough bars are available

bool isBullishEngulfing = IsBullishEngulfing();
bool isBearishEngulfing = IsBearishEngulfing();

if (isBullishEngulfing || isBearishEngulfing)
{
// Draw horizontal lines at high and low of the engulfing bar
Draw.HorizontalLine(this, "HighLine" + CurrentBar, High[0], Brushes.White, DashStyleHelper.Solid, 2, false);
Draw.HorizontalLine(this, "LowLine" + CurrentBar, Low[0], Brushes.White, DashStyleHelper.Solid, 2, false);
}
}

private bool IsBullishEngulfing()
{
// Check if current bar is bullish
if (Close[0] <= Open[0]) return false;

// Check if current bar engulfs the previous n bars
double bodyHigh = Math.Max(Open[0], Close[0]);
double bodyLow = Math.Min(Open[0], Close[0]);
double candleHigh = High[0];
double candleLow = Low[0];

for (int i = 1; i <= barsToEngulf; i++)
{
if (i > CurrentBar) return false; // Not enough bars

double prevBodyHigh = Math.Max(Open[i], Close[i]);
double prevBodyLow = Math.Min(Open[i], Close[i]);
double prevCandleHigh = High[i];
double prevCandleLow = Low[i];

// Bullish engulfing: current bar's body must engulf previous bar's body
// and wicks must encompass previous bar's wicks
if (bodyHigh <= prevBodyHigh || bodyLow >= prevBodyLow ||
candleHigh < prevCandleHigh || candleLow > prevCandleLow)
{
return false;
}
}

return true;
}

private bool IsBearishEngulfing()
{
// Check if current bar is bearish
if (Close[0] >= Open[0]) return false;

// Check if current bar engulfs the previous n bars
double bodyHigh = Math.Max(Open[0], Close[0]);
double bodyLow = Math.Min(Open[0], Close[0]);
double candleHigh = High[0];
double candleLow = Low[0];

for (int i = 1; i <= barsToEngulf; i++)
{
if (i > CurrentBar) return false; // Not enough bars

double prevBodyHigh = Math.Max(Open[i], Close[i]);
double prevBodyLow = Math.Min(Open[i], Close[i]);
double prevCandleHigh = High[i];
double prevCandleLow = Low[i];

// Bearish engulfing: current bar's body must engulf previous bar's body
// and wicks must encompass previous bar's wicks
if (bodyHigh <= prevBodyHigh || bodyLow >= prevBodyLow ||
candleHigh < prevCandleHigh || candleLow > prevCandleLow)
{
return false;
}
}

return true;
}

#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Bars to Engulf", Description = "Number of bars the engulfing bar must engulf", Order = 1, GroupName = "Parameters")]
public int BarsToEngulf
{
get { return barsToEngulf; }
set { barsToEngulf = value; }
}
#endregion
}
}


Explanation:
Purpose: The indicator identifies bullish or bearish engulfing bars that engulf at least n previous bars (set via the BarsToEngulf parameter) and draws white horizontal lines at the high and low of the engulfing bar.

Engulfing Logic:
A bullish engulfing bar has a higher close than open, and its body (open to close) and wicks (high to low) must fully encompass the bodies and wicks of the previous n bars.

A bearish engulfing bar has a lower close than open, with the same engulfing criteria.

Drawing: Uses Draw.HorizontalLine to draw white lines at the high and low of the engulfing bar, extending to the right (default NinjaTrader behavior for horizontal lines).

Parameter: BarsToEngulf (default = 2) allows the user to specify how many bars the engulfing bar must engulf.

Safety: Checks for sufficient bars (CurrentBar < barsToEngulf) to avoid index errors.

Calculation: Runs on bar close (Calculate.OnBarClose) to ensure complete bar data.

How to Use:
In NinjaTrader 8, go to Tools > Edit NinjaScript > Indicator.

Create a new indicator and paste the above code.

Compile the script.

Add the indicator to a chart via Indicators menu.

Set the Bars to Engulf parameter (e.g., 2) in the indicator settings.

Apply the indicator to see white lines at the highs and lows of qualifying engulfing bars.

Notes:
The lines persist until manually removed or the chart is refreshed, as they are drawn with unique tags (HighLine/LowLine + CurrentBar).

Ensure the chart has enough bars to evaluate the BarsToEngulf setting.

If you want the lines to extend only a certain number of bars to the right, you’d need to modify the script to use a custom drawing tool or manage line removal, which can be added if needed.

Let me know if you need adjustments, like limiting line duration or adding visual markers!


“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
Tin44
Madrid Spain
 
Posts: 13 since Nov 2022
Thanks Given: 5
Thanks Received: 5


SOAP7 View Post
Can someone help with a study that draws two white lines at the High and Low of a candle, if the next 4 candles are completely inside its range? Lines should have approx. length of 5 bars. If it's easier it can also just color the first candle or otherwise visually indicate. See image example of two white lines to indicate a small range.

Is this possible to do within SC or do I need to find someone to code this as a study? Thanks

(Apologies for my English)

I paid the subscription for Chatgpt I mostly use o3 y o4 mini high and of course Claude Sonnet.

On Chatgpt you can use Sierra Coder too... despite having tons of information about ACSIL it tends to fail.. I managed to create my indicator downloading all ACSIL documentation from Sierra Chart webpage and upload it on chatgpt as a pdf. Then when I just got near from what I want i use Claude Sonnet to fine tune things.

Try both of them. For 40 bucks you will be able to do that eyes closed. And trust me is by faaar more cheaper than hiring a coder.

Extremely important tip: you have to be so detailed while writing the prompt to the IA, like he is 6 years old and you have to give him instructions to learn to pee in the bathroom.. starting from "start walking, and went to the bathroom that is the second door right next too.... bla bla bla... then unzip.. bla bla bla"

You have to have crystal clear in your mind what you want to do and detail it hair by hair.


Reply With Quote




Last Updated on May 30, 2025


© 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