NexusFi: Find Your Edge


Home Menu

 





How to capture multiple conditions in a single condition?


Discussion in NinjaTrader

Updated
    1. trending_up 1,983 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?
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
GDP Day: The First Economic Reckoning -- Pahlavi at 6.55 …
Prediction Markets & Event Contracts
Post-Summit Scorecard: $36M in May 15 Bets Settle Near-Z …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 Koepisch 
@ Germany
Market Wizard
 
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