Need help for EMA slope startegy - NinjaTrader Programming | futures io social day trading

Need help for EMA slope startegy
 Updated: September 2nd, 2012 (11:58 AM) Views / Replies: 1,492 / 5 Created: August 31st, 2012 (10:11 AM) by michaelf Attachments: 0

 Welcome to futures io.

Need help for EMA slope startegy

 August 31st, 2012, 10:11 AM #1 (permalink) Elite Member Mérida, Mexico   Futures Experience: Intermediate Platform: NinjaTrader 8 Broker/Data: NinjaTrader Brokerage Favorite Futures: CL     Posts: 525 since Mar 2011 Thanks: 1,223 given, 531 received Need help for EMA slope startegy Happy Jackson Hole Day to everybody, lol I need some help to write a Strategy that plots vertical lines into a chart. I wrote everything with the Strategy Wizard and it is working, surprise! Now I would like to add a condition and with that one I have a problem. I would like an EMA with slope, for example 20 degree = flat. Flat = no plot. What is the parameter to write that? Thanks a lot michael

 August 31st, 2012, 10:11 AM #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.

Elite Member
Tampa, FL

Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J

Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,356 received

michaelf
 Happy Jackson Hole Day to everybody, lol I need some help to write a Strategy that plots vertical lines into a chart. I wrote everything with the Strategy Wizard and it is working, surprise! Now I would like to add a condition and with that one I have a problem. I would like an EMA with slope, for example 20 degree = flat. Flat = no plot. What is the parameter to write that? Thanks a lot michael

You couldn't really look at degrees for slope, because this would change based how zoomed in you were on the chart. You could add a plot, say myEMA was Plot[0].
Then add a variable for slope, say mySlope. mySlope would be ema value change over one bar.
Then
if(myEMA[0] - myEMA[1] <= mySlope && myEMA[0] - myEMA[1] >= -mySlope) PlotColors[0][0] = Color.Transparent;
else if(myEMA[0] - myEMA[1] > mySlope)PlotColors[0][0] = Color.Green;
else PlotColors[0][0] = Color.Red;

 The following user says Thank You to Xav1029 for this post:

Elite Member
New York

Futures Experience: Intermediate
Platform: NinjaTrader, Custom Platform
Broker/Data: IB
Favorite Futures: ES, YM, Currency Futures

Posts: 79 since May 2010
Thanks: 46 given, 68 received

You can use the normalized slope. This is how I calculated the slope for ES on hourly chart.

Code
 ```double _slope = Slope(_ema, 5); // this is slope per candle double _slopeN = 24 * 100 * _slope / Close[0]; // slope in percent per day // this assumes that 45 degree is 2% change in 4 days. // change the multiplier as per your assumption double _angle = 180 * Math.Atan(2 * _slopeN) / Math.PI;```
Hope this helps.

 The following user says Thank You to TraderSU for this post:

Elite Member
Mérida, Mexico

Futures Experience: Intermediate
Favorite Futures: CL

Posts: 525 since Mar 2011
Thanks: 1,223 given, 531 received

You can use the normalized slope. This is how I calculated the slope for ES on hourly chart.

Code
 ```double _slope = Slope(_ema, 5); // this is slope per candle double _slopeN = 24 * 100 * _slope / Close[0]; // slope in percent per day // this assumes that 45 degree is 2% change in 4 days. // change the multiplier as per your assumption double _angle = 180 * Math.Atan(2 * _slopeN) / Math.PI;```
Hope this helps.

Thank you, but I need do to it with the Strategy Wizard, I still don't understand how do write codes directely in the startegy.

 September 2nd, 2012, 11:58 AM #6 (permalink) Elite Member Tampa, FL   Futures Experience: Beginner Platform: NinjaTrader, Sierra Chart Broker/Data: Mirus Futures/Zen-Fire Favorite Futures: 6E, M6E, 6J     Posts: 1,374 since Dec 2011 Thanks: 1,452 given, 3,356 received Search NT support forum for slope simple. Its a slope indicator, but I don't have the original anymore.
 The following user says Thank You to Xav1029 for this post:

 futures io > Need help for EMA slope startegy

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

July

Jul 17