Trading Articles
Article Categories
Article Tools
Need little help with a Ninjatrader script
Updated April 20, 2011
Top Posters
looks_one
bukkan
with 3 posts (6 thanks)
looks_two
max-td
with 2 posts (2 thanks)
looks_3
raindrop
with 2 posts (0 thanks)
looks_4
MXASJ
with 1 posts (5 thanks)
Best Posters
looks_one
MXASJ
with 5 thanks per post
looks_two
bukkan
with 2 thanks per post
looks_3
NinjaTrader
with 2 thanks per post
looks_4
max-td
with 1 thanks per post
trending_up
3,054 views
thumb_up
15 thanks given
group
5 followers
forum
9 posts
attach_file
0 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
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
(If you already have an account, login at the top of the page)
Need little help with a Ninjatrader script
(login for full post details)
#1 (permalink )
USA
Experience: Beginner
Platform: NinjaTrader 6.5
Posts: 18 since Mar 2010
Thanks: 13 given,
1
received
Hi All,
I need to code few simple lines but not sure how to do it. I'd appreciate any help.
1) RSI(14) has been above 80 anytime within last 12 bars.
2) And price is at least 20 pips above the SMA (25)
Thanks.
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#3 (permalink )
Frankfurt
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,754 since Jun 2009
Thanks: 2,309 given,
924
received
hi raindrop,
i think a little more explaination of what you like to have is needed for helpers.
do you work on an indicator or strategy ?
do you want to plot anything ?
do you only want to have the conditions to be written in code ?
thanks
max
(login for full post details)
#4 (permalink )
Calcutta, India
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks: 161 given,
269
received
raindrop
Hi All,
I need to code few simple lines but not sure how to do it. I'd appreciate any help.
1) RSI(14) has been above 80 anytime within last 12 bars.
2) And price is at least 20
pips above the
SMA (25)
Thanks.
dont know if this is the most elegant way to do, but you can try something like below
put the code in OnBarUpdate
Code
bool istrue = false;
for (int i = 0;i<= 11; i++)
{
if (RSI(Close,14,3)[i] > 80)
{
istrue = true;
break;
}
}
if (istrue && Close[0] - TickSize * 20 > SMA(25)[0])
{
//do your stuff
}
The following 4 users say Thank You to bukkan for this post:
(login for full post details)
#5 (permalink )
Asia
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 798 since Jun 2009
Thanks: 109 given,
799
received
You can also look at MostRecentOccurance()/LeastRecentOccurance() for the RSI part of the logic.
The following 5 users say Thank You to MXASJ for this post:
(login for full post details)
#6 (permalink )
Calcutta, India
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks: 161 given,
269
received
MXASJ
You can also look at MostRecentOccurance()/LeastRecentOccurance() for the RSI part of the logic.
thanks MXASJ, thats the way to go.
The following 2 users say Thank You to bukkan for this post:
(login for full post details)
#7 (permalink )
Frankfurt
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,754 since Jun 2009
Thanks: 2,309 given,
924
received
what you guys think about the count If - code for the RSI - check ?
// If in the last 10 bars we have had 8 up bars then go long
if ( CountIf(delegate {return Close[0] > Open[0];}, 10) > 8)
.... do things
The following 2 users say Thank You to max-td for this post:
(login for full post details)
#8 (permalink )
Web: NinjaTrader AMA: Ask Me Anything Webinars: NinjaTrader Webinars Elite offer: Click here
Posts: 1,569 since May 2010
Thanks: 184 given,
2,416
received
Unless I am missing something...
if (MAX(RSI(14), 12)[0] > 80 && Close[0] > SMA (25)[0] + 20 * TickSize)
// Do something
The following 2 users say Thank You to NinjaTrader for this post:
(login for full post details)
#9 (permalink )
Calcutta, India
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks: 161 given,
269
received
boy o boy now whos the fairest of all
my code (post 4) and the one posted by Ray using the MAX function are essentially the same. my code breaks from the loop once the condition is fulfilled (i.e. RSI > 80) while MAX loops to the end and find the highest value. So that way max is doing some extra loop which is redundant in our case.
what is the code behind MRO as MXASJ pointed out?
(login for full post details)
#10 (permalink )
USA
Experience: Beginner
Platform: NinjaTrader 6.5
Posts: 18 since Mar 2010
Thanks: 13 given,
1
received
I came back to see if there is any response to my question and was amazed to see the level of help here. I really appreciate everyone trying to help me here.
I am trying to write a trend trading strategy script so that's why I want to look back few periods. I do not have to plot the RSI on the chart but it would be a plus if I could. I can write simple scripts on Stockfetcher but that is the limit of my coding abilities .
Now while testing my strategy I have noticed that price is more likely to whipsaw when it is very close to lets say SMA (25) and I want the strategy to only generate a signal if price is at least 25 pips away (above or below depending upon the direction of the trade) from SMA(25). What would you experts think such a script look like?
Again I appreciate all the help extended to me in this thread.
Raindrop.
Last Updated on April 20, 2011
Right now
Ongoing
Right now
February
Coming soon
March
Register to Attend
Elite only