[CMD]CheckPositionId

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

Description

Usage local positionid = CC_CheckPositionId(Load('positionid', NewGuid())) --- Run bot code, do blah, make teh profitz Save('positionId', CC_CheckPositionId(positionid))
HaasScript
DefineCommand('CheckPositionId', 'Check if the position is closed and return newguid if it is')
local positionId = DefineParameter(DynamicType, 'PositionId', 'The positionId to check', true, NewGuid(), 'NewGuid()')
local checkPid = function(pid)
    if pid then 
        if IsPositionClosed(pid) then 
            if IsAnyOrderOpen(pid) then 
                CancelAllOrders(pid)
            end 
            if GetPositionAmount(pid) == 0 then 
                return NewGuid()
            else return pid
            end 
        else return pid 
        end 
    else return NewGuid()
    end
end
DefineOutput(DynamicType, checkPid(positionId), 'The positionId', '')

1 Comment

Sign in to leave a comment.

M
Miguel_6705 over 2 years ago

good СС_ for optimizing and checking orders