Two Independent Crossovers / Timing Check - futures io
futures io futures trading

Two Independent Crossovers / Timing Check

Discussion in NinjaTrader

      Top Posters
    1. looks_one Big Mike with 1 posts (1 thanks)
    2. looks_two zeller4 with 1 posts (0 thanks)
    3. looks_3 sam028 with 1 posts (1 thanks)
    4. looks_4 diverdan with 1 posts (0 thanks)
    1. trending_up 1,238 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 1 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

Two Independent Crossovers / Timing Check

(login for full post details)
  #1 (permalink)
Experience: Intermediate
Platform: NT7
Trading: CL, NQ, NG
Posts: 469 since Jun 2009
Thanks: 1,401 given, 402 received

I'm attempting to identify two independent crossover events and verify if they both occur within 5 bars of each other. I've started with the following:
in Variables:
private bool crossoverEventLongA = false;
private bool crossoverEventLongB = false;
private bool crossoverLongBoth = false;
private bool crossoverEventShortA = false;
private bool crossoverEventShortB = false;
private bool crossoverShortBoth = false;
private int countDown = 0; 
in OnBarUpdate():
if (CrossAbove(PositiveHolder,EMAPositiveHolder,1)) 
 crossoverEventLongA = true; 
if (CrossAbove(NegativeHolder,EMANegativeHolder,1)) {crossoverEventLongB = true; }
if (crossoverEventLongA && crossoverEventLongB) {crossoverLongBoth = true;}
else crossoverLongBoth = false; 
what I'm not sure how to do is use countdown to prove the the EventB occurred within 6 bars of EventA.
I'm thinking I can use a countdown function somewhere to give a true/false result if the two did occur within the specified time period
 for (countdown = 6; countdown>0; countdown--)
Please help with the missing code / syntax to help me get a qualified result with the timing parameter. I've attached a screenshot to show that these cross sometimes on the same bar and sometimes not.
Thanks in advance!
Kirk (zeller4)

Attached Thumbnails
Click image for larger version

Name:	CL 09-09  8_13_2009 (4 Range).jpg
Views:	90
Size:	83.4 KB
ID:	1233  
Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Neurological explanations for trading Success
Psychology and Money Management
Indicators for pair trading MES and M2K
Platforms and Indicators
NT8 indicator to simulate a Funding Evaluation where to …
If ES tracks SPX, why do support/resistance, Level 2, vo …
Emini and Emicro Index
ZigZag with Depth and Backstep
EasyLanguage Programming
(login for full post details)
  #2 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
Big Mike's Avatar
Posts: 49,785 since Jun 2009
Thanks: 32,314 given, 97,581 received

Perhaps when EventA occurs, record that bar number. When EventB occurs, record that bar number. Then do Math.Abs() and see if within 6 bars.

int eventa_bar 0;
int eventb_bar 0;

if (eventA)
eventa_bar CurrentBar;

if (
eventb_bar CurrentBar;

int barsapart Math.Abs(eventa_bar eventb_bar);

if (
barsapart 6)

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
(login for full post details)
  #3 (permalink)
Experience: Beginner
Platform: Multicharts, R
Trading: EUR / USD
Posts: 185 since Feb 2010
Thanks: 106 given, 98 received

Hi Mike

Why is the "Maths.Abs" needed?


Visit my futures io Trade Journal Reply With Quote
(login for full post details)
  #4 (permalink)
Site Moderator
sam028's Avatar
Posts: 3,665 since Jun 2009
Thanks: 3,787 given, 4,494 received

diverdan View Post
Hi Mike

Why is the "Maths.Abs" needed?


Because it's better/shorter/smarter than writing:

int barsapart;
if (
eventa_bar eventb_bar) >= 0
=eventa_bar eventb_bar;
barsapart=eventb_bar eventa_bar;

if (
barsapart 6)
Remember that we don't know if event A occurs before event B or not.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:

futures io Trading Community Platforms and Indicators NinjaTrader > Two Independent Crossovers / Timing Check

Last Updated on June 6, 2010

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


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


Importance of Finding Your Own Way w/Adam Grimes

Elite only

Journal Challenge w/Jigsaw


Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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