NexusFi: Find Your Edge


Home Menu

 





Global Variables and Strategies in Ninja 6.5


Discussion in NinjaTrader

Updated
    1. trending_up 3,851 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)
 
TonyA's Avatar
 TonyA 
Toronto, Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: zenfire
Trading: 6E
Posts: 3 since Aug 2009
Thanks Given: 4
Thanks Received: 1

Hi,

Hoping to get some direction from someone in the forum.

Originally I started down the path of creating a strategy that would use the OCO concept by having a long and a short both created in a strategy and when one order was triggered the other would be cancelled. I researched the Ninja forum and discovered that one cannot place a short and a long from the same strategy ( this is also confirm by Josh in one of his replies). However, some managed to get both orders into the dom by using 2 strategies, one for the long and another for the short. Bertrand mentioned that one could use global variables to acomplish the equivalent of an OCO and once the order is triggered on one side an update to the global variable could be made and the other strategy could just cancel the other side of the order. The use of global variables is not support in the forum and no direction is provided.

this is the ninja forum post
Gloabal Variables? - Page 2 - NinjaTrader Support Forum
look at post 24.

I was hoping someone could kindly point me in the correct direction as to how to create the DLL and access it with the snippet of code provided in ninja forum.

Regards,

Tony


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Iran War Prediction Markets: Ceasefire 16%, Ground Invas …
Prediction Markets & Event Contracts
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
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
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632


There is an easy way to do this, maybe not the cleanest/faster way, but easy: let your variable be a file.
In the Long strategy, if the order is triggered, and their is no "short.txt" file, create a file "long.txt".
In the Short strategy, check if a file named long.txt exists, and don't take the trade if yes.
Much easier to do than writing a .dll which manage a GV.


Success requires no deodorant! (Sun Tzu)
Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
 
TonyA's Avatar
 TonyA 
Toronto, Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: zenfire
Trading: 6E
Posts: 3 since Aug 2009
Thanks Given: 4
Thanks Received: 1

Thank You Sam

Have yet to see the global variable approach anywhere in an example.

However I believe have seen an example of file usage you describe in one of the indicators in the forum.

I'll see if i can find it. At least i will have something to go by.

Thank you kindly

Tony


Started this thread Reply With Quote




Last Updated on November 6, 2010


© 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