Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
@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?
Can you help answer these questions from other members on NexusFi?
@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.
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.
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.