Is there is a Way?

gopiramnath
I am trying to write my strategy in vba as follows

String TradeDirection = "none"
uplopen = GetRTD("NSE","UPL","Open")
uplltp = GetRTD("NSE","UPL","last")
uplqty = GetPositions("NSE","UPL",Qty")
uplprofit = GetPositions("NSE","UPL",pnl)

if (uplltp > uplopen and uplqty = 0 and uplprofit = 0) TradDirection = "buy"
if(uplltlp <uplopen and uplqty = 0 and uplprofit = 0) TradeDirection = "sell"

When I am trading for the first time when the day open getpositions returns a empty value.
because of this I get repeated order.

Is there is a way?
  • trade_then
    why don`t you make extra variables. which inform if first order has been placed or not and only then check for positions i.e if your trade is MIS instead of CNC.

    i don`t remember VBA syntax but logically:

    if ( firstOrderPlaced == true ) then
    checkPositions
    if ( YourCriteriaSatisfies ) then
    setTradeDirection
    placeOrder
    else
    if ( YourCriteriaSatisfies ) then
    setTradeDirection
    placeOrder
    firstOrderPlaced = true

    and similarly for other checks also

    Thanks
    Regards
Sign In or Register to comment.