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)
This is outside the range of Ninja Support, but perhaps someone here knows and will post....
TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state)
Is normally used to trigger a user defined method (custom event) inside the same Strategy or Indicator.
However would it be possible for an Indicator running on a Chart to trigger a custom event in a strategy running in Strategy Analyzer?
(I used to code object oriented client server applications, and this was a standard way of executing code in another object., so there must be something in C# that would allow this?)
Thank you
Can you help answer these questions from other members on NexusFi?
I have looked for a simple way to do this in the past and thought more about what I was trying to do. I was thinking the Strategy is the controller not the indicator. So I poll or call public functions back to the Indicators to accomplish actions such as that which avoids the "child" driving the parent if you will seemed to make things more complex for me, but I think a new set of standard functions.
If you really wanted to do this, you could use public functions in the Indicator to pass values need for the Callback functions. You can see more about that structure from @anachronist here:
You got that right. Custom callbacks are trivial in C or C++, but C# delegates took me several days to figure out. Once you get it working, though, it's pretty easy. I'll show below how to do custom callbacks for entry order fills. I haven't …
Thank you...lots to study, it looks like. Will dig into LOM examples it this week.
From a conceptual level:
In my mind I don't see the need to have a parent-child tightly coupled relationship between the Signal Generator and the Trade Manager.
In a way the Signal Generator should be driving the Trade Manager. The Trade Manager should be in a sleep state until it has something to do...that is, a signal wakes it up or it has an active trade to manage.
Otherwise it is wasting CPU cycles doing nothing.
In the case where the Trade Manager is submitting an ATM it has only to submit an order, and perhaps cancel an unfilled order (if a new signal comes in). The ATM would be doing the actual trade management, leaving the Trade Manager to do nothing.
This is the way I trade exclusively for the past 4 years. All the buttons on the chart are from an indicator. Every button I click sends a text command to the strategy, and the strategy performs that command. Fore example, Pressing the 'Next Bar' button on the chart sends the following command to the strategy '<ATMmgrCmd> CL 09-12, BuyNextBar 1 @ 93.57 +12-93.51~0=9 @6:-3 @12:+6 NoFillCancel_2</ATMmgr>'. This means, put a buy stoplimit for 1 contract at the next bar open (93.57) and manage in the following way stop at 93.51 target +12 ticks At 6 ticks in profit move stop to -3 ticks (@6:-3), at 9 ticks profit move stop to break even (=9) at 12 ticks profit move stop to +6 ticks (@12:+6), if order is not filled after 2 bars cancel the stoplimit entry order (NoFillCancel_2), etc. I can add unlimited number of ATM style trade management just by adding a series of '@x:x' clauses to the command, or changing an open trade management the same way, etc. The communication just using a global style string variable that both the indicator and the strategy can poll and read.
In your Strategy put this code:
public class TradeManagerGlobal {
public static string command = "";
}
...
if ( TradeManagerGlobal.command.Contains("BuyLimit")) ) {
... Parse the string
... Execute commands
TradeManagerGlobal.command=""; // Clear the command, or send back results
}
In your Strategy put this code:
public class TradeManagerGlobal {
public static string command = "";
}
...
if ( TradeManagerGlobal.command.Contains("BuyLimit")) ) {
... Parse the string
... Execute commands
TradeManagerGlobal.command=""; // Clear the command, or send back results
}
I also add a 1 second wake up timer to my strategy to insure that the strategy execute any command within 1 second of a button press on the chart.
And of course the strategy can communicate any results back to the strategy using the same TradeManagerGlobal.command string, or different similarly defined string variable. Anything can communicate with that strategy, even a chart for a different instrument, if desired.
Thanks so much for sharing your approach on this.
It works well.
It would be great if you could provide some more detail on that 1 sec. wake up timer. I don't even know where to start on that one. If you could share the code that would be awesome!