NexusFi: Find Your Edge


Home Menu

 





Working together strategies


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 NOCOMPRRRENDO 
MALAGA, ESPAŅA
 
Experience: None
Platform: NINJATRADER
Trading: FUTURES
Frequency: Every few days
Duration: Hours
Posts: 4 since Jul 2021
Thanks Given: 1
Thanks Received: 1

Hello everyone.
I need my strategies to talk to each other. I would like if one strategy is active, the others are not. Is it possible to do this?

Thank you.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
March Jobs Report Update: 178K Beat vs 59K Expected, Wag …
Traders Hideout
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
Prediction Markets & Event Contracts
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
Eurex Eyes Prediction Markets -- Europes Biggest Derivat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 6,233 since Sep 2015
Thanks Given: 15,885
Thanks Received: 16,118


NOCOMPRRRENDO View Post
Hello everyone.
I need my strategies to talk to each other. I would like if one strategy is active, the others are not. Is it possible to do this?

Thank you.

Hi NOCOMPRRRENDO, welcome.

I haven't touched NT code in years but, from what I can remember, there isn't an overarching system to stop multiple strategies when one is active (I am assuming that these are all independent from each other).

What you would need to do is get into the code for each one of them and put some sort of control.

Others can probably help you with more specific tips.


Reply With Quote
  #3 (permalink)
 NOCOMPRRRENDO 
MALAGA, ESPAŅA
 
Experience: None
Platform: NINJATRADER
Trading: FUTURES
Frequency: Every few days
Duration: Hours
Posts: 4 since Jul 2021
Thanks Given: 1
Thanks Received: 1


That's what I thought.

Thank you for your reply.


Started this thread Reply With Quote
  #4 (permalink)
 
trendisyourfriend's Avatar
 trendisyourfriend 
Quebec Canada
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, NQ, YM
Frequency: Daily
Duration: Minutes
Posts: 4,580 since Oct 2009
Thanks Given: 4,266
Thanks Received: 6,199


NOCOMPRRRENDO View Post
Hello everyone.
I need my strategies to talk to each other. I would like if one strategy is active, the others are not. Is it possible to do this?

Thank you.

You can achieve it by using a global variable that would be incremented when a trade is entered and decremented when a trade is terminated.

 
Code
public static class GlobalVariables
{
    private static readonly object lockObject = new object();
    private static int activeTradeCount = 0;

    public static int ActiveTradeCount
    {
        get
        {
            lock (lockObject)
            {
                return activeTradeCount;
            }
        }
        set
        {
            lock (lockObject)
            {
                activeTradeCount = value;
            }
        }
    }
}
You can use the GlobalVariables.ActiveTradeCount property to track the number of active trades across strategies. By accessing this property, you can check if any other strategy is currently managing an active trade. Make sure to update the GlobalVariables.ActiveTradeCount value accordingly when entering or exiting trades in each strategy.

 
Code
// Check to do before entering a trade in each strategy running concurrently
if (GlobalVariables.ActiveTradeCount == 0)
     GlobalVariables.ActiveTradeCount++;
     // add you code to enter a new trade here


Reply With Quote
Thanked by:
  #5 (permalink)
 NOCOMPRRRENDO 
MALAGA, ESPAŅA
 
Experience: None
Platform: NINJATRADER
Trading: FUTURES
Frequency: Every few days
Duration: Hours
Posts: 4 since Jul 2021
Thanks Given: 1
Thanks Received: 1

Excellent!!.

As soon as I can I will try it.

Thanks for everything


Started this thread Reply With Quote




Last Updated on June 15, 2023


© 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