NexusFi: Find Your Edge


Home Menu

 





How to program price cross below a number of previous bars


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Twiddle with 4 posts (0 thanks)
    2. looks_two vegasfoster with 2 posts (0 thanks)
    3. looks_3 MXASJ with 1 posts (0 thanks)
    4. looks_4 Fat Tails with 1 posts (2 thanks)
    1. trending_up 3,032 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

How to program price cross below a number of previous bars

  #1 (permalink)
 Twiddle 
Sydney, Australia
 
Experience: Beginner
Platform: Ninjatrader
Broker: Mirus
Trading: FDAX
Posts: 139 since May 2010
Thanks Given: 150
Thanks Received: 94

Hi all,

I am using the strategy wizard to build a couple of strategies, but I am struggling to do something quite simple.

What I want to do is the following: When the close of a bar is below the price of the previous x number of bars. So basically just a simple break the a low of a period.

I have tried using the "crossbelow" option with with various price options as both the data sets, and then the lookback period value of the number of bars i want the range to be within... no go. I have tried various other methods also, can't seem to get it working. It seems like such a simple thing...

Any help would be most appreciated.
Cheers

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
33 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Tao te Trade: way of the WLD
23 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #2 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

Crossbelow a 3 period donchian should work

Reply With Quote
  #3 (permalink)
 Twiddle 
Sydney, Australia
 
Experience: Beginner
Platform: Ninjatrader
Broker: Mirus
Trading: FDAX
Posts: 139 since May 2010
Thanks Given: 150
Thanks Received: 94



vegasfoster View Post
Crossbelow a 3 period donchian should work

Using the close price?

e.g When close closses below donchian channel of certain period.

Tried this, but it seems the lower close will update the donchian channel so they are always equivalent and therefore can never cross?

Started this thread Reply With Quote
  #4 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

How about something like:

if(DonchianChannel.Lower(n)[0] < DonchianChannel.Lower(n)[1]) Print("Its headed south!!!");

Haven't tried it but that should work with COBC true or false.

Reply With Quote
  #5 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

Try referencing the previous bars figure.

Reply With Quote
  #6 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

I guess the easiest (and crude) way would be to simply reference the low of the previous bar...

if close < low[1] then ......

And if you wanted 2 bars....just add an and statement with low[2]

so forth and so on.....

I'm sure there's some geek type that can craft a more elegant way to use an input to specify the number of bars you desire and have the code reflect that......

Reply With Quote
  #7 (permalink)
 Twiddle 
Sydney, Australia
 
Experience: Beginner
Platform: Ninjatrader
Broker: Mirus
Trading: FDAX
Posts: 139 since May 2010
Thanks Given: 150
Thanks Received: 94


RM99 View Post
I guess the easiest (and crude) way would be to simply reference the low of the previous bar...

if close < low[1] then ......

And if you wanted 2 bars....just add an and statement with low[2]

so forth and so on.....

I'm sure there's some geek type that can craft a more elegant way to use an input to specify the number of bars you desire and have the code reflect that......

I have resorted to this in the past, there has to be a way to have a range of bars though surely?

Started this thread Reply With Quote
  #8 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


MXASJ View Post
How about something like:

if(DonchianChannel.Lower(n)[0] < DonchianChannel.Lower(n)[1]) Print("Its headed south!!!");

Haven't tried it but that should work with COBC true or false.


This condition is equivalent to Low[0] < DonchianChannel.Lower(n)[1], but the question was about the close. So this would be a better match for what @Twiddle asked for:

 
Code
 if (Close[0] < DonchianChannel.Lower(n)[1])
The easiest solution, however, would be:

 
Code
if (Close[0] < MIN (Low, n)[1])

Reply With Quote
Thanked by:
  #9 (permalink)
 Twiddle 
Sydney, Australia
 
Experience: Beginner
Platform: Ninjatrader
Broker: Mirus
Trading: FDAX
Posts: 139 since May 2010
Thanks Given: 150
Thanks Received: 94


Fat Tails View Post
This condition is equivalent to Low[0] < DonchianChannel.Lower(n)[1], but the question was about the close. So this would be a better match for what @ Twiddle asked for:

 
Code
 if (Close[0] < DonchianChannel.Lower(n)[1])
The easiest solution, however, would be:

 
Code
if (Close[0] < MIN (Low, n)[1])

I will give that a try, thanks Fat Tails.

Started this thread Reply With Quote




Last Updated on May 17, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts