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


Bearish, Bullish Retracement Ind
Updated: Views / Replies:858 / 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 90,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

Reply
 
Thread Tools Search this Thread
 

Bearish, Bullish Retracement Ind

  #1 (permalink)
Elite Member
london, England
 
Futures 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)
#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()
{
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.


patternType.Set(0);

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;

B=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow)[FirstLow];
A=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow)[FirstHigh];
x.Set(ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow)[SecondLow]);

AB=Diagonal(B-A,FirstLow-FirstHigh);
XA=Diagonal(A-X[0],FirstHigh-SecondLow);

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

B=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow)[FirstHigh];
A=ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow)[FirstLow];
x.Set(ZigZag(DeviationType.Percent,ZigZagPercentDeviation,useHighLow)[SecondHigh]);

AB=Diagonal(B-A,FirstLow-FirstHigh);
XA=Diagonal(A-X[0],SecondHigh-FirstLow);

bBearish=true;
}

//Print("Currentbar="+CurrentBar.ToString());

// 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) {

ipatternType.Set(GartleyButterflyPatternType.Bearish);
patternType.Set((double)GartleyButterflyPatternType.Bearish);
idealProfitTarget.Set(B-0.618*AB);
tag+="0.786 Bearish Retracement";

DrawLine(tag+"AB",bautoscale,SecondHigh,B,SecondLow,A,PenColor,DashStyle,PenWidth);
DrawLine(tag+"XA",bautoscale,SecondLow,A,ThirdHigh,X[0],PenColor,DashStyle,PenWidth);

}
else {
//bullish
ipatternType.Set(GartleyButterflyPatternType.Bullish);
patternType.Set((double)GartleyButterflyPatternType.Bullish);
idealProfitTarget.Set(B+0.618*AB);
tag+="0.786 Bullish Retracement";

DrawLine(tag+"AB",bautoscale,SecondLow,B,SecondHigh,A,PenColor,DashStyle,PenWidth);
DrawLine(tag+"XA",bautoscale,SecondHigh,A,ThirdLow,X[0],PenColor,DashStyle,PenWidth);
}


}

#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
[XmlIgnore()]
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
[XmlIgnore()]
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
[XmlIgnore()]
public DataSeries PatternType
{
get { return patternType; }

}

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

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

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

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

[Description("")]
[GridCategory("Parameters")]
public double ZigZagPercentDeviation
{
get { return zigZagPercentDeviation; }
set { zigZagPercentDeviation = Math.Max(0.001, value); }
}

[Description("")]
[GridCategory("Parameters")]
public double TolerancePercent
{
get { return tolerancePercent; }
set { tolerancePercent = Math.Max(0.0, value); }
}
#endregion
}
}

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)
Elite Member
Houston, Texas
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: futures
 
learning0101's Avatar
 
Posts: 247 since Aug 2011
Thanks: 3,400 given, 185 received


Hi @ryangillespie
you may get more response/help if you post here
https://futures.io/elite-circle/1261-want-your-ninjatrader-indicator-created-free.html

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

Reply



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

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

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 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:00 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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
Page generated 2017-12-11 in 0.12 seconds with 19 queries on phoenix via your IP 54.145.16.43