NexusFi: Find Your Edge


Home Menu

 





Sharing data between two indicators


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Erez with 3 posts (1 thanks)
    2. looks_two TimeTrade with 3 posts (8 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 ghostpipper with 1 posts (0 thanks)
    1. trending_up 3,606 views
    2. thumb_up 9 thanks given
    3. group 7 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Sharing data between two indicators

  #1 (permalink)
 Erez 
Haifa,,,
 
Experience: Intermediate
Platform: NinjaTrader
Broker: CQG
Trading: Futures
Posts: 186 since Mar 2011
Thanks Given: 181
Thanks Received: 869

I'm looking for method to share (communicate) data between two indicators.
Both indicators need to be attached to the same chart.
Call one indicator from within another one is not an option, as it limits plot options in the called one.
At first stage I want to keep it simple, so one indicator need only to send/outputs data and the second one only to read it.
DataSeries is the preferred data type I would like to use, so it can be used for both,historical and real-time.

Any suggestions?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - May 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
26 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
20 thanks
  #3 (permalink)
 TimeTrade 
Erfurt Germany
 
Experience: Master
Platform: rtMagic, NinjaTrader
Broker: AMP/CQG, IAB
Trading: ES, 6E, FDAX, FGBL
Posts: 338 since Aug 2011
Thanks Given: 54
Thanks Received: 461



Erez View Post
I'm looking for method to share (communicate) data between two indicators.
Both indicators need to be attached to the same chart.
Call one indicator from within another one is not an option, as it limits plot options in the called one.
At first stage I want to keep it simple, so one indicator need only to send/outputs data and the second one only to read it.
DataSeries is the preferred data type I would like to use, so it can be used for both,historical and real-time.

Any suggestions?

using the same "base class" and comunicate / datashare over static public class variable of this base class

myStorageIndiClass : Indicator
static valuelist = new list<double>

myWorkTool1 : myStorageIndiClass
valuelist.Add(Close[0])

myWorkTool2 : myStorageIndiClass
Close[0]=Mean(valuelist)

Reply With Quote
Thanked by:
  #4 (permalink)
 Erez 
Haifa,,,
 
Experience: Intermediate
Platform: NinjaTrader
Broker: CQG
Trading: Futures
Posts: 186 since Mar 2011
Thanks Given: 181
Thanks Received: 869


TimeTrade View Post
using the same "base class" and comunicate / datashare over static public class variable of this base class

myStorageIndiClass : Indicator
static valuelist = new list<double>

myWorkTool1 : myStorageIndiClass
valuelist.Add(Close[0])

myWorkTool2 : myStorageIndiClass
Close[0]=Mean(valuelist)

Thanks @TimeTrade, can you give more details? I'm not sure I completely understand your concept.

This is how the code shall looks from sender side?
How it should look from receiver side?
 
Code
 
namespace NinjaTrader.Indicator
{
    public class myStorageIndiClass : Indicator
    {
  public static valuelist = new list<double>;
 
        protected override void Initialize()
        {
        }
        protected override void OnBarUpdate()
        {
          valuelist.Add(Close[0]);
        }
 }
}

Started this thread Reply With Quote
  #5 (permalink)
 TimeTrade 
Erfurt Germany
 
Experience: Master
Platform: rtMagic, NinjaTrader
Broker: AMP/CQG, IAB
Trading: ES, 6E, FDAX, FGBL
Posts: 338 since Aug 2011
Thanks Given: 54
Thanks Received: 461


Erez View Post
Thanks @TimeTrade, can you give more details? I'm not sure I completely understand your concept.

This is how the code shall looks from sender side?
How it should look from receiver side?
 
Code
 
namespace NinjaTrader.Indicator
{
    public class myStorageIndiClass : Indicator
    {
  public static valuelist = new list<double>;
 
        protected override void Initialize()
        {
        }
        protected override void OnBarUpdate()
        {
          valuelist.Add(Close[0]);
        }
 }
}

 
Code
 
file 1:
namespace NinjaTrader.Indicator
{
    public class myStorageIndiClass : Indicator
    {
        public static valuelist = new list<double>;
    }
}

file 2:
namespace NinjaTrader.Indicator
{
    public class myWriteIndi : myStorageIndiClass
    {
        protected override void OnBarUpdate()
        {
          valuelist.Add(Close[0]);
        }
}

file 3:
namespace NinjaTrader.Indicator
{
    public class myReadIndi : myStorageIndiClass
    {
        protected override void OnBarUpdate()
        {
         // use try or count check to prevent problems with empty lists !!!
          Close[0]=valuelist[0];
        }
}

Reply With Quote
  #6 (permalink)
 Erez 
Haifa,,,
 
Experience: Intermediate
Platform: NinjaTrader
Broker: CQG
Trading: Futures
Posts: 186 since Mar 2011
Thanks Given: 181
Thanks Received: 869

Thanks, I'll test it.

I guess that I can use more than one instance of this in the same chart simultaneously, because the classes are not static.


TimeTrade View Post
 
Code
 
file 1:
namespace NinjaTrader.Indicator
{
    public class myStorageIndiClass : Indicator
    {
        public static valuelist = new list<double>;
    }
}
 
file 2:
namespace NinjaTrader.Indicator
{
    public class myWriteIndi : myStorageIndiClass
    {
        protected override void OnBarUpdate()
        {
          valuelist.Add(Close[0]);
        }
}
 
file 3:
namespace NinjaTrader.Indicator
{
    public class myReadIndi : myStorageIndiClass
    {
        protected override void OnBarUpdate()
        {
         // use try or count check to prevent problems with empty lists !!!
          Close[0]=valuelist[0];
        }
}


Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 TimeTrade 
Erfurt Germany
 
Experience: Master
Platform: rtMagic, NinjaTrader
Broker: AMP/CQG, IAB
Trading: ES, 6E, FDAX, FGBL
Posts: 338 since Aug 2011
Thanks Given: 54
Thanks Received: 461


Erez View Post
Thanks, I'll test it.

I guess that I can use more than one instance of this in the same chart simultaneously, because the classes are not static.

You can all do, if you have this self programmed... for more instances you cad add a key(=instance) based dictionary for select the right storeage container... or any other way (example the "register" concept with a unique name on Init and the storage shows the exist of this, if yes return the right container, if no create a new container and return the new value,...)
The only problem: you must understand the logic and know the "C# way" for realize this

Reply With Quote
Thanked by:
  #8 (permalink)
 ghostpipper 
rockford
 
Experience: Beginner
Platform: ninjatrader
Trading: oil
Posts: 43 since Apr 2012
Thanks Given: 3
Thanks Received: 22

Hi TimeTrade

I get the following error trying to compile file1

Invalid token '=' in class, struct, or interface member declaration


TimeTrade View Post
 
Code
 
file 1:
namespace NinjaTrader.Indicator
{
    public class myStorageIndiClass : Indicator
    {
        public static valuelist = new list<double>;
    }
}

file 2:
namespace NinjaTrader.Indicator
{
    public class myWriteIndi : myStorageIndiClass
    {
        protected override void OnBarUpdate()
        {
          valuelist.Add(Close[0]);
        }
}

file 3:
namespace NinjaTrader.Indicator
{
    public class myReadIndi : myStorageIndiClass
    {
        protected override void OnBarUpdate()
        {
         // use try or count check to prevent problems with empty lists !!!
          Close[0]=valuelist[0];
        }
}


Reply With Quote
  #9 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,220
Thanks Received: 101,610

Check a newer thread here:



Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on May 9, 2014


© 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