Definition
Allows the user to send a long trade signal request to your Python code to see if there is a long trade signal.
Note: The DSTRemoteShortSignal method has two overrides. Both versions should return true from the python machine learning model if there is a positive short sell trade signal. The first version of the method does not send any additional messages. The second version allows the user to send a message to python as well as receive a message back that can be used to analyze the signal. For example, a confidence level could be sent from python back to NinjaTrader and be used to decide if we should enter a trade. |
Syntax
bool DSTRemoteShortSignal()
bool DSTRemoteShortSignal(string message, ref string receivedMessage)
Parameters
message |
A string used to pass a message to the python code |
receivedMessage |
A ref string used to pass messages from python back to NinjaTrader |
Return value
bool |
DSTRemoteShortSignal will return true if there is a signal to enter a short trade. Please note, this must be set from the python side. |
Examples
|
Sending a trade signal message in a strategy derived from DSTPredictRemoteModelBase, such as DSTPredictRemoteModelTest |
|
public class DSTPredictRemoteModelTest : DSTPredictRemoteModelBase { ... protected override void OnBarUpdate() { // DST Library - The base OnBarUpdate needs to be called for updating the machine learning model data base.OnBarUpdate(); if (Position.MarketPosition == MarketPosition.Flat && BarsInProgress == 0) { // DSTRemoteLongSignal and DSTRemoteShortSignal will call the remote python code // and wait for a response before returning. This is to allow backtesting to // always return the correct response before continuing. if (DSTRemoteShortSignal()) { EnterShort(); } } } } |
|
Sending a message in a strategy derived from DSTPredictRemoteModelBase, such as DSTPredictRemoteModelTest |
|
public class DSTPredictRemoteModelTest : DSTPredictRemoteModelBase { ... protected override void OnBarUpdate() { // DST Library - The base OnBarUpdate needs to be called for updating the machine learning model data base.OnBarUpdate(); if (Position.MarketPosition == MarketPosition.Flat && BarsInProgress == 0) { // DSTRemoteLongSignal and DSTRemoteShortSignal will call the remote python code // and wait for a response before returning. This is to allow backtesting to // always return the correct response before continuing. string receivedMessage = string.Empty; customMessage = CurrentBar + ": short msg"; Print("Strategy " + _StrategyId + " Sending Short Signal Msg: " + customMessage); if (DSTRemoteShortSignal(customMessage, ref receivedMessage)) EnterShort(); if (!string.IsNullOrEmpty(receivedMessage)) Print(" Received Msg: " + receivedMessage); } } } |
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.