Trigger event in Strategy from Indicator - futures io
futures io futures trading



Trigger event in Strategy from Indicator


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Trigger event in Strategy from Indicator

(login for full post details)
  #1 (permalink)
Neuquen, Argentina
 
Experience: Intermediate
Platform: Ninja
Trading: CL, TF, 6S, NG, sometimes GC
 
Posts: 200 since Jul 2012
Thanks: 25 given, 42 received

Hello,

For NT 7

I want to keep a de-coupled architecture, and send an instant trade alert to a running strategy from an indicator.

I want to have one strategy listening for signals from multiple indicators or other strategies. This way I can concentrate the trade management in just one strategy.

I have a static global array working, but then the strategy needs a timer to watch for input.

Would rather just have the indicator send the signal direct to the strategy.

Any suggestions, samples?

How would the strategy "register itself" in the indicator, so the indicator could communicate?

Many thanks

Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(169 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
Gits (Hooglede) Belgium
 
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
 
rleplae's Avatar
 
Posts: 2,991 since Sep 2013
Thanks: 2,437 given, 5,801 received



vantojo View Post
Hello,

For NT 7

I want to keep a de-coupled architecture, and send an instant trade alert to a running strategy from an indicator.

I want to have one strategy listening for signals from multiple indicators or other strategies. This way I can concentrate the trade management in just one strategy.

I have a static global array working, but then the strategy needs a timer to watch for input.

Would rather just have the indicator send the signal direct to the strategy.

Any suggestions, samples?

How would the strategy "register itself" in the indicator, so the indicator could communicate?

Many thanks

Why would you do the order management in a strategy and be stuck to one instrument ?

you could have a small stand alone process outside NT that is listening for the triggers,
and if you like, then create an order through the ATI interface, but keep the order mgt
completely outside of a strategy running.

the strategy is BAD anyway, you close manual an order, the strategy and all it's objects
get resetted, not a good idea for something that will hold you logic...

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
Neuquen, Argentina
 
Experience: Intermediate
Platform: Ninja
Trading: CL, TF, 6S, NG, sometimes GC
 
Posts: 200 since Jul 2012
Thanks: 25 given, 42 received

Well, there would be one strategy running for each instrument. And somehow the indicator would need to match/sync to the strategy with the same Instrument.

I'm not a C# guy or a .Net guy....don't have enough skill to have something "outside" of NT setup.

Yes, I don't like the way the Strategy base is designed in NT...that NT disables the strategy when even a non-attached Chart ATM is closed.

I already do order management in an indicator with OIF. But there are lots of disadvantages to doing this, one being that the backtesting is not integrated with the strategy stats, et cetera. And, no prototypingwith the Strategy Analyzer.

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Gits (Hooglede) Belgium
 
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
 
rleplae's Avatar
 
Posts: 2,991 since Sep 2013
Thanks: 2,437 given, 5,801 received


vantojo View Post
Well, there would be one strategy running for each instrument. And somehow the indicator would need to match/sync to the strategy with the same Instrument.

I'm not a C# guy or a .Net guy....don't have enough skill to have something "outside" of NT setup.

Yes, I don't like the way the Strategy base is designed in NT...that NT disables the strategy when even a non-attached Chart ATM is closed.

I already do order management in an indicator with OIF. But there are lots of disadvantages to doing this, one being that the backtesting is not integrated with the strategy stats, et cetera. And, no prototypingwith the Strategy Analyzer.

I guess you have your answer then...

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,665 since Jun 2009
Thanks: 3,786 given, 4,494 received

You can try using named pipes with objects like NamedPipeClientStream, coding in C# is required but it's not very hard.
Your strategy can listen to this pipe(s) and act depending on what is received.
On the other side indicators or strategies can send "something" to this master strategy.


vantojo View Post
Hello,

For NT 7

I want to keep a de-coupled architecture, and send an instant trade alert to a running strategy from an indicator.

I want to have one strategy listening for signals from multiple indicators or other strategies. This way I can concentrate the trade management in just one strategy.

I have a static global array working, but then the strategy needs a timer to watch for input.

Would rather just have the indicator send the signal direct to the strategy.

Any suggestions, samples?

How would the strategy "register itself" in the indicator, so the indicator could communicate?

Many thanks


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
 
(login for full post details)
  #7 (permalink)
Neuquen, Argentina
 
Experience: Intermediate
Platform: Ninja
Trading: CL, TF, 6S, NG, sometimes GC
 
Posts: 200 since Jul 2012
Thanks: 25 given, 42 received

I was playing with TCP before and it might work...I could assign an instrument to a single port in the loopback and then have that be the matching between indicator ??

this would allow more than one instrument, each instrument having one strategy and possibly multiple indicators talking to it over a singe port

have not looked at named pipes yet....

But, was hoping for something simplier...like

.... having the indicator trigger an event in the (decoupled) strategy

but how to match the two?

Started this thread Reply With Quote
 
(login for full post details)
  #8 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,665 since Jun 2009
Thanks: 3,786 given, 4,494 received


vantojo View Post
I was playing with TCP before and it might work...I could assign an instrument to a single port in the loopback and then have that be the matching between indicator ??

this would allow more than one instrument, each instrument having one strategy and possibly multiple indicators talking to it over a singe port

have not looked at named pipes yet....

But, was hoping for something simplier...like

.... having the indicator trigger an event in the (decoupled) strategy

but how to match the two?

What you can do is:
- in the strategy
-> create a "service" thread
-> this service thread will read what's coming in from a namedpipe
-> if it's for a new instrument create a new thread with a new namedpipe for this specific instrument (which will be the same as the sender's namedpipe)
Then you can play with events in each threads to buy/sell or whatever you want.
I did something like to hedge two different accounts positions, it worked well, you can use the same kind of logic.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
 
