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)
You want to know how to implement a 1:1 unidirectional Socket connection between
say MyAmazingTriggerGeneratingIndicator, and a receiver, like your enhanced Chart Trader
facility?
So that would involve a "Server Socket" and a "Client Socket" where the server side just
reads whatever comes its way (e.g. "Buy" or "Sell" messages) and potentially does
something like initiating a single contract or fixed size position.
If we keep it very simple, then the solution is corresponding much simpler.
What would be your ideal relationship between a signal generating Indicator, and
your Order Entry module?
What are the primary desirable advantages of such a link? Primarily 1) speed, and/or
2) Accuracy, etc... of course it would be...
But, as they say, "Where you can go; depends upon where you start!" meaning that if
this were a "green field" development, then there's be the Indicator part; and then
there's be a Strategy developed; and Socket comms would be integrated into that
design.
But, I don't know how I would integrate a socket listener into a Chart Trader instance,
although many "hacks" are possible. If code could be added to the Chart Trader, then
an incoming message could DISPATCH a User Interface programmatic "Click" action
onto a Buy button or a Sell button. Yes, this is a hack, but such a thing could be
necessary, depending on where we start travelling either 1) the Yellow Brick Road,
or 2) down the Rabbit Hole. LOL There's always a solution; and every case is
different.
Having said all of those obvious things... I'm sure you'll be thinking a bit more
what you'd ideally like to do...
Generally, NinjaTrader's Chart Trader offers what is known as "Managed Order Entry"
which places constraints on Order Processing, kind of like Training Wheels on a kids
bicycle. It's forgiving, avoids things getting out of control, etc. And that's a Good Thing
considering that most users have only simple needs, and don't want to get into
trouble.
The other method of entering Orders is "Unmanaged Order Entry" which permits
FREE entry of Orders, but requires that all of the ways things can "screw up" are
the responsibility of the programmer, who has Total Freedom in Order Entry...
That's a little bit like designing a Bicycle for the Tour de France; many more
considerations, even though the simile quickly breaks down here, and I'm sorry
I used Bicycling as a primitive explanatory tool. LOL
Thanks for the thought process. That bicycle was a good analogy.
My chart trader, as you might imagine, is using "listeners" to take any action. All the Order activities are under "Unmanaged Order Entry". Hence, any messages detected by a socket listener can be processed just like the button event listeners to process Orders (or I will need to learn also how to fire an equivalent event to the corresponding button). Sounds interesting.
JT
TWYS NWYT(Price Advertises Opportunity; Time Regulates it; Volume Measures its Success/Failure ---- Dalton)
Yeah, but how do we "inject" the listener Socket code? And the code to "Dispatch"
Button presses onto the GUI thread? etc..... I have no idea; but maybe we
can throw some XML at it, and magically connect, say, to a DLL facility
containing the Socket code?
That would be a Super Hack; however, I'm not familiar with Chart Trader and
it's WPF stuff...
I did a quick search and.....
It looks like this "Rat's Nest" is the one we should be looking at, for possible
Chart Trader enhancements via code injection in XML... ??
Just thinking about it makes me throw up a bit in my mouth; but let's consider that
it could possibly be a way forward, I'd think maybe a DLL could be accessed to
( some-how ) insert Socket comms into Chart Trader as a triggering mechanism...
Let me know when you've done it... I'd prefer "real code" myself... Just kidding; not kidding...
[EDIT] In considering this sort of thing in the past, one of the obvious facilities
would be not to do something like Socket comms to your trade initiator; but
to use AutoHotKey (aka AHK) in the Indicator (using its supported DLL) to click buttons at
specific screen locations, thus automating some of the interactivity; but requiring specific
positioning coordinates for the Chart Trader's UI surface. This can work, and is
probably much less of a hack than code injection attempts via XAML.
[...] I poked around this for a while, a while back, in trying to implement a "shift left" action
on Charts; which NinjaTrader engineering flatly refused to help me with; which is why
I never ask them for code support any more, if I can find any way to avoid it...
If you are looking for selected "One Shot" actions on Chart Trader buttons, then
this is a viable way forward. Specific positioning and sizing constraints would
normally apply, unless a specific internal control handle can be used to find
the control in question (I think unlikely). Coordinates could be held in a file, etc.,
but AHK has been around for decades so it quite well developed and supported,
and there is a supported DLL which is easily accessed from C# code in the
originating signal-generating Indicator code, over which we have control.
THIS CODE CONTAINS SNIPPETS ILLUSTRATING HOW AHK COULD BE INTEGRATED
WITHIN AN INDICATOR. DO NOT USE THE CODE, EXCEPT AS A ROUGH SAMPLE
OF HOW AHK FUNCTIONS MAY BE ACCESSED FROM AN INDICATOR.
Ths local AHK scripting support file was:
DrafLeft.txt just contained a few numbers:
...for justtrader to look at:
This code is a mess because it switches and mixes AHK external functions,
with Win32 calls; in a (failed) attempt to get to a satisfactory solution to "drag left"
for chart panels; an issue which I "gave up on" and got no help from Ninja support
despite going to management... can't win 'em all
This code was part of my research, which was later discontinued. But it does illustrate
that "automated button clicks" or other actions via AutoHotKey (aka AHK) can easily
be embedded within an Indicator.
Perhaps, avoiding AHK; just Win32 Mouse functions are sufficient in the end...
so there are alternatives for accomplishing what is desired with Mouse actions, despite
the fact that it is often "brittle" as a general solution...
...but it is true that...
This facility, AutoHotKey has a supported DLL and has been around for decades,
as a solution broadly to automating user interface actions.
As they say, "Don't try this at home, kidz" -- just kidding... LOL
Yeah, but I can see now that an Indicator on the same Chart as
the ChartTrader being used, has direct access to the WPF controls.
That means that there is no need for interprocess communication.
This makes a solution much simpler; and a "shell" indicator that
may enhance the ChartTrader GUI (like you've done)
could simply "host" or "embed"
the type of Indicator we've been discussing here (which generates
"signals") which could be could be integrated to activate Trades...
So it's not the Nightmare I originally imagined; and I'm something
of a "master" at "embedding" Indicators within a much larger
execution context; not by referencing them (the NinjaTrader way)
but by inserting the code and driving data into them thus escaping
from the "limitations" inherent in the standard Indicator model.
If that made no sense to you; it's cuz nobody does it... LOL but
I'd say the path forward from IndicatorEmbedded to sending events
to ChartTrader is relatively straightforward...?
I suppose that the above code is the AutoDragLeft.AHK. Meanwhile, could you please give us the links where we can get AutoHotkey.dll and AutoHotkey.Interop.dll files.
I suppose that the above code is the AutoDragLeft.AHK. Meanwhile, could you please give us the links where we can get AutoHotkey.dll and AutoHotkey.Interop.dll files.
Lolu
There is a huge mature community about AutoHotKey and how to get files.