OrderMan - Ordering interface for NOW + Amibroker

boarders

Well-Known Member
#41
i tried copy pasting into config filer and result is same error...then i tried copying from order entry window and then pasting it into the window itself ....this time it stays there but the moment we delete the last charector like "M" of crudeoilm, it goes blank and throws the error...so it seems the only way is to select scrip from dropdown list
 

TracerBullet

Well-Known Member
#42
i tried copy pasting into config filer and result is same error...then i tried copying from order entry window and then pasting it into the window itself ....this time it stays there but the moment we delete the last charector like "M" of crudeoilm, it goes blank and throws the error...so it seems the only way is to select scrip from dropdown list
ok, ill code workaround for it. Ping me Ammy admin ID when your are ready, we can test it on NFO scrips just to check basic trade workflows
 

boarders

Well-Known Member
#44
problem with scrip solved now and tested live placing order and cancel order.
the problem was with the sequence in submitorder in order.ahk. I am copy pasting the working sequence as follows:

_submitOrder( winTitle ){ // Fill up opened Buy/Sell window and verify

scrip := this._input.scrip
ordertype := this.getNowOrderType()

Control, ChooseString , % scrip.segment, ComboBox1, %winTitle% // Exchange Segment - NFO/NSE etc
Control, ChooseString , % scrip.type, ComboBox7, %winTitle% // Type - XX/PE/CE
Control, ChooseString , % scrip.instrument, ComboBox5, %winTitle% // Inst Name - FUTIDX / EQ etc
Control, ChooseString , % scrip.Symbol, ComboBox6, %winTitle% // Scrip Symbol
Control, ChooseString , % scrip.strikePrice, ComboBox8, %winTitle% // Strike Price for options
Control, Choose, % scrip.expiryIndex, ComboBox9, %winTitle% // Expiry Date - Set by Position Index (1/2 etc)
Control, ChooseString , % ordertype, ComboBox3, %winTitle% // Order Type - LIMIT/MARKET/SL/SL-M
Control, ChooseString , % this._input.prodType, ComboBox11, %winTitle% // Prod Type - MIS/NRML/CNC
Control, ChooseString , DAY, ComboBox12, %winTitle% // Validity - Day/IOC

this._submitOrderCommon( winTitle )
}

pls note that now type is before symbol...selecting type after symbol was rendering the symbol window blank.

Now I will continue to debug regarding target placement etc and revert....Many thanks Tracer Bullet for all your help and guidance....May God Bless You
 

boarders

Well-Known Member
#45
just now I took a live trade on CRUDEOILM using orderman and it placed the SL long entry order which when executed it placed the correct Stoploss exit order, which I modified also through orderman successfully. But target order was not placed...which I will debug tomorrow and revert.

1. entry placement works
2. cancel order works
3. modify order works

todo: target placement
to confirm modify order will work with target once it is working

many thanks TracerBullet for the wonderful utility
 

TracerBullet

Well-Known Member
#46
just now I took a live trade on CRUDEOILM using orderman and it placed the SL long entry order which when executed it placed the correct Stoploss exit order, which I modified also through orderman successfully. But target order was not placed...which I will debug tomorrow and revert.

1. entry placement works
2. cancel order works
3. modify order works

todo: target placement
to confirm modify order will work with target once it is working

many thanks TracerBullet for the wonderful utility
Later can also try adds, if you use them. Adds use same code as new so should work. Only one stop order is used for all, so its qty increases on add trigger.

Also, later, post the control id changes you did for cancelSelectedOpenOrder() / selectOpenOrder() / openModifyOrderForm()
 

boarders

Well-Known Member
#47
summary of all changes done until now.

1. using find-replace, replaced NowOrderNo to NestOrderNo. in all ahk files
2. using find-replace, replaced NowUpdateTime to NestUpdateTime. in all ahk files
3. in OrderMan.ahk: TITLE_NOW := (this shud be same as individual Nest Trader title)


4. following changes in Order.ahk

