Decoupling Strategy and Indicators: A new paradigm for Ninjatrader - NinjaTrader | futures io social day trading
futures io futures trading


Decoupling Strategy and Indicators: A new paradigm for Ninjatrader
Updated: Views / Replies:5,515 / 25
Created: by vantojo Attachments:2

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 90,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
 2  
 
Thread Tools Search this Thread
 

Decoupling Strategy and Indicators: A new paradigm for Ninjatrader

  #11 (permalink)
Elite Member
Zurich Switzerland
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB
Favorite Futures: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 511 received


vantojo View Post
public class MyIndicator_Global
{
public static string Instrument = "";
public static string LongShort = "";
public static double Price = 0;
public static string ATM_Name = "My ATM";
}

This way I do not have to parse a string in the Strategy.

@vantojo
thanks for feedback
I see an advantage in splitting the data on the indicator side.
When I parse prices from different instruments then I have to deal with different length. ES 5618 / 6E 12302 (4 or 5 digits). And sometimes an instrument is in the zone where it flips from 4 to 5 and back from 5 to 4 digits. Such things do complicate my life, but I can live with them.
On the other hand when sending all information with one click, I am confident that everything is on the way.
Do you see other advantages?

@monpere and the rest of the world
Do you see any advantages/disadvantages with this way?

Reply With Quote
 
  #12 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


terratec View Post
@vantojo
thanks for feedback
I see an advantage in splitting the data on the indicator side.
When I parse prices from different instruments then I have to deal with different length. ES 5618 / 6E 12302 (4 or 5 digits). And sometimes an instrument is in the zone where it flips from 4 to 5 and back from 5 to 4 digits. Such things do complicate my life, but I can live with them.
On the other hand when sending all information with one click, I am confident that everything is on the way.
Do you see other advantages?

@monpere and the rest of the world
Do you see any advantages/disadvantages with this way?

Not sue I understand the question

Reply With Quote
 
  #13 (permalink)
Elite Member
Zurich Switzerland
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB
Favorite Futures: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 511 received



monpere View Post
Not sue I understand the question

@monpere
Sometimes it is a bit difficult to understand me as I am German thinking and writing...

We send one string with all the stuff we need. In the strategy we pick the substrings from that string to create the order and the order management stuff etc. It is all sent by one click.
public static string command = "";

vantojo does use for each thing an own variable and therefore does not have to pick substrings etc.
public static string Instrument = "";
public static string LongShort = "";
public static double Price = 0;
public static string ATM_Name = "My ATM";

I know what I (we?) do. His way could make some things easier or riskier or more CPU consuming or whatever. I am thinking about it (as I am always curious) and would like to have some inputs. Like chances with this way, risks etc.

Reply With Quote
 
  #14 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


terratec View Post
@monpere
Sometimes it is a bit difficult to understand me as I am German thinking and writing...

We send one string with all the stuff we need. In the strategy we pick the substrings from that string to create the order and the order management stuff etc. It is all sent by one click.
public static string command = "";

vantojo does use for each thing an own variable and therefore does not have to pick substrings etc.
public static string Instrument = "";
public static string LongShort = "";
public static double Price = 0;
public static string ATM_Name = "My ATM";

I know what I (we?) do. His way could make some things easier or riskier or more CPU consuming or whatever. I am thinking about it (as I am always curious) and would like to have some inputs. Like chances with this way, risks etc.

I send one string to the strategy, and let the strategy parse it and figure out what to do with the command. The more parsing logic in the strategy, the more flexible I find it personally. I parse all strings using REGEX which is pretty powerful for string manipulation. You also only need to run 1 strategy per instrument, because the strategy compares the instrument in the command string to the instrument it is running, in order to consume or ignore the command. These are a sample of some of the command strings I generally send to the strategy.

"GLD, SellReverseNextBar 300 @ 156.71 +40-156.79~0=8 @8:-4 @40:+8 NoFillCancel_2"
"EURUSD, BuyNextBar @ 1.2325 $150+2R=1.25R~5Bars NoFillCancel_4"
"CL, BuyMarket 1 ATM_'FUT 10R' NoFillCancel_2"
"SPY, Chase 2"
"CL, Close"
"CL, Status"
"GLD, MoveTarget+1R"
"SPY, BarTrail 3"
"GLD, PauseStrategy"
etc.


Last edited by monpere; August 17th, 2012 at 10:18 AM.
Reply With Quote
The following user says Thank You to monpere for this post:
 
  #15 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

reply

I am finding the structure I posted to be adequate for my purposes to communicate trade signals from indicator to a strategy. I am not using this for anything other than sending the initial trade signal.

public class MyIndicator_Global
{
public static string Instrument = "";
public static string LongShort = "";
public static double Price = 0;
public static string ATM_Name = "My ATM";
}

Not being a C# guy, this is simple for me. And, personally, I don't like to parse strings much. I prefer to pass data in fixed structures.

With this, I can have several charts open, each with a different instrument, and then the same number of matching strategies running (in Strategy Analyzer), and the signals are not getting confused.

The first thing the strategy does is to see if the MyIndicator_Global.Instrument == Instrument.MasterInstrument.Name

