NexusFi: Find Your Edge


Home Menu

 





How to capture multiple conditions in a single condition?


Discussion in NinjaTrader

Updated
    1. trending_up 1,898 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 RonKiker 
Birmingham, AL
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES, YM, NQ
Posts: 34 since Apr 2012
Thanks Given: 17
Thanks Received: 23

I have 4 conditions that I monitor via indicators on my chart. If any 3 of the 4 conditions are true, I enter the trade. What I'd like to do is develop an indi that monitors these 4 conditions and then signals when any 3 of the 4 are true. It could be any 3 of the 4, and it may not necessarily be the same 3 each time, nor in the same order each time.

I think what I need to do is program a bool variable into each condition. I can handle that. Where I am having trouble is how do I monitor these 4 conditions for a "true" variable and then signal when any 3 of the 4 are true?

Does anyone have any suggestions on how I would program this logic?

Thanks,
Ron


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Al Arabiya: US-Iran Draft Deal Within Hours Contains Hor …
Prediction Markets & Event Contracts
SEC and CFTC Unlock Customer Cross-Margining for Treasur …
Treasury Notes and Bonds
New Section 301 Probes Target 16 Trading Partners -- Tra …
Traders Hideout
MyForexFunds Begins Returning Frozen Funds After CFTC Ca …
Funded Trading Evaluation Firms
April Jobs Beat Flips Fed Hike Odds Past 52% for First T …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 Koepisch 
@ Germany
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: FDAX
Posts: 568 since Nov 2011
Thanks Given: 440
Thanks Received: 518


You can code it like that:

 
Code
int Count = 0;
bool C1, C2, C3, C4;

// *** set conditions C1..C4 ***
// ...

// *** Check Results ***
if (C1)
    Count++;
if (C2)
    Count++;
if (C3)
    Count++;
if (C4)
    Count++;

if (Count >= 3)
{
    // *** Enter Trade ***
}


Reply With Quote
Thanked by:
  #4 (permalink)
 RonKiker 
Birmingham, AL
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES, YM, NQ
Posts: 34 since Apr 2012
Thanks Given: 17
Thanks Received: 23


Koepisch View Post
You can code it like that:

 
Code
int Count = 0;
bool C1, C2, C3, C4;

// *** set conditions C1..C4 ***
// ...

// *** Check Results ***
if (C1)
    Count++;
if (C2)
    Count++;
if (C3)
    Count++;
if (C4)
    Count++;

if (Count >= 3)
{
    // *** Enter Trade ***
}

Thanks, Koepisch!

That is just the mental kick in the pants that I needed.

Ron


Started this thread Reply With Quote




Last Updated on August 12, 2013


© 2026 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 - Downloads - Top
no new posts