_openOrderForm(){
global TITLE_NOW, TITLE_BUY, TITLE_SELL

Loop, 5{ // Try upto 5 times
if( this._input.direction == "B" ){
winTitle := TITLE_BUY
WinMenuSelectItem, %TITLE_NOW%,, Orders and Trades, Order Entry, Buy Order Entry // F1 F2 F3 sometimes (rarely) does not work. Menu Does
}
else if( this._input.direction == "S" ){
winTitle := TITLE_SELL
WinMenuSelectItem, %TITLE_NOW%,, Orders and Trades, Order Entry, Sell Order Entry
}
WinWait, %winTitle%,,2
if !ErrorLevel
break
}


----------flow sequencing and comboboxes numbering changed in below part--------------



_submitOrder( winTitle ){ // Fill up opened Buy/Sell window and verify

scrip := this._input.scrip
ordertype := this.getNowOrderType()

Control, ChooseString , % scrip.segment, ComboBox1, %winTitle% // Exchange Segment - NFO/NSE etc
Control, ChooseString , % scrip.type, ComboBox7, %winTitle% // Type - XX/PE/CE
Control, ChooseString , % scrip.instrument, ComboBox5, %winTitle% // Inst Name - FUTIDX / EQ etc
Control, ChooseString , % scrip.Symbol, ComboBox6, %winTitle% // Scrip Symbol
Control, ChooseString , % scrip.strikePrice, ComboBox8, %winTitle% // Strike Price for options
Control, Choose, % scrip.expiryIndex, ComboBox9, %winTitle% // Expiry Date - Set by Position Index (1/2 etc)
Control, ChooseString , % ordertype, ComboBox3, %winTitle% // Order Type - LIMIT/MARKET/SL/SL-M
Control, ChooseString , % this._input.prodType, ComboBox11, %winTitle% // Prod Type - MIS/NRML/CNC
Control, ChooseString , DAY, ComboBox12, %winTitle% // Validity - Day/IOC

this._submitOrderCommon( winTitle )
}
----------------------edit box numbering changed in below----------------

_submitOrderCommon( winTitle ){
global TITLE_TRANSACTION_PASSWORD, AutoSubmit

ControlSetText, Edit5, % this._input.qty, %winTitle% // Qty
if( this._input.price != 0 )
ControlSetText, Edit6, % this._input.price, %winTitle% // Price
if( this._input.trigger != 0 )
ControlSetText, Edit8, % this._input.trigger, %winTitle% // Trigger

if( AutoSubmit ){
ControlClick, Button1, %winTitle%,,,, NA // Submit Order
WinWaitClose, %winTitle%, 2 // Wait for order window to close. If password needed, notify
IfWinExist, %TITLE_TRANSACTION_PASSWORD%
MsgBox, 262144,, Enter Transaction password in NOW and then click ok
}

WinWaitClose, %winTitle%
}

--------------------------------------

5. following changes to OrderBook.ahk.....

a) Removed Pending Qty from readColumnHeaders() - Completed Orders headers and keys

