Welcome to the Traders Laboratory Forums.
TradeStation Custom Programming Discuss projects, ideas, obstacles in programming with TradeStation.

Reply
Old 10-26-2011, 11:13 AM   #1

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Quantity of Position Open, Position Quantity

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(GetSy mbolName, GetAccountID)

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

Code:
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);
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 10-26-2011, 11:23 AM   #2

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Quantity of Position Open, Position Quantity

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.

Code:
If HigherHigh and QtyOpen > 0 then begin
value1 = MarketOrder("OncePerBar", GetAccountID(), "Sell", "Future", GetSymbolName, QtyOpen);
Condition1 = (PlaySound("c:\Wave\CloseLong.wav"));
End;
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
The Following 2 Users Say Thank You to Tradewinds For This Useful Post:
MadMarketScientist (10-26-2011), zdo (10-26-2011)

Reply

Tags
position quantity, quantity open

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Sizing carltonp Beginners Forum 22 04-28-2012 09:09 AM
When Do You Add to a Position? mslk Trading and the Markets 7 10-27-2011 08:13 AM
Reversing Position Help rickek Coding Forum 0 03-19-2009 03:53 PM
Trading Around a Position RobinHood Beginners Forum 9 09-05-2008 03:01 PM
Exit a Position 156 Beginners Forum 5 07-29-2008 01:10 PM

All times are GMT -4. The time now is 10:02 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.