NexusFi: Find Your Edge


Home Menu

 





Multiple Entries and Exits


Discussion in TradeStation

Updated
    1. trending_up 3,577 views
    2. thumb_up 4 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Multiple Entries and Exits

  #1 (permalink)
Hussa
Freiburg Germany
 
Posts: 4 since Apr 2015
Thanks Given: 1
Thanks Received: 0

Hello

Easy Language allows to utilize various entries and exits which is well known like:

Buy("My1stBuy") Next Bar 200 Shares at Market;
Buy("My2ndBuy") Next Bar 100 Shares at High Stop;
Sell("My1stSell") Next Bar From Entry ("My1stBuy")100 shares at High Limit;
Sell("My2ndSell") Next Bar From Entry ("My2ndBuy")50 shares at Low Stop;
if Time = 1500 then Sell next bar at Market;

I would like to get things like EntryPrice("My1stBuy"), EntryPrice("My2ndBuy"), BarsSinceEntry("My1stBuy"), BarsSinceEntry("My2ndBuy"), HighestHigh("My1stBuy"), HighestHigh("My2ndBuy") and others. The syntax I used is obviously not allowed.

Is there another doable procedure?

Could somebody point me in the right direction?


Thank you very much

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
58 thanks
Battlestations: Show us your trading desks!
55 thanks
NexusFi site changelog and issues/problem reporting
48 thanks
What percentage per day is possible? [Poll]
31 thanks
GFIs1 1 DAX trade per day journal
29 thanks

  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Hussa,

you will have to use OOEL for that. Otherwise (afaik) it won't be possible to access that information for a multi-leg position.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
Hussa
Freiburg Germany
 
Posts: 4 since Apr 2015
Thanks Given: 1
Thanks Received: 0


ABCTG,

thanks for taking the time - running the risk of sounding ignorant: what is OOEL?

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Hussa,

no worries you don't sound ignorant, just too lazy to use google .
OOEL stands for Object Oriented EasyLanguage and gives you a lot more control and options in your programming.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #5 (permalink)
Hussa
Freiburg Germany
 
Posts: 4 since Apr 2015
Thanks Given: 1
Thanks Received: 0

ABCTG,

well, thanks for the Google hint.

It sounds that OOEL is surely far above and beyond what I will ever achieve on the programming side of things. Plus I'm still (happily) stuck with TS2000i and have no plans going to TS 9.0 or higher.

I guess that means that my little project is over before it even started.

Thanks again for your help!

Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Hussa,

you are welcome. With TS2000i you'd be stuck indeed. You might want to consider testing your idea in Multicharts as not only can you use your code there, but you can also test your idea. As there it's quite simple to access the values you want.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #7 (permalink)
 aerotrader 
Hong Kong
 
Experience: Advanced
Platform: Matlab, TradeStation, Multicharts
Broker: Tradestation, LMAX
Trading: Forex & Futures
Posts: 5 since Jul 2012
Thanks Given: 0
Thanks Received: 8

Something like this should get you on your way, done without objects


 
Code
Inputs: //
Entry1_lot_size(200),
Entry2_lot_size(100);

Vars: //
MP(0),
My.Real.Position(0),
Number.of.Shares(0),
Bars.Since.Entry1(0),
Bars.Since.Entry2(0),
Entry.Price.Lot1(0),
Entry.Price.Lot2(0),
Highest.High.1(0),
Highest.High.2(0),
Todays.Highest.High(0);


MP=Marketposition;

if date<>date[0] then Todays.Highest.High=-1;

if MP<>MP[1] then
Begin
  Bars.Since.Entry1=0;
  Bars.Since.Entry2=0;
  Number.of.Shares=0;
  Entry.Price.Lot1=0;
  Entry.Price.Lot2=0;
End;

If currentBar=1 then
Begin
  Highest.High.1=High;
  Highest.High.2=High;
  Todays.Highest.High=High;
End;

// Buy 200 shares at 930 or the closest bar to it 
If MP=0 and time >=930 then Buy("My1stBuy") Next Bar Entry1_lot_size Shares at Market;
// find out if you have the shares from the broker
My.Real.Position = GetPositionQuantity(GetSymbolName, GetAccountID);
// How many shares
Number.of.Shares = GetPositionQuantity(GetSymbolName, GetAccountID);
// If we are actually long, keep a track of the number of bars count the number of bars
if (My.Real.Position=1) then Bars.Since.Entry1 = Bars.Since.Entry1+1;
// if you have the first lot, buy the second lot
if ((My.Real.Position=1) and (Number.of.Shares=Entry1_lot_size)) then
Begin
  Entry.Price.Lot1=GetPositionAveragePrice(GetSymbolName, GetAccountID);
  Buy("My2ndBuy") Next Bar Entry2_lot_size Shares at High Stop;
end;
Number.of.Shares = GetPositionQuantity(GetSymbolName, GetAccountID);
if (Number.of.Shares=(Entry1_lot_size+Entry2_lot_size)) then Bars.Since.Entry2 = Bars.Since.Entry2+1;
// Just a simple time rule to sell some of the shares
If MP=1 and time >=1100 and (Number.of.Shares=(Entry1_lot_size+Entry2_lot_size)) then
begin
// Cost of all the shares
  Value1= (GetPositionAveragePrice(GetSymbolName, GetAccountID)*(Entry1_lot_size+Entry2_lot_size));
//Cost of the first lot
  Value2= (Entry.Price.Lot1*Entry1_lot_size);
// Quick divide by zero check
  if Entry2_lot_size>0 then
//Average cost of the second lot is the cost of the second lot divided by the number if shares
  Entry.Price.Lot2=((value1-value2)/Entry2_lot_size);
  Sell("My1stSell") Next Bar From Entry ("My1stBuy")100 shares at High Limit;
  Sell("My2ndSell") Next Bar From Entry ("My2ndBuy")50 shares at Low Stop;
end;

Number.of.Shares = GetPositionQuantity(GetSymbolName, GetAccountID);
// Highest high since Entry 1
If ((MP=1) and(Number.of.Shares=Entry1_lot_size)) then Highest.High.1=highest(High,2);
// Highest high since Entry 2
If ((MP=1) and (Number.of.Shares=(Entry1_lot_size+Entry2_lot_size))) then Highest.High.2=highest(High,2);
// Highest high today
If High>Todays.Highest.High Then Todays.Highest.High=High;

// Get rid of the remainder of the shares at the end of the day and print the info requested
If MP=1 and Time >=1558 then
begin
  Sell next bar at Market;
  Print("I would like to get things like .....");
  Print("My1stBuy Entry Price : ",Entry.Price.Lot1);
  Print("My2ndBuy Entry Price : ",Entry.Price.Lot2);
  Print("BarsSinceEntry My1stBuy : ",Bars.Since.Entry1);
  Print("BarsSinceEntry My2ndBuy : ",Bars.Since.Entry2);
  Print("Highest high My1stBuy : ", Highest.High.1);
  Print("Highest high My2ndBuy : ", Highest.High.2);
  Print("Highest high today : ", Todays.Highest.High);
  Print("This is for educational purposes only, use at your own risk ");
end;

Reply With Quote
The following 4 users say Thank You to aerotrader for this post:
  #8 (permalink)
Hussa
Freiburg Germany
 
Posts: 4 since Apr 2015
Thanks Given: 1
Thanks Received: 0

@aerotrader

Thank you very much for pointing that out. Very helpful indeed.

Reply With Quote





Last Updated on May 14, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts