I have developed a long only strategy in NT8 that seems to be working ok when trading a small amount of shares but I now need to try to scale it by placing iceberg orders. I have searched the forum for this topic and touched upon it in some prior posts, but the other threads I’ve found aren’t resolved from a code example perspective (and on Google most topics are for developing indicators for identifying iceberg orders, not placing them via ninjascript). I’m thinking of using upwork to try and find a freelancer to code this for me, but posting here first in case anyone already has a code example they can please share.
I am looking for a code example that, when a buy signal is triggered (‘buyFlag’ = true), will place an order for instrument ABC for 1000 shares in an iceberg fashion, waiting for each 200 share small order to fill before placing further small orders. I am imagining the following approach:
//Variables default settings upon setting off the strategy:
buyFlag = false
200ShareOrderPlaced = false
totalSharesFilled = 0
startBuying = false
stopBuying = false
Logic
//first time/first 200 order
If (buyFlag == true
&& 200ShareOrderPlaced ==false
&& totalSharesFilled == 0
&& startBuying == false
&& stopBuying == false)
{
startBuying = true;
place a market buy order for 200 shares
‘200ShareOrderPlaced’ = true
}
confirm once the 200 order is filled
{
totalSharesFilled = totalSharesFilled+200
200ShareOrderPlaced = false
}
//check to see if able to place a further small 200 order
If (buyFlag == true
&& startBuying == true
&& 200ShareOrderPlaced == false
&& totalSharesFilled + 200 <= 1000
&& stopBuying == false)
{
place a market buy order for 200 shares
‘200ShareOrderPlaced’ = true
}
//buy signal has ended - don’t place any more orders (eg maybe price has now moved away too much)
If (startBuying == true && buyFlag == false && stopBuying == false) stopBuying = true
//placing another small order would exceed 1000 shares - don’t place any more orders
If (startBuying == true && buyFlag == true && stopBuying == false && 200ShareOrderPlaced == false && totalSharesFilled + 200 > 1000) stopBuying = true
I’ll need to add some more sophisticated logic to the above (and translate it to exiting logic too) but the above scenario is the core area I’m struggling with and hoping for some code development help please. The core issue is watching and confirming that the full 200 order has been filled - I’m really struggling with this and in the log files there seems to be so many confirmation messages (some seem duplicative but perhaps I’m not familiar yet with the nuances) that I’m nervous about taking a trial and error approach to figuring this out on a live account (and test accounts just fill straight away so may have issues I don’t foresee)
Any help on this would be greatly appreciated. Many thanks in advance
ChainsawDR
Other posts checked:
https://ninjatrader.com/support/foru...ers#post454646
https://ninjatrader.com/support/foru...erg-order-code

Comment