[cmd] getOID

stable
By Strooth in Miscellaneous Published November 2021 👁 1,469 views 💬 2 comments

Description

---Usage local oid = CC_getOID(true, 1) ----blah get signal then place order if oid == '' and signal == SignalLong then oid = CC_getOID(true, 1, PlaceGoLongOrder(CurrentPrice().close, TradeAmount())) end ** requires ** CheckOpenOrder
HaasScript
-- Author: Strooth
DefineCommand('getOID', 'Get the orderId for the index and side (PositionLong or PositionShort')
local isLong = DefineParameter(DynamicType, 'isLong', 'Accepts either boolean true = long, false = short or enum PositionLong, enum PositionShort', true, '', 'true/false/PositionLong/PositionShort')
local index = DefineParameter(NumberType, 'Index', 'The number/index of the orderId', false, 1, 'Number')
local save = DefineParameter(DynamicType, 'Save', 'Force a save of the orderId to update manually', false, '', 'dynamictype, input, string')
if And(isLong != '', isLong != true, isLong != false) then 
    isLong = IfElseIf(isLong == PositionLong, isLong == PositionShort, true, false, 0)
    if isLong == 0 then 
        LogError('getOID command - inccorrect paramerter for isLong. Please specify true/false or PositionLong/PositionShort')
        return 
    end 
end 
local getOID = function(isLong, index, save) 
    local oid = ''
    if save then 
            if isLong then Save(index..'longorderid', save)
            else Save(index..'shortorderid', save) end 
            return save 
    else
        if isLong then 
            oid = CC_CheckOpenOrder(Load(index..'longorderid', ''))
            Save(index..'longorderid', oid)
        elseif not isLong then 
            oid = CC_CheckOpenOrder(Load(index..'shortorderid', ''))
            Save(index..'shortorderid', oid)
        end
        return oid 
    end 
end

DefineOutput(DynamicType, getOID(isLong, index, save), 'The orderId for the position index and side', 'String, DynamicType')

2 Comments

Sign in to leave a comment.

S
SerumScalperStale about 3 years ago

Pls help. Where to paste this script in signal trigger bot? I get error CC getPID and error CCgetOID.

S
SerumScalperStale about 3 years ago

Where to paste the script getOID and getPID in this script to Signal trigger bot Custom commands?