If it matches then we have a signal for the strategy instrument, if not then the script returns. When there is a signal, the strategy processes it then immediately clears the global area so another indicator can write into it.

The disadvantage is that there is just one global communication area shared by multiple instruments. The only time there could be a conflict is if in the almost exact same moment two indicators write a signal into the common area. Unlikely but possible. In this case the first signal would be lost. (Or not, one would need to understand the code execution threading inside Ninja).

I would not write this type of code if it were being used to land a probe on Mars... :-)

My first preference was to have the indicator trigger an event in the matching strategy. This is what my longer term plans are, when I get time. Then there is a direct link between the indicator and the strategy.

Reply With Quote
 
  #16 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


vantojo View Post
I am finding the structure I posted to be adequate for my purposes to communicate trade signals from indicator to a strategy. I am not using this for anything other than sending the initial trade signal.

public class MyIndicator_Global
{
public static string Instrument = "";
public static string LongShort = "";
public static double Price = 0;
public static string ATM_Name = "My ATM";
}

Not being a C# guy, this is simple for me. And, personally, I don't like to parse strings much. I prefer to pass data in fixed structures.

With this, I can have several charts open, each with a different instrument, and then the same number of matching strategies running (in Strategy Analyzer), and the signals are not getting confused.

The first thing the strategy does is to see if the MyIndicator_Global.Instrument == Instrument.MasterInstrument.Name

If it matches then we have a signal for the strategy instrument, if not then the script returns. When there is a signal, the strategy processes it then immediately clears the global area so another indicator can write into it.

The disadvantage is that there is just one global communication area shared by multiple instruments. The only time there could be a conflict is if in the almost exact same moment two indicators write a signal into the common area. Unlikely but possible. In this case the first signal would be lost. (Or not, one would need to understand the code execution threading inside Ninja).

I would not write this type of code if it were being used to land a probe on Mars... :-)

My first preference was to have the indicator trigger an event in the matching strategy. This is what my longer term plans are, when I get time. Then there is a direct link between the indicator and the strategy.

This is pretty much what I do. I also have one communication variable since I trade manually, and there would never be an instance where I would manually enter 2 trades at the exact same moment in time. This is pretty much a direct link into the strategy since the variable you call global is a memory structure accessible by both indicator and strategy. I've had this code working for years, no issues, it is pretty robust.

If you want to have multiple indicators and strategies talking at the same time, you would have to turn the message communication structure into a list queue, and every indicator and strategy will put and scan the queue for their own messages. That way there is no collision of messages.

Reply With Quote
 
  #17 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

advantage

the other advantage of using a structure is that you can have things in the structure that are not strings....

int
double
bool

(don't know if a structure is the right word)

then you don't have to parse and also don't have to do data type conversions

=============

question....in C#, can a queue contain a structure composed of several data types, as my example?

Reply With Quote
 
  #18 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


vantojo View Post
the other advantage of using a structure is that you can have things in the structure that are not strings....

int
double
bool

(don't know if a structure is the right word)

then you don't have to parse and also don't have to do data type conversions

=============

question....in C#, can a queue contain a structure composed of several data types, as my example?

Yes it can.

Reply With Quote
 
  #19 (permalink)
Elite Member
Neuquen, Argentina
 
Futures Experience: Intermediate
Platform: Ninja
Favorite Futures: CL, TF, 6S, NG, sometimes GC
 
Posts: 195 since Jul 2012
Thanks: 25 given, 39 received

reply

good!

Reply With Quote
 
  #20 (permalink)
Elite Member
Zurich Switzerland
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IB
Favorite Futures: ES, 6E, CL
 
Posts: 404 since Sep 2009
Thanks: 64 given, 511 received



vantojo View Post
the other advantage of using a structure is that you can have things in the structure that are not strings....

int
double
bool

(don't know if a structure is the right word)

then you don't have to parse and also don't have to do data type conversions

For a constant (feedback) dataflow like actual account size, risk position value, AvgPrice, filled Quantity etc. it has also some advantages with this structure. But can also be done the other way.

By the way... The constant bidirectional flow has the side effect that you don't need to care about wakeup the strategy.

Reply With Quote

Reply



futures io > > > > Decoupling Strategy and Indicators: A new paradigm for Ninjatrader

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
NinjaTrader 7 Indicators YoderIII NinjaTrader Programming 4 July 24th, 2013 03:35 PM
Ninjatrader indicators without plots jstnbrg NinjaTrader 6 March 2nd, 2011 02:14 AM
How-to import indicators in NinjaTrader ZTR Help, Tutorials, and How-Tos 2 July 21st, 2010 02:06 PM
Fibonacci Indicators for NinjaTrader Fat Tails The Elite Circle 48 July 6th, 2010 11:58 AM
NinjaTrader 7 indicators Big Mike The Elite Circle 31 November 21st, 2009 03:00 PM


All times are GMT -4. The time now is 02:41 PM.

Copyright © 2017 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
Page generated 2017-12-11 in 0.15 seconds with 20 queries on phoenix via your IP 54.226.172.30