(login for full post details)
  #9 (permalink)
Neuquen, Argentina
 
Experience: Intermediate
Platform: Ninja
Trading: CL, TF, 6S, NG, sometimes GC
 
Posts: 200 since Jul 2012
Thanks: 25 given, 42 received

Thank you...will look at named pipes...seems not too hard...

can you post a sample of the service method code?

(just the core, not your private algos...)

:-)

Started this thread Reply With Quote
 
(login for full post details)
  #10 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,665 since Jun 2009
Thanks: 3,786 given, 4,494 received



vantojo View Post
Thank you...will look at named pipes...seems not too hard...

can you post a sample of the service method code?

(just the core, not your private algos...)

:-)

In fact there is more simpler than pipes with TriggerCustomEvent().
You can check this example:
- the indicator TransferToStrategy contains the entry/exit logic (very private algo: buy if bar is up, sell if bar is down )
- the TransferMaster strategy is executing orders signal sent by the indicator
- the TransferSlave strategy is executing orders signal sent by the indicator (which is the opposite of the what TransferMaster sent)

Success requires no deodorant! (Sun Tzu)
Attached Files
Register to download File Type: zip Transfer.zip (3.0 KB, 9 views)
Follow me on Twitter Reply With Quote
 
(login for full post details)
  #11 (permalink)
Neuquen, Argentina
 
Experience: Intermediate
Platform: Ninja
Trading: CL, TF, 6S, NG, sometimes GC
 
Posts: 200 since Jul 2012
Thanks: 25 given, 42 received

I will study this later, but that is exactly the concept I was looking for...

Started this thread Reply With Quote
 
(login for full post details)
  #12 (permalink)
Neuquen, Argentina
 
Experience: Intermediate
Platform: Ninja
Trading: CL, TF, 6S, NG, sometimes GC
 
Posts: 200 since Jul 2012
Thanks: 25 given, 42 received

For another use I've been testing the MessageQueue Class and it looks like it may work very well for this use....

https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue%28v=vs.110%29.aspx

The listener would be waiting to Receive() the message object, while apparently multiple other processes could send messages to the same queue.

The queue possibly could be named uniquely based on the instrument...so an auto trader could be listening for a decoupled message from one or more indicators, for example, on an FDAX queue.

The advantage to the MessageQueue, apparently is that it is an integral part of Windows, for the purpose of Inter Process Communication. So, it should be very fast, and be able to queue up multiple messages easily in milliseconds, from different sources (in the case I'm using it for in this test, to queue alert and trace / debugging messages external to the Ninja Output Window).

The messageQueue.Receive() method needs to be in a separate thread inside a continuous loop, because the Receive() locks the thread it is running in. If not its own thread it will freeze lock NT 7.

Also, it looks like this class needs to be referred to System.Messaging.DLL which is found (for NT 7, Net 3.5) in the Framework V2 directory.

Good luck... :-)

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Trigger event in Strategy from Indicator


Last Updated on October 17, 2017


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



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