NexusFi: Find Your Edge


Home Menu

 





Anyone using TCP to communicate between Indicator and Strategy?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one vantojo with 5 posts (0 thanks)
    2. looks_two sam028 with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 GregLGTP with 1 posts (0 thanks)
    1. trending_up 2,145 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Anyone using TCP to communicate between Indicator and Strategy?

  #1 (permalink)
 vantojo 
Vilcabamba, Ecuador
 
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012

I'm using global variables to communicate between indicators and strategy and it is working pretty good.

But I would like to have the two communicate via TCP/IP on 127.0.0.1 and decouple the communication from the tick datafeed (i.e. OnBarUpdate, etc)

I've started the initial coding but it seems I am going to hit a lot of snags, since I have not coded TCP server/client before in C#.

Has anyone done this yet?

Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Build trailing stop for micro index(s)
Psychology and Money Management
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


I did that, and you will easily find a bunch of socket examples.
On the same host it's more efficient and more "logic" to use named pipes.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #4 (permalink)
 vantojo 
Vilcabamba, Ecuador
 
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012

I would prefer to use TCP over Named Pipes so it could scale in the future across the internet.

But, I'm not finding the examples on BigMike....with the search...

Can you point me to one or two for Ninja Indicator/Strategy communication?

Thanks

Started this thread Reply With Quote
  #5 (permalink)
 GregLGTP 
Austin, TX
 
Experience: Beginner
Platform: NinjaTrader
Broker: NT Broker
Trading: ES
Posts: 121 since Mar 2015
Thanks Given: 258
Thanks Received: 70

I have used WCF to achieve inter-process communication on a Windows machine. This can be set up to be between machines over the local or even the internet. I found it a lot easier than trying to code the TCP interface.

Blessings & Good Trades
Reply With Quote
  #6 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

It's pure C# so search for C# example like here , not NinjaScript examples.




vantojo View Post
I would prefer to use TCP over Named Pipes so it could scale in the future across the internet.

But, I'm not finding the examples on BigMike....with the search...

Can you point me to one or two for Ninja Indicator/Strategy communication?

Thanks


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
 vantojo 
Vilcabamba, Ecuador
 
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012


sam028 View Post
It's pure C# so search for C# example like here , not NinjaScript examples.

Yes, I found lots of those.

Looks like I need to backup and study TCP, and not expect any plug in code to get this going quickly.

There is synchronous and it appears that starting a new Thread for this is best otherwise the TCP runs in the same thread as the strategy or indicator. So that includes both sides of the communication needing to be Threaded.

Then async is something different and .NET manages the Threads.

I have the server up and accepting connections, but in Ninja OnTermination I Stop() the server.listener and of course it does not like that....because the Listener is in a blocked state....

And, if I don't Stop() the listener OnTermination, then the IP Address/Port is locked and not available and the strategy cannot start the listener again.

And, on and on... :-)

Ok, this is a longer term project....

Started this thread Reply With Quote
  #8 (permalink)
 vantojo 
Vilcabamba, Ecuador
 
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012


GregLGTP View Post
I have used WCF to achieve inter-process communication on a Windows machine. This can be set up to be between machines over the local or even the internet. I found it a lot easier than trying to code the TCP interface.

OK, the initial view of WCF seems greatly simpler than TCP....I'll look further into it...

Thank you.

Started this thread Reply With Quote
  #9 (permalink)
 Mrbaffalo 
New York
 
Experience: Advanced
Platform: NinjaTrader
Posts: 4 since Nov 2009
Thanks Given: 0
Thanks Received: 1

Thanks guys, really appreciated.
I am starting from MSDN. I know I have to deal with Threads and doing in Ninja isn't so nice...

Anyway thanks to all!
I will keep you posted on the progression!
MrB

Reply With Quote
  #10 (permalink)
 vantojo 
Vilcabamba, Ecuador
 
Experience: Intermediate
Platform: Ninja
Trading: NQ, UB
Posts: 204 since Jul 2012


After reading a little more it seems that WCF has more overhead than TCP.

What I decided to do was to bite the bullet and study TCP .NET when I get time. So, for me this project is on the back burner.

If anyone has done this in Ninja and is willing to share, please post your code.

Thanks

Started this thread Reply With Quote




Last Updated on July 16, 2015


© 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