Bearish, Bullish Retracement Ind - NinjaTrader Programming | futures io social day trading
futures io futures trading

Bearish, Bullish Retracement Ind
Updated: Views / Replies:1,473 / 2
Created: by ryangillespie Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Thread Tools Search this Thread

Bearish, Bullish Retracement Ind

  #1 (permalink)
london, England
Trading Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
ryangillespie's Avatar
Posts: 34 since Nov 2011
Thanks: 9 given, 1 received

Bearish, Bullish Retracement Ind

I am trying to adjust the code of the gartley indicator to plot XAB .786 Bullish, Bearish retracement triangles showing target 61.8 retracement of A-B. I must have errors in the code still, I would appreciate it if someone can point out whats missing.

/// <summary>
/// detects bullish and bearish and sets value to 1 or -1 or 0 if not found
/// </summary>
[Description("detects bullish and bearish and sets value to 1 or -1 or 0 if not found")]
public class RetracementAtempt1 : Indicator
#region Variables
// Wizard generated variables
private double zigZagPercentDeviation = 0.05; // Default setting for ZigZagPercentDeviation
private double tolerancePercent = 5; // Default setting for TolerancePercent

private IntSeries ipatternType;
private DataSeries patternType;
private DataSeries x;
private DataSeries idealProfitTarget;
private Color penColor = Color.Orange;
private int penWidth= 20;
private DashStyle dashStyle=System.Drawing.Drawing2D.DashStyle.Dash;
private int barsBack=250;

// User defined variables (add any user defined variables below)
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = true;
ipatternType=new IntSeries(this);
patternType=new DataSeries(this);
x=new DataSeries(this);
idealProfitTarget=new DataSeries(this);

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
private double Diagonal(double A,double B){
return Math.Sqrt(A*A+B*B);

protected override void OnBarUpdate()
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.


double B=0;
double A=0;
//double x=0;
double AB=0;
double XA=0;
double time_CD=0;
bool useHighLow=false;
bool bBearish=false;
int FirstHigh=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow).HighBar(0,1,barsBack);
int SecondHigh=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow).HighBar(0,2,barsBack);
int FirstLow=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow).LowBar(0,1,barsBack);
int SecondLow=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow).LowBar(0,2,barsBack);
int ThirdLow=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow).LowBar(0,3,barsBack);
int ThirdHigh=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow).HighBar(0,3,barsBack);
if(FirstHigh==-1 || SecondHigh==-1 || FirstLow==-1 || SecondLow==-1) return;

if(FirstLow<FirstHigh) {
// bullish case
if(SecondLow==-1) return;



else {
// bearish case
if(ThirdHigh==-1) return;





// Print(AB);
// Print(time_CD);
// Print(XA);
// Print(BC);
// Print(CD);

if(AB<=0.618*(1-TolerancePercent/100)*XA || AB>=0.786*(1+TolerancePercent/100)*XA) return;

// now conditions:
string tag=CurrentBar.ToString();
bool bautoscale=true;
if(bBearish) {

tag+="0.786 Bearish Retracement";


else {
tag+="0.786 Bullish Retracement";



#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries X
get { return x; }

[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
public DataSeries IdealProfitTarget
get { return idealProfitTarget; }

[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
public IntSeries Value
get { return ipatternType; }

[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
public DataSeries PatternType
get { return patternType; }


[Description("Pen Color Pattern")]
public Color PenColor
get { return penColor; }
set { penColor = value; }
// Serialize our Color object
public string PenColorSerialize
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(penColor); }
set { penColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }

[Description("Dash Style")]
public DashStyle DashStyle
get { return dashStyle; }
set { dashStyle = value; }

[Description("Pen Width")]
public int PenWidth
get { return penWidth; }
set { penWidth = Math.Max(0,value); }

[Description("Bars back")]
public int BarsBack
get { return barsBack; }
set { barsBack = Math.Max(5,value); }

public double ZigZagPercentDeviation
get { return zigZagPercentDeviation; }
set { zigZagPercentDeviation = Math.Max(0.001, value); }

public double TolerancePercent
get { return tolerancePercent; }
set { tolerancePercent = Math.Max(0.0, value); }

Reply With Quote
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

  #3 (permalink)
Houston, Texas
Trading Experience: Intermediate
Platform: NinjaTrader,TOS,Etrade,St
Broker/Data: NT:( tos,etrade,CS
Favorite Futures: stocks,options,futures,forex
learning0101's Avatar
Posts: 260 since Aug 2011
Thanks: 3,510 given, 206 received

Hi @ryangillespie
you may get more response/help if you post here

Reply With Quote
The following user says Thank You to learning0101 for this post:


futures io > > > > > Bearish, Bullish Retracement Ind

Upcoming Webinars and Events (4:30PM ET unless noted)

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now

Similar Threads
Thread Thread Starter Forum Replies Last Post
Needed.Color coded script for ema(changes from red to green with trend)&Volume ind. Rad4633 NinjaTrader 5 October 16th, 2012 03:24 PM
help with Fib retracement please slip The Elite Circle 15 January 13th, 2012 11:46 AM
Bearish Report on ES for 7/21? ron99 Emini and Emicro Index Futures Trading 2 July 21st, 2011 09:54 AM
Post your favorite Divergence ind. here zacharydw00 NinjaTrader Programming 22 January 6th, 2011 08:52 AM
How to know when a retracement ends? ikeaboy Traders Hideout 9 August 25th, 2010 07:06 AM

All times are GMT -4. The time now is 11:20 AM. (this page content is cached, log in for real-time version)

Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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.
no new posts