Here is my setup which I hope you find useful. My buttons consist of 4 for buy and 4 for sell:
Notes:
BUY: places a limit order with 1/4 buying power and attaches a stop loss at 99% of last price at time of order. Note, the method suggested by Andrew at the very top didn't work for me and I found out that you couldn't attach a stop loss order with qty = position and price= av.cost as at the time of running the command there is no position to start with. So what I did is send two separate orders with one command, both with 1/4 buying power, one buy limit and one stop market
Breakeven: It first cancels any pending orders (i.e the existing stop that went with original order) and then places a stop order at average purchase price
Sell Half: Assuming you would do this to cash some profit (i.e you are on the profit side), it cancels any pending order, sells half the position, and then places a stop market for half the position at original purchase price.
Close: Sells all and cancels all pending orders
Same but opposite positions for the Short commands
BUY:
ROUTE=LIMIT;Price=Ask+0.05;Share=BP*0.25 ;TIF=DAY+;HANDINST=ANY;SSHARE=0 ;BUY=Send;ROUTE=STOP;StopType=Market;StopPrice=last*0.99;Share=BP*0.25;TIF=DAY+;HANDINST=ANY;SELL=SEND
BREAKEVEN:
CXL ALLSYMB;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos;TIF=DAY+;HANDINST=ANY;SELL=Send
HALVE:
CXL ALLSYMB;ROUTE=LIMIT;Price=Bid-0.05;Share=Pos*0.5 ;TIF=DAY+;HANDINST=ANY;SSHARE=0 ;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos*0.5;TIF=DAY+;HANDINST=ANY;SELL=SEND
CLOSE:
ROUTE=LIMIT;Price=Bid-0.05;Share=Pos ;TIF=DAY+;HANDINST=ANY;SSHARE=0 ;SELL=Send;CXL ALLSYMB
SHORT:
ROUTE=LIMIT;Price=Bid-0.05;Share=BP*0.25 ;TIF=DAY+;HANDINST=ANY;SSHARE=0 ;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=last*1.01;Share=BP*0.25;TIF=DAY+;HANDINST=ANY;BUY=SEND
BREAKEVEN:
CXL ALLSYMB;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos;TIF=DAY+;HANDINST=ANY;BUY=Send
HALVE:
CXL ALLSYMB;ROUTE=LIMIT;Price=Ask+0.05;Share=Pos*0.5 ;TIF=DAY+;HANDINST=ANY;SSHARE=0 ;BUY=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos*0.5;TIF=DAY+;HANDINST=ANY;BUY=SEND
CLOSE:
ROUTE=LIMIT;Price=Ask+0.05;Share=Pos ;TIF=DAY+;HANDINST=ANY;SSHARE=0 ;BUY=Send;CXL ALLSYMB