Share Data between two Charts - NinjaTrader Programming | futures io social day trading
futures io futures trading


Share Data between two Charts
Updated: Views / Replies:898 / 20
Created: by user10 Attachments:4

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 100,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
 4  
 
Thread Tools Search this Thread
 

Share Data between two Charts

  #1 (permalink)
Dresden + Germany
 
 
Posts: 17 since Feb 2018
Thanks: 10 given, 5 received

Share Data between two Charts

Hello Community,

I want to exchange data between two charts.
With Streamreader I write data from Chart Write to an SSD and read the data in Chart Read with streamwriter.
Because the process is quite slow, I want to speed up the process.

For this I use a static variable, which real-time transmits the data correctly.
double readtestvalue = Write.writetestvalue ==> works

My problem is the historical representation of the data
The assignment ReadArray [0] = Write.WriteArray [0];
is accepted by the compiler but leads to a runtime error (missing object instance)

Write [] readArray = new Write [];
Does not solve the problem ....

How would you solve the problem?

1. Is it correct to transfer the data with an array?
2. My WriteArray is public static ==> As far as I know, using static in Read does not require a constructor
Does the runtime error result for other reasons?
3. I tried to transfer the data via a property in Write.
The public property in Write is not visible in Read ==> how do I access from Chart1 a property in Chart2?
Is the property in Ninjatrader 8 read-only?
4. Are there examples in the community for my concern?

Many thanks for the support!

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)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,651 since Dec 2012
Thanks: 17,403 given, 8,353 received



user10 View Post
Write [] readArray = new Write [];
Does not solve the problem ....

You still need to allocate actual space for the array, e.g.

 
Code
public static double[] values = new double[8];

Remember that you are responsible for any synchronisation (unlike the native NT DataSeries), and also that any recompile needs a reload of all charts that are using global data, otherwise the connections are lost.

Cheers

Travel Well
Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #4 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,651 since Dec 2012
Thanks: 17,403 given, 8,353 received


user10 View Post
The public property in Write is not visible in Read ==> how do I access from Chart1 a property in Chart2?
Is the property in Ninjatrader 8 read-only?

You need to use the class name as part of the reference, e.g.

 
Code
public static class myData
{
    public static int fred;
}

...

myData.fred = 3;

The values are not read-only, but connections do get lost when compiling, all charts need to be F5'd or re-opened. Global data does work fine under NT and there are plenty of code examples on the forum, just use the search facility, it does however need care, as do most good things.

Cheers

Travel Well
Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #5 (permalink)
Dresden + Germany
 
 
Posts: 17 since Feb 2018
Thanks: 10 given, 5 received

Thanks for the hint.
I can now access the Write.WriteArray.

However, the data should be presented historically.
This works neither with (State = = State.Historical) nor with OnBarUpdate.

for (int i = 0; i <ReadArray.Length; i ++)
ReadArray [0] = Write.WriteArray [0];
or
ReadArray [i] = Write.WriteArray [i];
only shows the current data.

How can I present the historical data?
Many Thanks!

Reply With Quote
The following user says Thank You to user10 for this post:
 
  #6 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,651 since Dec 2012
Thanks: 17,403 given, 8,353 received


user10 View Post
Thanks for the hint.
I can now access the Write.WriteArray.

However, the data should be presented historically.
This works neither with (State = = State.Historical) nor with OnBarUpdate.

for (int i = 0; i <ReadArray.Length; i ++)
ReadArray [0] = Write.WriteArray [0];
or
ReadArray [i] = Write.WriteArray [i];
only shows the current data.

How can I present the historical data?
Many Thanks!

Really depends on what you are trying to do, basically you will have to make use of bar indexing in the indicator OnBarUpdate code using the 'CurrentBar' or BarsSinceSession variables (NT7, I can't be sure about NT8 equivalents as I haven't written code for that for a year or so).

Note that NT uses inverse bar indexing so Close[0] is the current bar, Close[2] is 2 bars earlier.

e.g. in OnBarUpdate

 
Code
Write.WriteArray[CurrentBar] = Close[0]; // assumes your arrays are big enough, else you need wrap around code
Data will only get written to your array on each OnBarUpdate call when the writer chart is first loaded or F5'd (for Historical) and will then be updated on each OnBarUpdate call when live. So your reader chart will only see valid data if the writer chart was loaded first, and again it will only see anything at all if they are both refreshed in that order after a recompile. Once stable and both are running it will update fine but you have no guarantee on individual tick update order between the charts, that's not usually a big deal though. Note that NT8 charts may be running on different threads, not the case in NT7.

