NexusFi: Find Your Edge


Home Menu

 





Sharing Int values between indicators


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Caveman with 2 posts (1 thanks)
    2. looks_two Eubie with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 rsmN with 1 posts (0 thanks)
    1. trending_up 2,084 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
 Eubie 
Prague, Czech republic
 
Experience: Beginner
Platform: NinjaTrader/ZF
Trading: ES, TF
Posts: 169 since Jul 2010
Thanks Given: 393
Thanks Received: 134

Hello traders,

I ran into a problem when developing further SwingRays2 here on NexusFi (formerly BMT). The problem: I need one indicator to make an Int value public. So I write SharingIndi, which has a private int and the value of this int is shown to the rest of the world.

 
Code
#region Variables
	private int currBar;
#endregion

...

       protected override void OnBarUpdate()
        {
            currBar = CurrentBar * 2;
	    Print("Indi   -> Bar=" + CurrentBar + " Value=" + CurrBar );
        }
...
        #region Properties
        [Browsable(false)]	
        [XmlIgnore()]		
        public int CurrBar
        {
            get { return currBar; }
        }

        #endregion
Now I want to see whether those CurrBar values are really accesible from outside, so I write another indi.

 
Code
      #region Variables
		private SharingIndi Indi;
       #endregion

	protected override void OnStartUp()
	{
		Indi = SharingIndi();
	}

        protected override void OnBarUpdate()
        {
		Print("Checker -> Bar=" + CurrentBar + " Value=" + Indi.CurrBar );
        }
and running both on the same chart reveals that Indi.CurrBar returns 0 all the time. Namely, the output is like

Quoting 
Indi -> Bar=27 Value=54
Indi -> Bar=28 Value=56
Indi -> Bar=29 Value=58
Indi -> Bar=30 Value=60
Checker -> Bar=0 Value=0
Checker -> Bar=1 Value=0
Checker -> Bar=2 Value=0
Checker -> Bar=3 Value=0
Checker -> Bar=4 Value=0

What am I doing wrong? Support does not help despite I have a live license...Attached are both indis.
Many thanks for any hint,
Daniel


Attached Files
Elite Membership required to download: Sharing_BMT.zip
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
CFTC Launches Innovation Task Force for AI Trading Syste …
Traders Hideout
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
OneChronos Launches First Combinatorial Auction FX Venue …
Currencies
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 Caveman 
Edmond,Oklahoma,United States
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: ES, CL
Posts: 19 since Sep 2010
Thanks Given: 6
Thanks Received: 30


I have imported this zip, and it appears to be working as expected on my end. Are you refreshing your output window? Otherwise the call is proper and the output is as expected.

You have an if statement in the SharingIndi which states to return(quit) if the CurrentBar < 5. You have 5 examples listed. What was the 6th bar output? With this statement intact, the first 5 bars will return 0 since it never gets to the currBar calculation and hence, any reference to the Indi.CurrBar will return 0 WHILE CurrentBar < 5.

Any time you reference something in one indicator from within another, the conditions set within that reference indicator have to be met before variables will be anything other than what they are set to during the Variable or Initialize region.


Reply With Quote
  #4 (permalink)
 Eubie 
Prague, Czech republic
 
Experience: Beginner
Platform: NinjaTrader/ZF
Trading: ES, TF
Posts: 169 since Jul 2010
Thanks Given: 393
Thanks Received: 134

Hello Caveman,

yes Im refreshing my Output window. Attached is a video of how the results appear on my end, mind the TV in the back

In have added a

 
Code
if ( CurrentBar < 5 )
   return;
line into the Checker indi. As Im attaching both indis to an empty chart, I have no idea what might be going wrong.
Thanks again!
Daniel


Attached Files
Elite Membership required to download: Sharing2.mp4
Started this thread Reply With Quote
  #5 (permalink)
 Caveman 
Edmond,Oklahoma,United States
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: ES, CL
Posts: 19 since Sep 2010
Thanks Given: 6
Thanks Received: 30

What you are seeing is the back-data on your data series "Days to load" being ran through the indicator. As these contain no real bar update calls they get fed through your indicator without meeting the CurrentBar rule.

Bottom line is, the information from the sharing indi is making it to the checker. You need to run live data through it to get the 0's to go away. I saw the same behavior on mine, but it cleared as soon as data was being fed in. Back data loaded into a chart is considered historical and is handled differently than live data by the OnBarUpdate method.

Hope this helps.


Reply With Quote
Thanked by:




Last Updated on May 8, 2012


© 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