GetSellTrailPrice function will trail your sell price by the given trail points. You can take action on the trailed price.
Assume, You just shorted axisbank and want to trail by every 0.5 move in your favour A1 = "AXISBANK" B1 = 480.00 (LTP) C1 = 480.00 (Your Shorted Price) D1 = 482.00 (Initial Stoploss) E1 = 0.5 (Trail Points) F1 = GetSellTrailPrice (A1, B1,C1,E1,D1)
At first moment F1 will display your initial stoploss i.e. 482.00 when the ltp touches 479.50 i.e. 0.5 move in your favour, F1 will display 481.5 i.e. your stoploss decreased by 0.5
It will keep on trail for every 0.5 move in your favour. You can take any action based on the F1, say G1 = If(B1> F1, PlaceRegularOrder(),"No HIT")
P.S. The above is very basic example, as usual add static variables to restrict multiple order firing and check of null/invalid values before placing order.
CancelRegularOrder(OrderId) will cancel the passed OrderId if it is OPEN.
and it will not exit any position.
You have to place a opposite with same qty/product to close your regular/exit positions.
GetSellTrailPrice function will trail your sell price by the given trail points. You can take action on the trailed price.
Assume,
You just shorted axisbank and want to trail by every 0.5 move in your favour
A1 = "AXISBANK"
B1 = 480.00 (LTP)
C1 = 480.00 (Your Shorted Price)
D1 = 482.00 (Initial Stoploss)
E1 = 0.5 (Trail Points)
F1 = GetSellTrailPrice (A1, B1,C1,E1,D1)
At first moment F1 will display your initial stoploss i.e. 482.00
when the ltp touches 479.50 i.e. 0.5 move in your favour, F1 will display 481.5 i.e. your stoploss decreased by 0.5
It will keep on trail for every 0.5 move in your favour.
You can take any action based on the F1, say
G1 = If(B1> F1, PlaceRegularOrder(),"No HIT")
The above is very basic example,
as usual add static variables to restrict multiple order firing and check of null/invalid values before placing order.