I am new to attempting to use ATM strategies.
I have been working with the "sampleATMstrategy" that ships with NT.
I also recreated THIS example, and have attached it below(not necessary to download), and is called "TestBed." It will reside in a folder in Strategies called "MaMS". The primary difference between the example linked above, and the one attached, is that I have changed it to a limit order, and changed the way it initially finds a trade(by checking the orderid length).
This brings me to MY problem.
I want to create an ATM strategy, that places a grid of orders. The number of orders and the prices will be a user input. The number of levels and the spacing could vary. I am attaching an IMAGE of what that looks like. You can see, it simply places 5 buy limits below the current price. These orders have been done by an atm strategy I created. This is also attached, and it is called, "orderPlaceReplace."
Also of note, is that I want to orders to continually be replaced(user input option), if it goes on to hit its profit target. But initially, I am just attempting to get the order placement working properly.
My solution to this, was to create a List/Array, and store the price levels and other necessary items, and put the necessary info there. This MOSTLY works now.
The problem is within the callback function. I am wondering if there is a problem with putting List elements into the callback function?
For example, THIS below works fine:
AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], Low[0]-20*myPipSize, TimeInForce.Gtc,
atmStrategyOrderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallbackId) => {
// checks that the call back is returned for the current atmStrategyId stored
if (atmCallbackId == atmStrategyId && atmCallbackErrorCode == Cbi.ErrorCode.NoError)
{
isAtmStrategyCreated = true;
}
});
But this does NOT work as expected. In this snipped, the "i" is used, as this is in a loop that cycles through each of the price levels.
AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, _price[i], _stopPrice[i], TimeInForce.Gtc,
_orderId[i], "AtmStrategyTemplate", _atmStrategyId[i], (atmCallbackErrorCode, atmCallBackId) => {
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == _atmStrategyId[i] /**/)
{
_isAtmStrategyCreated[i] = true;
}
});
Again, the above actually does place the orders on the chart in the way that I want. But, my solution does not seem to generate the proper Id(atmCallBackId) that matches the strategyId generated(atmStrategyId[i]). As such, the right side of that if statement inside AtmStrategyCreate() never evaluates to true.
So the questions,
- are there any issues with using List values IN the AtmStrategyCreate() method?
- does my logic of creating a list of price levels, then looping through that list and individually creating each order make sense?
THanks,
FP

Comment