Encoding a Hold signal for "X" bars? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Encoding a Hold signal for "X" bars?
Updated: Views / Replies:1,689 / 6
Created: by fredesch 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
 

Encoding a Hold signal for "X" bars?

  #1 (permalink)
Elite Member
San Diego, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Tradestation
Broker/Data: Mirus/ZenFire
Favorite Futures: EUR/USD
 
Posts: 4 since Apr 2010
Thanks: 1 given, 1 received

Encoding a Hold signal for "X" bars?

Can anyone provide guidance as how to encode a "hold" signal for "x" number of bars in ninjascript? What I am seeking would resemble the following which was obtained from another language:

SYNTAX hold( EXPRESSION, periods )
FUNCTION Holds a "true" result of EXPRESSION for the specified number of periods.
This true result is held true over the number of periods specified even if a "false" result is generated.
EXAMPLE hold( cross(rsi(14),70),5 )

Thank you in advance for any help you can provide.
With kind regards,

Fred

Reply With Quote
 
  #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.

 
  #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,601 received
Forum Reputation: Legendary



fredesch View Post
Can anyone provide guidance as how to encode a "hold" signal for "x" number of bars in ninjascript? What I am seeking would resemble the following which was obtained from another language:

SYNTAX hold( EXPRESSION, periods )
FUNCTION Holds a "true" result of EXPRESSION for the specified number of periods.
This true result is held true over the number of periods specified even if a "false" result is generated.
EXAMPLE hold( cross(rsi(14),70),5 )

Thank you in advance for any help you can provide.
With kind regards,

Fred

I would define a BoolSeries object, which will hold the value "true" or "false" for each bar. You can then use an integer index, set it to 5 periods, count it down to zero and set the value to "true" if the index still is greater than 0.

However, it is not clear what you actually try to achieve.

Reply With Quote
 
  #4 (permalink)
Elite Member
San Diego, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Tradestation
Broker/Data: Mirus/ZenFire
Favorite Futures: EUR/USD
 
Posts: 4 since Apr 2010
Thanks: 1 given, 1 received

Thanks, Fat Tails. Much appreciated. What I am trying to do is:
1. Define an entry setup that I believe should be valid for "x" bars even if all conditions defining that setup don't hold true for all "x" bars. For example, a Long entry setup could be a very oversold situation, eg, RSI(2) < 3.
2. Use price movement beyond the extreme of the last bar in the desired trade direction to confirm and trigger a Long trade entry. For example, using the above oversold case: H[0] > H[1] could be the Long entry trigger.

I hope that makes sense.

I have some limited programming experience with Amibroker but none really with Ninjascript, so I am currently using the Strategy Wizard to cobble together a strategy. If you wouldn't mind, would you be so kind as to provide a simple example of the code you proposed. I'm very new at this and would regard it as an excellent learning opportunity.

Many thanks,

Fred

Reply With Quote
 
  #5 (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,601 received
Forum Reputation: Legendary

The easiest think would be, if you just edit a sample strategy. You could for example edit the SampleMACrossOver and save it under a new name.

You can then change the conditions within this strategy. If you have coded indicators or strategies with AmiBroker that should not be much of a problem. For example, you can use the RSI instead of the SMA. Note that the RSI has two parameters, the period of the RSI and the smoothing period, so the syntax will be RSI(period,smooth), as opposed to the SMA(period).

Now let us assume that you have a setup signal

1st condition: RSI(2) < 30

and that you want to hold this signal for 5 bars, and that you have an entry condition

2nd condition High[0] > High[1]

This means that you would have to check, whether the second condition is true and whether the first condition was true for the current or one of the prior four bars

A simple solution:

 
Code
if ((RSI(2)[0]< 30 || RSI(2)[1]< 30 || RSI(2)[2]< 30 || RSI(2)[3]< 30 || RSI(2)[4]< 30) && 
High[0]>High[1])
EnterLong();
Admittedly not very elegant, but should work nevertheless. Alternatively you could code

 
Code
if(High[0]>High[1])
{
	for (int i=0; i<5; i++)
		if(RSI(2)[i]<30)
		{
			EnterLong();
			break;
		}
}

Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:
 
  #6 (permalink)
Elite Member
San Diego, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, Tradestation
Broker/Data: Mirus/ZenFire
Favorite Futures: EUR/USD
 
Posts: 4 since Apr 2010
Thanks: 1 given, 1 received

Dear Fat Tails,
With your kind assistance I was able to successfully deploy your second suggestion. Thank you very much for your generous efforts. FWIW, I've ordered a book on C# programming!

With kind regards,

Fred

Reply With Quote
The following user says Thank You to fredesch for this post:
 
  #7 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received

Be kind, use the thanks button

https://futures.io/help-tutorials-how-tos/6661-how-use-thanks-button.html



Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote

Reply



futures io > > > > > Encoding a Hold signal for "X" bars?

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
"Floored," the documentary on Trading Pit opens in Chicago this week goldilocks Off-Topic 39 September 11th, 2013 12:55 PM
dealing with GetCurrentBidVolume and GetCurrentAskVolume , "long" casting into "int" jmejedi NinjaTrader Programming 4 May 23rd, 2011 10:33 AM
RJay's "Trader Volume" and "Trader Tick" Indicator Suites RJay The Elite Circle 20 December 20th, 2010 06:01 PM
"time"stop" codes for MC ptcm EasyLanguage Programming 1 September 2nd, 2010 01:57 AM
"Share Bars" Chart Type ???? RJay Traders Hideout 1 October 24th, 2009 05:37 PM


All times are GMT -4. The time now is 06:14 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-15 in 0.11 seconds with 19 queries on phoenix via your IP 107.20.115.174