b) readCompletedOrders(){
global TITLE_ORDER_BOOK

this.open()

this.CompletedOrders := {}
this.CompletedOrders.size := 0
index := this._completedOrdersColumnIndex

ControlGet, completedOrdersRaw, List, , SysListView322, %TITLE_ORDER_BOOK%

Loop, Parse, completedOrdersRaw, `n
{
order := new OrderDetailsClass
Loop, Parse, A_LoopField, %A_Tab%
{
if( A_Index == index.orderType )
order.orderType := A_LoopField
else if( A_Index == index.buySell )
order.buySell := A_LoopField
else if( A_Index == index.tradingSymbol )
order.tradingSymbol := A_LoopField
else if( A_Index == index.totalQty )
order.totalQty := A_LoopField
//else if( A_Index == index.pendingQty )
//order.pendingQty := A_LoopField
else if( A_Index == index.price )
order.price := A_LoopField
else if( A_Index == index.triggerPrice )
order.triggerPrice := A_LoopField
else if( A_Index == index.averagePrice )
order.averagePrice := A_LoopField
else if( A_Index == index.status )
order.status := A_LoopField
else if( A_Index == index.NestOrderNo )
order.NestOrderNo := A_LoopField
else if( A_Index == index.NestUpdateTime )
order.NestUpdateTime := A_LoopField
else if( A_Index == index.rejectionReason )
order.rejectionReason := A_LoopField
}
---------------------------------
openModifyOrderForm( NestOrderNo, winTitle ){
global TITLE_ORDER_BOOK

if( this.selectOpenOrder( NestOrderNo ) ){
Loop, 5{
ControlClick, Button1, %TITLE_ORDER_BOOK%,,,, NA
WinWait, %winTitle%,,2
if !ErrorLevel
return true
}
MsgBox, Could not open Buy/Sell Window
return false
}
else{
MsgBox, Order %NestOrderNo% Not Found in OrderBook > Open Orders
return false
}
}

--------------------------------
cancelSelectedOpenOrder(){
global TITLE_ORDER_BOOK

window := "NOW"
windowText := "Cancel These Order"

ControlClick, Button2, %TITLE_ORDER_BOOK%,,,, NA // Click Cancel

WinWait, %window%, %windowText%, 1
WinSet, Transparent, 1, %window%, %windowText%

ControlClick, Button1, %window%, %windowText%,,, NA // Click ok
}


todo:

1. target order placement
2. modify target
3. cancel target
4. adds
5. check AMIbroker chart interface
6. ninja chart interface
 
Last edited:

boarders

Well-Known Member
#48
i was thinking of introducing a wait period between placement of exit stop order and target order. this is because unless we use basket order to place order, we cannot place both sl and target orders together, it has to be one after the other.

pls advise whether it is feasible and where to introduce same (in trade.ahk??)
 

TracerBullet

Well-Known Member
#49
i was thinking of introducing a wait period between placement of exit stop order and target order. this is because unless we use basket order to place order, we cannot place both sl and target orders together, it has to be one after the other.

pls advise whether it is feasible and where to introduce same (in trade.ahk??)
1) In Orderman GUI, you can put both stop and Target together.
2) Orderman will then open SLM order for stop first immediately followed by target Limit order - There is not much delay
3) I do not understand why you want delay between the two. But this can be done in Trade.ahk : trackerCallback().

this._triggerPendingStop() triggers SL order creation, this._handleTargetOrder( this.targetOrder.getPrice() ) triggers target order creation. You can put sleep between two. But it should not effect functionality - only delays it.

Code:
if( this.isEntrySuccessful()  ){									// Entry Successful - Add Entry Order to Position by inserting in executedEntryOrderList

	if( this.isStopPending )										// We have pending stop order - Create/Update Stop order if Entry was successful
		[B]this._triggerPendingStop()[/B]

	this.positionSize += this.newEntryOrder.getOrderDetails().totalQty
	this.executedEntryOrderList.Push( this.newEntryOrder )
	[B]this._handleTargetOrder( this.targetOrder.getPrice() [/B])			// If Entry successful, update target order - Increase target order size
}
So since target order is not being created, put some breakpoints in trackerCallback() and in _handleTargetOrder(). It should be called after Entry is successful - then just go line by line and see where it returns from in _handleTargetOrder(). But first do get some sleep if you havent already.

btw, Target order works for me in NOW ( although i dont use it in trading).
thanks for your efforts, i should be able to release initial version with Nest support in a week or so.
 

boarders

Well-Known Member
#50
many thanks for your guidance.

have troubleshot the target order placement and tried out modify and it places and modifies the target. following was the part corrected: (see the commented out section) in trade.ahk. kindly add same to my earlier mods posting.

_handleTargetOrder( targetPrice ){
global ORDER_TYPE_GUI_LIMIT

if( (targetPrice == 0 || targetPrice = "" || this.positionSize == 0) ){
if( this.targetOrder.isOpen() ){
this.targetOrder.cancel() // Can happen for adds, If target cleared, cancel it
}
return
}

_entryDirection := this.direction
_stopDirection := UtilClass.reverseDirection(_entryDirection)
_prodType := this.stopOrder.getInput().prodType
_stopPrice := this.stopOrder.getPrice()

if( !IsObject( this.targetOrder ) ){
this.targetOrder := new OrderClass
}
// Create/Update Target Limit Order - Target always covers only current Executed position
if( !this._validateTargetPrice(_entryDirection, _stopPrice, targetPrice) )
return

this.targetOrder.setOrderInput( ORDER_TYPE_GUI_LIMIT, _stopDirection, this.positionSize, targetPrice, 0, _prodType, this.scrip )

//if( this.positionSize == 0 ) // Keep Target order pending until we have Entered a position
// return

if( this.targetOrder.isCreated )
this.targetOrder.update()
else
this.targetOrder.create()

}

TODO: UPDATE

1. cancel target
2. adds
3. check AMIbroker chart interface
4. ninja chart interface