Want to create an indicator and have no idea where to start? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Want to create an indicator and have no idea where to start?
Updated: Views / Replies:11,019 / 93
Created: by forrestang Attachments:30

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
 30  
 
Thread Tools Search this Thread
 

Want to create an indicator and have no idea where to start?

  #51 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received

For example, here is the code snippet to generate one of the buy signals, which at the moment is just an UpArrow. Initially I was thinking you would have to have a parity bit or flag that would trigger to some value upon this arrow being printed. That was the idea behind that variable I have there called "inTrade."

I was thinking I'd add another IF statement outside of that block where the UpArrow is printed to check to see if inTrade==true, and if it is, means we are in a trade so check to see if sell condition is met.

 
Code
//1a_A Trade
			
			if(ERG_Trade().Ltsx[0] == 1 && ERG_Str1().HISTSlope[0] == 1 && ERG_Trade().HIST[0] >= 10 )
			{
				if(ERG_Trade().HISTSlope[1] == 1 && ERG_Trade().HISTSlope[2] == 1 && ERG_Trade().HISTSlope[3] == -1)
				{	
				DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
				DrawText("text0"+CurrentBar, ""+Open.ToString(), 0, Low[0]-30*TickSize, Color.Black);
				DrawText("text1"+CurrentBar ,"1a_A", 0, Low[0]-38*TickSize, Color.Black);
				inTrade = true;			
				}
				
			}

Reply With Quote
 
  #52 (permalink)
Elite Member
Lagos, Nigeria
 
Futures Experience: Intermediate
Platform: NinjaTrader, SierraChart
Favorite Futures: Euro Currency & Oil
 
lolu's Avatar
 
Posts: 2,440 since Jun 2009
Thanks: 1,000 given, 1,595 received


forrestang View Post
For example, here is the code snippet to generate one of the buy signals, which at the moment is just an UpArrow. Initially I was thinking you would have to have a parity bit or flag that would trigger to some value upon this arrow being printed. That was the idea behind that variable I have there called "inTrade."

I was thinking I'd add another IF statement outside of that block where the UpArrow is printed to check to see if inTrade==true, and if it is, means we are in a trade so check to see if sell condition is met.

 
Code
//1a_A Trade
			
			if(ERG_Trade().Ltsx[0] == 1 && ERG_Str1().HISTSlope[0] == 1 && ERG_Trade().HIST[0] >= 10 )
			{
				if(ERG_Trade().HISTSlope[1] == 1 && ERG_Trade().HISTSlope[2] == 1 && ERG_Trade().HISTSlope[3] == -1)
				{	
				DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
				DrawText("text0"+CurrentBar, ""+Open.ToString(), 0, Low[0]-30*TickSize, Color.Black);
				DrawText("text1"+CurrentBar ,"1a_A", 0, Low[0]-38*TickSize, Color.Black);
				inTrade = true;			
				}
				
			}

Please, always remember to update the indicator as contained in post #18.

Lolu

Reply With Quote
 
  #53 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received



forrestang View Post

That was the idea behind that variable I have there called "inTrade."

I was thinking I'd add another IF statement outside of that block where the UpArrow is printed to check to see if inTrade==true, and if it is, means we are in a trade so check to see if sell condition is met.

Got it!

I did what I suggested above. Problem is that I have to do this for every individual trade scenario I have, and there are over 200 of them.

Here is the code snippet. I added that flag I spoke of above, so that it only triggers AFTER the entry condition is satisfied.

 
Code
if(ERG_Trade().Ltsx[0] == 1 && ERG_Str1().HISTSlope[0] == 1 && ERG_Trade().HIST[0] >= 10 )
			{
				if(ERG_Trade().HISTSlope[1] == 1 && ERG_Trade().HISTSlope[2] == 1 && ERG_Trade().HISTSlope[3] == -1)
				{	
				DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
				DrawText("text0"+CurrentBar, ""+Open.ToString(), 0, Low[0]-30*TickSize, Color.Black);
				DrawText("text1"+CurrentBar ,"1a_A", 0, Low[0]-38*TickSize, Color.Black);
				inTrade_1a_A = 1;			
				}
				
				if(inTrade_1a_A == 1 && ERG_Trade().HISTSlope[1] == -1)
				{	
				DrawArrowDown("arrow"+CurrentBar, true, 0, High[0]+12*TickSize, Color.Black);
				DrawText("text2"+CurrentBar, ""+Open.ToString(), 0, High[0]+30*TickSize, Color.Black);
				inTrade_1a_A = 0;			
				}
			}

Attached Thumbnails
Want to create an indicator and have no idea where to start?-prime2011-06-01_094546.jpg  
Reply With Quote
 
  #54 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


lolu View Post
Please, always remember to update the indicator as contained in post #18.

Lolu

I think it should be? I'm pretty sure I posted it earlier this morning?

Reply With Quote
 
  #55 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


