NexusFi: Find Your Edge


Home Menu

 





Global variables in NT


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Geir with 6 posts (30 thanks)
    2. looks_two Cheech with 5 posts (1 thanks)
    3. looks_3 shodson with 4 posts (10 thanks)
    4. looks_4 Zondor with 3 posts (4 thanks)
      Best Posters
    1. looks_one Geir with 5 thanks per post
    2. looks_two shodson with 2.5 thanks per post
    3. looks_3 drmartell with 1.5 thanks per post
    4. looks_4 Zondor with 1.3 thanks per post
    1. trending_up 17,964 views
    2. thumb_up 51 thanks given
    3. group 20 followers
    1. forum 24 posts
    2. attach_file 5 attachments




 
Search this Thread

Global variables in NT

  #21 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709


Cheech View Post
OK thank you, I will do that, give it a shot, and report the results.

That said, the second problem is that after the historical data is plotted (correctly) they go out of sync. I didn't modify any of the original code when I added in the locks and at this point not sure if the original code worked. Should the locks have prevented this from happening or is there something missing in the original code?

I'm not sure what "out of sync" means. I need to move on, maybe someone else can help you from here. Since you don't have any/much programming experience this could get very time-consuming for me. I just thought I'd point out some quick-to-find things for you. You can always try here or here or here as well for further help.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
The following user says Thank You to shodson for this post:

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
67 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
Battlestations: Show us your trading desks!
43 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #22 (permalink)
 Cheech 
Mesa, AZ/USA
 
Experience: Intermediate
Platform: NinjaTrader, ThinkorSwim
Broker: AMP Futures/CQG, TDA
Trading: Currency Futures, my Harley Davidson
Posts: 107 since Jun 2012
Thanks Given: 43
Thanks Received: 133


shodson View Post
I'm not sure what "out of sync" means. I need to move on, maybe someone else can help you from here. Since you don't have any/much programming experience this could get very time-consuming for me. I just thought I'd point out some quick-to-find things for you. You can always try here or here or here as well for further help.

BTW, I am a retired programmer/analyst but C# is not a language that I know. The out of sync condition as shown in the screenshot means the plots don't match.


Ok, thanks for your help.

Reply With Quote
The following user says Thank You to Cheech for this post:
  #23 (permalink)
 antonma 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader, cTrader
Trading: Currency Futures
Posts: 7 since Aug 2014
Thanks Given: 4
Thanks Received: 4


Hi,

what I do if I want to share data between more indicators is a Singleton Pattern class. This ensures, that only one instance can be exist at one time. Just google for Singleton Pattern C#

So the class could look like this:

 
Code
public class TSMTFHistory
{
        private static double _OnBidVolumeHistory;
	private static double _OnAskVolumeHistory;		
		
	private static readonly TSMTFHistory _TSMTFHistoryInstance = new TSMTFHistory();

        // Explicit static constructor to tell C# compiler
        // not to mark type as beforefieldinit
        static TSMTFHistory()
        {
			
        }

        private TSMTFHistory()
        {
			
        }

        public static TSMTFHistory TSMTFHistoryInstance
        {
            get
            {
                return _TSMTFHistoryInstance;
            }
        }
       
       public void AddBidVolume(double value)
	{
		_OnBidVolumeHistory += value;
	}
		
	public double GetBidVolume()
	{
		return _OnBidVolumeHistory;
	}

}
So you can do some write operation in indicators like this:
 
Code
TSMTFHistory.TSMTFHistoryInstance.AddBidVolume(bid);
And read like this:
 
Code
TSMTFHistory.TSMTFHistoryInstance.GetBidVolume();

For me it works fine. Hope this helps.

Reply With Quote
The following 2 users say Thank You to antonma for this post:
  #24 (permalink)
 Cheech 
Mesa, AZ/USA
 
Experience: Intermediate
Platform: NinjaTrader, ThinkorSwim
Broker: AMP Futures/CQG, TDA
Trading: Currency Futures, my Harley Davidson
Posts: 107 since Jun 2012
Thanks Given: 43
Thanks Received: 133


Geir View Post
Hi drmartell

I have not heard of similar problems and I have no idea what this could be.

I guess that Ninja Trader does not provide support when it comes to custom code, but they do provide a framework in which it is possible to program the platform. And when this framework starts behaving strangely in some instances, then I assume that they would be interested in investigating the issue.

I hope this helps.

Regards
Geir

@Geir

I had that exact same problem, indicators compiled with no errors but all of my custom indicator disappeared, but were in the Indicators directory. I contacted Ninja support and after compiling several indicators with no errors he upgraded my release level (I was only 1 level behind) and when that didn't fix the problem we started removing these indicators, which solved the problem.

The original indicators first posted worked fine, but when I updated the code to include making the DataTable private and included the global locking mechanism the problem occurred, As I stated once all of the indicators were removed the problem went away.

I haven't gotten back to it yet but once I do I will be more methodical in doing the updates and see if I can at lease identify where it's getting broken.

Reply With Quote
  #25 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

Project goals:

Create indicator that will, for each instrument of interest, calculate the prior day OHLC, overnight (Globex) HL, prior day VWAP, current day VWAP , and SD of current day VWAP, and store the data in a singlet class, or a file.

Create indicators that recover the stored data and display those levels on any chart of any of the instruments of interest. So that you don't have to calculate the same things on a gazillion different charts.

Even better would be if @NinjaTrader calculated these and made them available from their historical and real time data servers.

"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
“Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014
“The greatest shortcoming of the human race is our inability to understand the exponential function.”
Prof. Albert Bartlett
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
The following user says Thank You to Zondor for this post:





Last Updated on March 31, 2016


© 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