Sharing Int values between indicators - NinjaTrader Programming | futures io social day trading
futures io futures trading


Sharing Int values between indicators
Updated: Views / Replies:721 / 4
Created: by Eubie Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Sharing Int values between indicators

  #1 (permalink)
Elite Member
Prague, Czech republic
 
Futures Experience: Beginner
Platform: NinjaTrader/ZF
Favorite Futures: ES, TF
 
Posts: 79 since Jul 2010
Thanks: 41 given, 34 received

Sharing Int values between indicators

Hello traders,

I ran into a problem when developing further SwingRays2 here on futures.io (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
Register to download File Type: zip Sharing_BMT.zip (3.0 KB, 12 views)
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Edmond,Oklahoma,United States
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: ES, CL
 
Posts: 19 since Sep 2010
Thanks: 6 given, 30 received


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)
Elite Member
Prague, Czech republic
 
Futures Experience: Beginner
Platform: NinjaTrader/ZF
Favorite Futures: ES, TF
 
Posts: 79 since Jul 2010
Thanks: 41 given, 34 received

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
Sharing2.mp4 (740.2 KB, 15 views)
Reply With Quote
 
  #5 (permalink)
Elite Member
Edmond,Oklahoma,United States
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: ES, CL
 
Posts: 19 since Sep 2010
Thanks: 6 given, 30 received

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
The following user says Thank You to Caveman for this post:

Reply



futures io > > > > > Sharing Int values between indicators

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharing data between two indicators Erez NinjaTrader Programming 8 May 9th, 2014 11:01 AM
Sharing input values kiasom EasyLanguage Programming 2 August 30th, 2011 02:27 PM
dealing with GetCurrentBidVolume and GetCurrentAskVolume , "long" casting into "int" jmejedi NinjaTrader Programming 4 May 23rd, 2011 10:33 AM
Using negative numbers as private int MXASJ NinjaTrader Programming 2 September 9th, 2009 06:41 AM
Translating EMA-values to ZN-values or visaversa max-td NinjaTrader Programming 17 June 22nd, 2009 04:42 PM


All times are GMT -4. The time now is 03:28 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-18 in 0.10 seconds with 20 queries on phoenix via your IP 54.163.209.109