NexusFi: Find Your Edge


Home Menu

 





Working together strategies


Discussion in NinjaTrader

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




 
Search this Thread

Working together strategies

  #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: 0

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?
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
Increase in trading performance by 75%
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
11 thanks
GFIs1 1 DAX trade per day journal
11 thanks
  #2 (permalink)
 
xplorer's Avatar
 xplorer 
London UK
Site Moderator
 
Experience: Beginner
Platform: CQG
Broker: S5
Trading: Futures
Posts: 5,971 since Sep 2015
Thanks Given: 15,481
Thanks Received: 15,374


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: 0


That's what I thought.

Thank you for your reply.

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


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: 0

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


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