Indicator to check consolidation - NinjaTrader | futures io social day trading
futures io futures trading


Indicator to check consolidation
Updated: Views / Replies:2,546 / 4
Created: by danjuma 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
 

Indicator to check consolidation

  #1 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker/Data: IB, Kinetic
Favorite Futures: Stocks, Forex
 
Posts: 97 since Nov 2011
Thanks: 47 given, 16 received

Indicator to check consolidation

Hello people.

Would be very grateful for your assistance with this code please. I have already posted it on the NT forum, but not getting much response/assistance at present. Basically its an indicator I am trying to write to use in the Market Analyzer of NT. I am a complete novice to NT scripts and C#, and this is just my crude and primitive attempt using the NT indicator wizard and nicking snippets of code here and there.

What I am after is an indicator to return 1 if a condition is met or 0 otherwise. The condition is basically to look at the last four bars to see if are in a very narrow range (highest range not more than say 0.25c) and also if close to the day's high or low so far.

Not surprisingly, it failed to compile, giving me the following errors:
Class member declaration expected
Invalid token 'namespace' in class, struct, or interface member declaration
Invalid token '{' in class, struct, or interface member declaration
} expected

Many thanks for you assistance.


 
Code
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Checks if last 4 bars have very narrow range and close to day high or low
    /// </summary>
    [Description("Checks if last 4 bars have very narrow range and close to day high or low")]
    public class Consolidating : Indicator
    {
        #region Variables
        // Wizard generated variables
        // 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()
        {
            Overlay                = false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            bool MaxRng4Bars = false;
            double maxHigh = MAX(High,4)[0];
            double minLow =  MIN(Low,4)[0];
            double maxHlessDayH = CurrentDayOHL().CurrentHigh[0] - maxHigh;
            double minLlessDayL = minLow - CurrentDayOHL().CurrentLow[0];
            bool CloseToHigh = false;
            bool CloseToLow = false;
            
            if (Range()[0]<0.26 && Range()[1]<0.26 && Range()[2]<0.26 && Range()[3]<0.26)
             {
                MaxRng4Bars = true;
             { 
            if (maxHlessDayH >= 0 && maxHlessDayH < 0.5)
             {
                CloseToHigh = true;
             }
            if (minLlessDayL >= 0 && minLlessDayL < 0.5)
             {
                CloseToLow = true;
             }
         
            
             Value.Set(MaxRng4Bars = true && CloseToHigh = true && CloseToLow = true  ? 1 :0);
                
        }

Reply With Quote
 
  #2 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker/Data: IB, Kinetic
Favorite Futures: Stocks, Forex
 
Posts: 97 since Nov 2011
Thanks: 47 given, 16 received

Ok, been working on the code (basically through trial and error, not too sure exactly what I am doing ). However, the amended code below so far has compiled successfully. I have not tested it yet as the markets (US stocks) are currently closed. Logically though, does it look correct, will it do what I want it to do? Many thanks.


 
Code
protected override void OnBarUpdate()
        {
            
            
            double maxHlessDayH = CurrentDayOHL().CurrentHigh[0] - MAX(High,4)[0];
            double minLlessDayL = MIN(Low,4)[0] - CurrentDayOHL().CurrentLow[0];
            int MaxRng4Bars, CloseToHigh, CloseToLow;
            
            if (Range()[0]<0.26 && Range()[1]<0.26 && Range()[2]<0.26 && Range()[3]<0.26)
                          
                 MaxRng4Bars = 1;
            else
            {
                 MaxRng4Bars = 0;
            }
              
            if (maxHlessDayH >= 0 && maxHlessDayH < 0.5)
             
                 CloseToHigh = 1;
            else
            {
                 CloseToHigh = 0;
            }
             
            if (minLlessDayL >= 0 && minLlessDayL < 0.5)
            
                 CloseToLow = 1;
            else
             {
                  CloseToLow = 0;
             }
           
            if (MaxRng4Bars == 1 && CloseToHigh == 1 && CloseToLow == 1)
                
             Value.Set(1);
            else
            {
             Value.Set(0);
            
            }

Reply With Quote
 
  #3 (permalink)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received

curly brackets


As a novice, make sure you use curly brackets with every if statement, ie:

 
Code
                            
if (X)
{
     
//statement 
}
else
{
    
//statement

C# will process only first line after if when curly bracket is missing so it is a good practice to use them, especially when you don't know what your are doing

Reply With Quote
The following user says Thank You to gregid for this post:
 
  #4 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: NinjaTrader, IB TWS
Broker/Data: IB, Kinetic
Favorite Futures: Stocks, Forex
 
Posts: 97 since Nov 2011
Thanks: 47 given, 16 received


gregid View Post
As a novice, make sure you use curly brackets with every if statement, ie:

 
Code
                            
if (X)
{
     
//statement 
}
else
{
    
//statement

C# will process only first line after if when curly bracket is missing so it is a good practice to use them, especially when you don't know what your are doing

Thanks for the tip gregid. Logically though, apart from the missing curly brackets, does the code look ok? Thanks

Reply With Quote
 
  #5 (permalink)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received

your conditions are quite simple so I don't see why it wouldn't work. Just load it, test and see for yourself =)

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

Reply



futures io > > > > Indicator to check consolidation

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
This Is the Year of Consolidation for BP: CEO Quick Summary News and Current Events 0 July 26th, 2011 06:40 AM
Check out this equity curve! MXASJ NinjaTrader Programming 5 May 29th, 2010 02:09 PM
Indicator to detect non-trending periods / consolidation? diverdan The Elite Circle 5 May 27th, 2010 06:29 PM
Consolidation alert a la tzachi Saroj NinjaTrader Programming 35 August 21st, 2009 05:01 PM
consolidation lines? rassi Traders Hideout 1 June 16th, 2009 06:37 AM


All times are GMT -4. The time now is 10:58 AM.

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-13 in 0.08 seconds with 19 queries on phoenix via your IP 54.227.51.103