forrestang View Post
Got the logic done and it's doing what I want.

Is there a simple way to add a closing arrow to this? Does NT have some function built in so that once my green/red arrow prints to show my entry, I can plot an exit AFTER that entry arrow?

Asking as eventually I'll want to kick this out to a strategy.

if you convert it into a strategy, it draws arrows for entry and exit for you. You can very this by applying sample strategy ma cross, enable = true and you will see arrows on your chart.
 
Code
		protected override void OnBarUpdate()
		{
			if (CrossAbove(SMA(Fast), SMA(Slow), 1))
			    EnterLong();
			else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
			    EnterShort();
		}

Reply With Quote
The following user says Thank You to cory for this post:
 
  #56 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


cory View Post
if you convert it into a strategy, it draws arrows for entry and exit for you. You can very this by applying sample strategy ma cross, enable = true and you will see arrows on your chart.

Excellent!

Since I have it setup when to draw an arrow up, and attached to it already is the exit.... so basically all I would need to do is replace the logic for drawing the arrows and the text I have with the "EnterLong()/EnterShort()" short commands?

Is there a command for exiting the signals, or do you just enter "EnterShort()" to exit a long trade for example?

Also, when I do create a strategy for this, if I have over 200 individual setups that I want to collect statistics for individually, do I have to individually toggle them on/off in the script and then test? Or will that be taken care of in the "signalName" parameter in the EnterLong()? Or is "signalName" just for visual reference on the chart?

NinjaTrader Version 7

Reply With Quote
 
  #57 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


forrestang View Post

Is there a command for exiting the signals, or do you just enter "EnterShort()" to exit a long trade for example?

Ah, found the ExitLong() command and connecting it to the entry via 'signalName' parameter.

Reply With Quote
 
  #58 (permalink)
Elite Member
Houston,Tx
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: TF
 
ThatManFromTexas's Avatar
 
Posts: 2,302 since Feb 2010
Thanks: 1,208 given, 4,293 received


forrestang View Post
For example, here is the code snippet to generate one of the buy signals, which at the moment is just an UpArrow. Initially I was thinking you would have to have a parity bit or flag that would trigger to some value upon this arrow being printed. That was the idea behind that variable I have there called "inTrade."

I was thinking I'd add another IF statement outside of that block where the UpArrow is printed to check to see if inTrade==true, and if it is, means we are in a trade so check to see if sell condition is met.

 
Code
//1a_A Trade
			
			if(ERG_Trade().Ltsx[0] == 1 && ERG_Str1().HISTSlope[0] == 1 && ERG_Trade().HIST[0] >= 10 )
			{
				if(ERG_Trade().HISTSlope[1] == 1 && ERG_Trade().HISTSlope[2] == 1 && ERG_Trade().HISTSlope[3] == -1)
				{	
				DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
				DrawText("text0"+CurrentBar, ""+Open.ToString(), 0, Low[0]-30*TickSize, Color.Black);
				DrawText("text1"+CurrentBar ,"1a_A", 0, Low[0]-38*TickSize, Color.Black);
				inTrade = true;			
				}
				
			}



MarketPosition

Definition
Gets the current market position.



Property Value

MarketPosition.Flat

MarketPosition.Long

MarketPosition.Short



Syntax

Position.MarketPosition


Examples


 
Code
protected override void OnBarUpdate()
{ 
    // If not flat print our open PnL
    if (Position.MarketPosition != MarketPosition.Flat) 
         Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));
}

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
The following user says Thank You to ThatManFromTexas for this post:
 
  #59 (permalink)
Elite Member
Houston,Tx
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: TF
 
ThatManFromTexas's Avatar
 
Posts: 2,302 since Feb 2010
Thanks: 1,208 given, 4,293 received


forrestang View Post
Ah, found the ExitLong() command and connecting it to the entry via 'signalName' parameter.

You can also tie your strategy to an "ATM" strategy and let it handle the Stops and Targets for you.

SampleATMstrategy.zip

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
 
  #60 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


Ah shucks!

My exit logic is off. Printing some erroneous arrows along with leaving some of them out.

Reply With Quote

Reply



futures io > > > > > Want to create an indicator and have no idea where to start?

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
Is there a Programmer that can create this Congestion Indicator nillz123 NinjaTrader 9 December 28th, 2013 01:19 PM
Simple Divergence and Stop Box Indicator Idea! tdaman Platforms and Indicators 5 May 16th, 2011 09:44 AM
want to create a new indicator. joyginy NinjaTrader Programming 5 January 18th, 2010 06:52 PM
Create this indicator Zoethecus NinjaTrader Programming 16 November 16th, 2009 07:56 PM
trying to create a Trend Line Rejection Indicator Eric NinjaTrader Programming 5 October 27th, 2009 03:45 PM


All times are GMT -4. The time now is 09:22 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-16 in 0.19 seconds with 20 queries on phoenix via your IP 54.83.122.227