NT code problem - NinjaTrader | futures io social day trading
futures io futures trading


NT code problem
Updated: Views / Replies:981 / 8
Created: by lincor Attachments:1

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
 

NT code problem

  #1 (permalink)
Trading Apprentice
Mt. Martha Victoria Australia
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: EUR/USD
 
Posts: 5 since Oct 2012
Thanks: 6 given, 0 received

NT code problem

Greetings. New to the forum, hello all. New to attempted scripting in NT as well.Trying to find a piece of code that will allow me to condense the many lines I have compiled, saying for example, && CCI (50) [0]<CCI (50) [1]...right up to say [20]. Have ordered the C# Dummies book, but not arrived yet. All help appreciated.

Reply With Quote
 
  #2 (permalink)
Elite Member
las vegas
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 836 received

Answer
This post has been selected as an answer to the original posters question Answer

Not 100% sure what you are specifically asking in relation to the CCI, but I think you want to know how to loop, something like for (C# Reference)

Reply With Quote
 
  #3 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

Answer
This post has been selected as an answer to the original posters question Answer



lincor View Post
Greetings. New to the forum, hello all. New to attempted scripting in NT as well.Trying to find a piece of code that will allow me to condense the many lines I have compiled, saying for example, && CCI (50) [0]<CCI (50) [1]...right up to say [20]. Have ordered the C# Dummies book, but not arrived yet. All help appreciated.

Why don't you post the code?

Highlight the code and then select "#" from the upper task bar.

With the information you have given us so far, nobody can help you.

Reply With Quote
 
  #4 (permalink)
Elite Member
Cheltenham
 
Futures Experience: Advanced
Platform: InvestorRT, NinjaTrader
Favorite Futures: ES
 
Posts: 54 since Jan 2012
Thanks: 8 given, 100 received

Answer
This post has been selected as an answer to the original posters question Answer

I am new to C# and NinjaScript, but I think that you are looking for something like this.


 
Code
    public class MyCustomIndicator : Indicator
    {
        #region Variables
        // Wizard generated variables
            private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
		
		private double minCCI;
		
        #endregion


        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.
           
			// Find the lowest value of the 50 period CCI over the last 20 bars
			// This won't change,so only calculate once to improve performance
			if (FirstTickOfBar)
			{
				minCCI = MIN(CCI(50), 20)[0];
			}
			
			// Test each new tick to see if a new low has been found
			if (CCI(50)[0] < minCCI)
			{
				Print("New low found in CCI");
			}
			
        }


Last edited by pawnbroker; October 29th, 2012 at 10:22 AM. Reason: "double minCCI;" changed to "private double minCCI;"
Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Mt. Martha Victoria Australia
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: EUR/USD
 
Posts: 5 since Oct 2012
Thanks: 6 given, 0 received

thank you

Hi Pawnbroker,

Appreciate your efforts here !

Will try this tomorrow and let you know how it goes

best wishes

Lincor

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Mt. Martha Victoria Australia
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: EUR/USD
 
Posts: 5 since Oct 2012
Thanks: 6 given, 0 received

Example of Code


Fat Tails View Post
Why don't you post the code?

Highlight the code and then select "#" from the upper task bar.

With the information you have given us so far, nobody can help you.

Not too sure how any of this works yet, the forum, and not sure of what you mean by '#' at the task bar Fat Tails, but have taken a snipp of the code and attached it.

So with my small amount of knowledge I know that this is redundant. I have to write a line for each of the look back periods, where I want the indicator to be clear of. In this case, the MACD at a certain setting, has to be clear of itself for 17 bars back. In other words, if this current bar is not the highest during the look back period...1 to 17....a line will not be drawn over price. Hope that helps ?

Attached Thumbnails
NT code problem-code-example-bmf.jpg  
Reply With Quote
 
  #7 (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

Answer
This post has been selected as an answer to the original posters question Answer

You could use something like this:

 
Code
bool validFlag = true;
for (int i = 1; i <= 17; i++)
{
	if !(MACD(3, 10,16)[0] > MACD(3, 10,16)[i])
	{
		validFlag = false;
		break;
	}
}
if (validFlag == true)
{
	EnterLong();
}
PS. # is a button available for you when you post a message on the forum - it is in the same place that you have buttons for changing font, aligning etc.


Last edited by gregid; October 29th, 2012 at 09:57 AM. Reason: coma to semicolon error fixed
Reply With Quote
The following user says Thank You to gregid for this post:
 
  #8 (permalink)
Trading Apprentice
Mt. Martha Victoria Australia
 
Futures Experience: Intermediate
Platform: Ninja Trader
Favorite Futures: EUR/USD
 
Posts: 5 since Oct 2012
Thanks: 6 given, 0 received

Code


gregid View Post
You could use something like this:

 
Code
bool validFlag = true;
for (int i = 1; i <= 17; i++)
{
	if !(MACD(3, 10,16)[0] > MACD(3, 10,16)[i])
	{
		validFlag = false;
		break;
	}
}
if (validFlag == true)
{
	EnterLong();
}
PS. # is a button available for you when you post a message on the forum - it is in the same place that you have buttons for changing font, aligning etc.



Hi again Gregid. I tried your suggestion every which way, but the compiler just kept generating errors. Being new, I am assuming the 'bool validFlag and for(int" ...the first two lines, go in the initialize section of the editor. The 'if' statement goes under the 'OnBarUpdate' area. In a few months I'll look back and laugh, but for now, all help appreciated

Reply With Quote
 
  #9 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


lincor View Post
Hi again Gregid. I tried your suggestion every which way, but the compiler just kept generating errors. Being new, I am assuming the 'bool validFlag and for(int" ...the first two lines, go in the initialize section of the editor. The 'if' statement goes under the 'OnBarUpdate' area. In a few months I'll look back and laugh, but for now, all help appreciated

The whole block goes into OnBarUpdate.
Posting a screenshot of the errors along with the code generating the errors makes finding the problem much easier.

vvhg

Hic Rhodos, hic salta.
Reply With Quote

Reply



futures io > > > > NT code problem

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
NT VolumeStop indicator problem h20polo NinjaTrader 3 May 24th, 2011 06:44 PM
MC: Simple strategy code problem / Easy Language true EasyLanguage Programming 4 December 19th, 2010 09:48 AM
dwnloads nt indicators problem w/ laredo78676 NinjaTrader 10 March 29th, 2010 07:33 PM
Problem with NT Hapster NinjaTrader 10 February 12th, 2010 09:37 AM
Round to interval: code snippet + problem gregid NinjaTrader Programming 3 December 9th, 2009 09:02 PM


All times are GMT -4. The time now is 03:32 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-17 in 0.14 seconds with 38 queries on phoenix via your IP 107.20.115.174