CloseStrategy()
<< Click to Display Table of Contents >> CloseStrategy() |
Cancels all working orders, closes any existing positions, and finally disables the strategy. This behavior can also be overridden for a given strategy if desired.
Notes: •If you choose to override this method using custom logic, the default behavior of the CloseStrategy() method will NOT be executed. For this reason, it is suggested to call the base implementation of CloseStrategy() method within the virtual override to ensure that the strategy is terminated as designed, otherwise it is your responsibility to correctly manage any working orders or positions. •CloseStrategy() will work of the current strategy position and will not factor in any StartBehavior setting, i.e. calling CloseStrategy() while the script is in a virtual historical position could result in an unwanted position •The default CloseStrategy() handling will be applied to all series of a MultiSeries NinjaScript strategy. |
This method does not return a value.
Syntax
CloseStrategy(string signalName)
Warning: This method can only be call before the State has reached State.Terminated and after the State reaches State.Realtime |
You may choose to override this method using the following syntax:
public override void CloseStrategy(string signalName)
{
}
signalName |
The signal name which will be used to identify the closing order. If no signal name exists or is null, "Close" will be substituted instead. |
Basic usage of CloseStrategy |
---|
DateTime StartTime = new DateTime(); |
Overriding the Default CloseStrategy logic |
---|
public override void CloseStrategy(string signalName) |