NexusFi: Find Your Edge


Home Menu

 





NinjaTrader and DLL's (creating and loading how-to)


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one rleplae with 16 posts (87 thanks)
    2. looks_two laadari with 10 posts (0 thanks)
    3. looks_3 NJAMC with 6 posts (15 thanks)
    4. looks_4 sam028 with 3 posts (5 thanks)
      Best Posters
    1. looks_one rleplae with 5.4 thanks per post
    2. looks_two ratfink with 2.7 thanks per post
    3. looks_3 NJAMC with 2.5 thanks per post
    4. looks_4 sam028 with 1.7 thanks per post
    1. trending_up 53,114 views
    2. thumb_up 121 thanks given
    3. group 23 followers
    1. forum 45 posts
    2. attach_file 18 attachments




 
Search this Thread
  #31 (permalink)
laadari
morocco
 
Posts: 8 since Jun 2016
Thanks Given: 1
Thanks Received: 0

I wanna posted it but I must before that have more than 5 posts :'(
I tested my library in a simple console project and it's work verry well. This library use an other dll file to export historical data from an other plateform.


Reply With Quote
  #32 (permalink)
laadari
morocco
 
Posts: 8 since Jun 2016
Thanks Given: 1
Thanks Received: 0

Hello;

I want to work with a DLL file to export historical data from an other trading plateform. But I have the error message: "Unhandled exception: unable to read beyond the end of stream".



This is a part of code:

Quoting 
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
.......
}

else if (State == State.Configure)
{
string connectionString = "Server=PCAM1;Database=NinjaTrader_ExportHistoricalData;User Id=sa;Password = n2Ls5kiKojV3839S37rT; ";
export = new ExportHD(connectionString);
Log("_____________---------------State = State.Configure---------------_____________", LogLevel.Information);

}
}


tected override void OnBarUpdate()
{
export.connect("127.0.0.1", 7496, 0);
try
{
export.exportHistoricalData(1, symbolDetails, EndDateTime, Duration, BarSizeSetting, WhatToShow, UserRTH, 1);
}
catch (Exception e)
{
Log("_____________---------------Exception message = " + e.Message + "---------------_____________", LogLevel.Information);
}
finally
{
export.disconnect();
}

}

I wish if you can help me to resolve that


Reply With Quote
  #33 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,860


laadari View Post
Hello;

I want to work with a DLL file to export historical data from an other trading plateform. But I have the error message: "Unhandled exception: unable to read beyond the end of stream".



This is a part of code:

I wish if you can help me to resolve that

I think this has more to do with a problem in the DLL itself, do you have the source code of that DLL ?
are you able to make it work correctly outside NT ?


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #34 (permalink)
laadari
morocco
 
Posts: 8 since Jun 2016
Thanks Given: 1
Thanks Received: 0


rleplae View Post
I think this has more to do with a problem in the DLL itself, do you have the source code of that DLL ?
are you able to make it work correctly outside NT ?

Yes of caurse, I tested it in a console project and it's work as I wish. The DLL file doesn't have any problem.


Reply With Quote
  #35 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,860


laadari View Post
Yes of caurse, I tested it and it's work as I wish. The DLL file doesn't have any problem.

Looks like inside the DLL you are trying to do some TCP/IP socket connection
and that fails, the exception is not properly caught

put

try
{
}
catch
{
}

in your code, inside the DLL, where you try to do things that you are not sure will work
like making a connection to something or reading a file

the stream should give you some clue...


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #36 (permalink)
laadari
morocco
 
Posts: 8 since Jun 2016
Thanks Given: 1
Thanks Received: 0


rleplae View Post
Looks like inside the DLL you are trying to do some TCP/IP socket connection
and that fails, the exception is not properly caught

put

try
{
}
catch
{
}

in your code, inside the DLL, where you try to do things that you are not sure will work
like making a connection to something or reading a file

the stream should give you some clue...

Thinks, I will tested it after.
I have also an ofher problem

Quoting 
Error on calling "OnbarUpdate" method on bar X: Object reference not set to an instance of an object


Reply With Quote
  #37 (permalink)
laadari
morocco
 
Posts: 8 since Jun 2016
Thanks Given: 1
Thanks Received: 0


rleplae View Post
Looks like inside the DLL you are trying to do some TCP/IP socket connection
and that fails, the exception is not properly caught

put

try
{
}
catch
{
}

in your code, inside the DLL, where you try to do things that you are not sure will work
like making a connection to something or reading a file

the stream should give you some clue...

I added the bloc try {} catch() {} but the error persiste


Reply With Quote
  #38 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 2,947 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,860


laadari View Post
I added the bloc try {} catch() {} but the error persiste

that means it does not wrap the code that generates the exception
sometimes you may be suprised where it comes from


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #39 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632

I had the same Stream error message (on NT8) while importing years of market replay data from NT7 but that was from a custom file-system and I think the error was coming from there (the file-system was too slow to handle NT8 queries). So maybe that's not relevant.
In this case it's maybe a threading issue, adding a
 
Code
                            
this.Dispatcher.InvokeAsync(() => {
   
blah blah blah;
  }
); 
may help.


Success requires no deodorant! (Sun Tzu)
Follow me on X Reply With Quote
Thanked by:
  #40 (permalink)
laadari
morocco
 
Posts: 8 since Jun 2016
Thanks Given: 1
Thanks Received: 0


sam028 View Post
I had the same Stream error message (on NT8) while importing years of market replay data from NT7 but that was from a custom file-system and I think the error was coming from there (the file-system was too slow to handle NT8 queries). So maybe that's not relevant.
In this case it's maybe a threading issue, adding a
 
Code
                            
this.Dispatcher.InvokeAsync(() => {
   
blah blah blah;
  }
); 
may help.

Think you Sam;

When I tried it, I get the error message:

Error message
Indicator "MyCustomIndicator": Error on calling "OnBarUpdate" method on bar X: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall

And when I use "try catch", I get:

Error message
Indicator "MyCustomIndicator": Error on calling "OnBarUpdate" method on bar X: Object reference not set to an instance of an object.

I hope you have a solution to that.


Reply With Quote




Last Updated on December 4, 2020


© 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