NexusFi: Find Your Edge


Home Menu

 





How to capture multiple conditions in a single condition?


Discussion in NinjaTrader

Updated
    1. trending_up 1,492 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?
Help re translation of ninjascript to EL
NinjaTrader
is there a better Trade Performance tool for NinjaTrader?
NinjaTrader
Historical data for Kospi and Nikkei Index
NinjaTrader
Has anyone taken The Confident Trader course from aheadc …
Trading Reviews and Vendors
Quantum physics & Trading dynamics
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
HumbleTraders next chapter
58 thanks
Tao te Trade: way of the WLD
45 thanks
ApexTraderFunding.com experience and review
26 thanks
What is Markets Chat (markets.chat) real-time trading ro …
23 thanks
1 Minute Man
19 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


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