Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

Sign in to follow this  
Tradewinds

Quantity of Position Open, Position Quantity

Recommended Posts

There is a way to retrieve the quantity and side of the position open. The symbol must be designated, as you could have multiple positions open with different ticker symbols.

 

GetPositionQuantity(GetSymbolName, GetAccountID)

 

Short Positions are designated by a negative number. This code displays the quantity open on the chart.

 

var: QtyOpen(0);

Once 
begin  
Value1 = Text_new( D, T, H, "x");
end;

QtyOpen = GetPositionQuantity(GetSymbolName, GetAccountID);

Text_SetString(Value1, "       Positions: " + NumToStr(QtyOpen,0));
Text_SetLocation(Value1, D, T, H + 0.02 );
Text_setcolor(Value1, Black);

Share this post


Link to post
Share on other sites

Determining the Quantity Open is important to be able to close a position from code. You need to designate how many of the position to close.

 

If HigherHigh and QtyOpen > 0 then begin
value1 = MarketOrder("OncePerBar", GetAccountID(), "Sell", "Future", GetSymbolName, QtyOpen);
Condition1 = (PlaySound("c:\Wave\CloseLong.wav"));
End;

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.