Alert and Debug Concepts
<< Click to Display Table of Contents >> Alert and Debug Concepts |
In most scenarios you can use the NinjaScript provided methods for triggering alerts and debugging functionality. However, when building your own custom objects, you may find yourself wanting to use this functionality outside the NinjaScript scope (e.g. when building a NTTabPage for Add Ons).
Instead of Print(), use Output.Process() to write a message.
Instead of ClearOutputWindow(), use Output.Reset() to clear the output window.
// Instead of Print() |
Instead of Alert(), use NinjaTrader.NinjaScript.Alert.AlertCallback() for sending an alert.
Instead of ResetAlert(), use NinjaTrader.NinjaScript.Alert.RearmAlert()
// Instead of Alert() |
Instead of Log(), use NinjaScript.Log() to send a message to the NinjaTrader logs.
Instead of PlaySound(), use Globals.PlaySound() to play a sound.
Instead of SendMail(), use Globals.SendMail() to send a mail.
Tip: Both the Globals.PlaySound() and .SendMail() above could be used in a regular NinjaScript objects as well, however this is not recommended practice since those would not ignore the calls outside State.Realtime which could yield unexpected results. |
// Instead of Log() |
The ErrorCode enumeration can be found in NinjaTrader logs from time to time when an error occurs, and these can provide further clues into the cause of unexpected behavior during your debugging. These error codes are not necessarily related to your code, but they can provide an indication of an issue to address outside of the scope of your code, saving you time in trying to find the source of errors in your code. Below is a list of ErrorCode enum values and their meanings:
NoError |
No errors were thrown |
LogOnFailed |
Failed to log on due to invalid credentials |
OrderRejected |
Broker rejected the current order |
UnableToCancelOrder |
Order cannot be canceled now, but may be successfully canceled later |
UnableToChangeOrder |
Either the exchange or broker does not support order updates for the instrument in question, or the order has not yet been submitted |
UserAbort |
The operation was aborted by the user |
Panic |
An unspecified error was thrown |