Need little help with a Ninjatrader script - futures io
futures io futures trading



Need little help with a Ninjatrader script


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one bukkan with 3 posts (6 thanks)
    2. looks_two max-td with 2 posts (2 thanks)
    3. looks_3 raindrop with 2 posts (0 thanks)
    4. looks_4 MXASJ with 1 posts (5 thanks)
      Best Posters
    1. looks_one MXASJ with 5 thanks per post
    2. looks_two bukkan with 2 thanks per post
    3. looks_3 NinjaTrader with 2 thanks per post
    4. looks_4 max-td with 1 thanks per post
    1. trending_up 3,054 views
    2. thumb_up 15 thanks given
    3. group 5 followers
    1. forum 9 posts
    2. 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)

 
Search this Thread
 

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.

Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(170 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
 
max-td's Avatar
 
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

max-td
Reply With Quote
 
(login for full post details)
  #4 (permalink)
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
 
Posts: 278 since Jun 2009
Thanks: 161 given, 269 received


raindrop View Post
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

}

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

Reply With Quote
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 View Post
You can also look at MostRecentOccurance()/LeastRecentOccurance() for the RSI part of the logic.

thanks MXASJ, thats the way to go.

Reply With Quote
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
 
max-td's Avatar
 
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

max-td
Reply With Quote
The following 2 users say Thank You to max-td for this post:
 
(login for full post details)
  #8 (permalink)
Site Sponsor

Web: NinjaTrader
AMA: Ask Me Anything
Webinars: NinjaTrader Webinars
Elite offer: Click here
 
 
NinjaTrader's Avatar
 
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

Follow me on Twitter Reply With Quote
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?

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

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Need little help with a Ninjatrader script


Last Updated on April 20, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



Copyright © 2021 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