I always use simple Print calls to see the ins and outs, but beware opening Output Windows in 2 different workspaces under NT8 as this always uses to crash it (maybe fixed now I haven't tried for a long time.)

Cheers

Travel Well
Visit my futures io Trade Journal Reply With Quote
 
  #7 (permalink)
Dresden + Germany
 
 
Posts: 17 since Feb 2018
Thanks: 10 given, 5 received

Thank you for that information; unfortunately I do not get correct results.

In Chart Write, I set calculations that I want to use in Chart Read.
For the sake of simplicity we assume that in Chart Write with 1000 bars I count a counter from 1 to 1000.
In Chart Write WriteArray [0] correctly displays these numbers for each bar from 1 - 1000.

I would now like to use the result of this calculation in Chart Read (1000 bars).
I assign ReadArray = Write.WriteArray and get the value 1000.
(ReadArray [0] = Write.WriteArray [0] returns the value 0.)

The chart Read should represent all numbers from 1 - 1000 from bar 1 to bar 1000.
I tried to read the ReadArray or the Write.WriteArray with the methods
for (int i = 0; i <(..) Array.Length; i ++) {...}
foreach {...}
while {...}

But I always only get the last value 1000 in Chart Read.

If I print in the chart Read Write.WriteArray [x] at the position x (x = 100, 500, ...), I always get 0;
Is it possible that the data will be lost? But the last value 1000 is present!

The problem should be in the historical assignment.
My WriteArray is one-dimensional and contains no further indexing.
Because the number of bars in both charts is identical, I tried to synchronize the arrays with a counter in the chart read.
Unfortunately, without success: Chart Read tries to load the data and gets no result ....
I am thankful for every hint!

Reply With Quote
 
  #8 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,651 since Dec 2012
Thanks: 17,403 given, 8,353 received


user10 View Post
I am thankful for every hint!

You will need to attach a zip or post or PM the .cs for me to see much further in I think.

Travel Well
Visit my futures io Trade Journal Reply With Quote
 
  #9 (permalink)
Dresden + Germany
 
 
Posts: 17 since Feb 2018
Thanks: 10 given, 5 received

Thank you for your support.
Enclosed a zip file with the example code ..

Attached Files
Register to download File Type: zip WriteRead.zip (4.4 KB, 3 views)
Reply With Quote
The following user says Thank You to user10 for this post:
 
  #10 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,651 since Dec 2012
Thanks: 17,403 given, 8,353 received



user10 View Post
Thank you for your support.
Enclosed a zip file with the example code ..

[deleted here where I wrote about using State.Configure rather than State.DataLoaded but shouldn't matter and I think is a red-herring in any case]

Any global sharing I have done has used static classes outside of the Ninja namespaces, as I'm not sure whether it honours public static declarations inside its own non-static indicator/straegy instances as you are trying to do.

They can still be in the same .cs file, but before the Ninja strategy/indicator, e.g.

public static class myData
{
public static int[] array = new int[1000];
}

The shared area is pre-allocated at compile time so you can delete the OnStateChange allocation code and it is referenced in the same way i.e. test = myData.array[0];

I think this is the better way, let me know.

Cheers

Travel Well
Visit my futures io Trade Journal Reply With Quote

Reply



futures io > > > > > Share Data between two Charts

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Show us your trading desks and win over $5,000 in prizes w/Jigsaw Trading

September
 

Trading Nadex Touch Bracket Contracts Sized Like Micro Futures w/Nadex

Sep 17
 

The Spirituality of Trading w/Dr Brett Steenbarger

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
[ThinkOrSwim]     Would anyone like to Share futures data for backtesting and research miamiflow1012 Platforms and Indicators 0 April 11th, 2017 05:53 AM
Will share Bayesian Estimation Results - Need 6E Tick Historical Data edolphin Reviews of Brokers and Data Feeds 4 April 10th, 2017 07:50 AM
Can you please share 1 minute E6 data? CureNet The Elite Circle 2 September 29th, 2016 02:52 AM
Renko charts on non-tick data? Xyzzy Platforms and Indicators 4 June 1st, 2011 08:47 PM
Chatbox enhancements: Ability to share charts and images Big Mike The Elite Circle 1 July 24th, 2009 03:38 AM


All times are GMT -4. The time now is 04:34 AM. (this page content is cached, log in for real-time version)

Copyright © 2019 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