Usable Margin function code request

Moderator: admin

Usable Margin function code request

Postby Cactus » Thu Aug 25, 2016 1:42 am

May I request code for a function that would return the Usable Margin %? So that I may use it with my strategy. I had previously requested this as an indicator but the function code itself can work too.
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: Usable Margin function code request

Postby Cactus » Thu Aug 25, 2016 2:06 am

Actually this might just solve it

Code: Select all
function checkAccountRow()
    if mAccountRow == nil then
        mAccountRow = core.host:findTable("accounts"):find("AccountID", mAccount);
    else
        mAccountRow:refresh();
    end
end


Then

Code: Select all
function getUsableMargin()
    checkAccountRow();
    return mAccountRow.UsableMargin;
end


lol
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: Usable Margin function code request

Postby Cactus » Thu Aug 25, 2016 3:57 am

And to get the percentage I did
Code: Select all
function getUsableMarginPercent()
   checkAccountRow();
   return (mAccountRow.UsableMargin / mAccountRow.Equity) * 100;
end



I enjoy Indicore SDK 3 much after getting aquainted with the documentation. lua isn't that hard after all it's all nice tables
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 7 guests