I did some test with the SampleStrategyTemplate and it works fine for what I'm doing..
I created another Strategy based on this code but I used different entry rules.
I can't find any information on the order code in the Ninja Script so I need some advice on what to do.
Here is some of the code from the SampleStrategyTemplate ( the code in red is the part that I modify and some other code but that's working fine)
if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
{
isAtmStrategyCreated = false; // reset atm strategy created check to false
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) =>
{
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
isAtmStrategyCreated = true;
});
}
I modified this section hoping that I could have a TYPE Double from my own calculations which I would enter into the AtmStrategyCreate() code
AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId)
I want to be able to use the double type instead of the Low[0] and also change order type to stoplimit
For example
I created a double type name buyEntry and put that in place of the Low[0] thinking that would be ok..
AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit, buyEntry, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId)
But I get this message when the strategy is running and conditions are met.
AtmStrategyCreate method error: A stop limit order requires a limit and stop price
I created a AtmStrategy and named it AtmStrategyTemplate so it has the stop limits in there , and that AtmStrategy is called in the code above.
Can anyone help with this? Is there more information on this type of order entry.. I've checked in managed and un-managed orders but can't see any similar code.
Thanks..
Comment