NexusFi: Find Your Edge


Home Menu

 





Using slope of an indicator in an auto-strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one nanobiotech with 2 posts (1 thanks)
    2. looks_two sam028 with 1 posts (8 thanks)
    3. looks_3 Zoethecus with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 6,003 views
    2. thumb_up 9 thanks given
    3. group 4 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread

Using slope of an indicator in an auto-strategy

  #1 (permalink)
 
nanobiotech's Avatar
 nanobiotech 
Brisbane, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/Zen-Fire
Trading: CL
Posts: 670 since Jun 2009
Thanks Given: 134
Thanks Received: 430

I have a question for those amongst us that understand indicator code (I'm not too good at this yet) in order to access indicators in a strategy.

A nice example is the attached MASlopeBoxMulti indicator, which can display the slope of any of a good selection of moving average indicators.

My question is: how can the slope that is displayed on the chart be used as an entry or exit trigger in a strategy? How can we code for this in a strategy?

Cheers,
Nano

Attached Files
Elite Membership required to download: MASlopeBoxMulti.zip
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
ZombieSqueeze
Platforms and Indicators
 
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


In your .zip, a DataSeries is used to store the slope, but it's not always needed.
You can just use a variable, which stores the current slope, computed using the 3 previous values of the "thing" you want to apply/compute the slope.
For example, the slope of a EMA(20), in degrees:

 
Code
                            
//init

private int _ema20slope ;
...
// OnBarUpdate()
_ema20slope = (int)(180/Math.PI*(Math.Atan((EMA(20)[0]-(EMA(20)[1]+EMA(20)[2])/2)/1.5/TickSize)));
if (
_ema20slope 45) { golong();}
if (
_ema20slope < -45) { goshort();} 

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #4 (permalink)
 
nanobiotech's Avatar
 nanobiotech 
Brisbane, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/Zen-Fire
Trading: CL
Posts: 670 since Jun 2009
Thanks Given: 134
Thanks Received: 430


sam028 View Post
In your .zip, a DataSeries is used to store the slope, but it's not always needed.
You can just use a variable, which stores the current slope, computed using the 3 previous values of the "thing" you want to apply/compute the slope.
For example, the slope of a EMA(20), in degrees:

 
Code
                            
//init

private int _ema20slope ;
...
// OnBarUpdate()
_ema20slope = (int)(180/Math.PI*(Math.Atan((EMA(20)[0]-(EMA(20)[1]+EMA(20)[2])/2)/1.5/TickSize)));
if (
_ema20slope 45) { golong();}
if (
_ema20slope < -45) { goshort();} 

Sam, I'm seriously impressed. Thank you. I'll have a go.

Nano

Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 Zoethecus 
United States of America
 
Experience: Advanced
Platform: NT
Posts: 1,145 since Aug 2009


nanobiotech View Post
Sam, I'm seriously impressed. Thank you. I'll have a go.

Nano

Sam is the best. A major assest and a true professional.

Reply With Quote




Last Updated on August 6, 2010


© 2024 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 - Privacy Policy - Downloads - Top
no new posts