NexusFi: Find Your Edge


Home Menu

 





modified profit target


Discussion in TradeStation

Updated
    1. trending_up 1,667 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 1 attachments




 
Search this Thread

modified profit target

  #1 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40

happy year and happy holidays to everyone,


i'm trying to code / find a modified version of a profit target.


the profit target automated strategy included in tradestation does fine, but it always closes the whole position.


i would like to be able to drop half my position at say, position +1.5, and keep the other half to be closed by the standard profit target, stop loss strategies.


i'm trying to code it, but can't even get tradestation to return the entry price, much less set the exit properly.


any help would be appreciated, thanks.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

maggtrading,

I would do something like this:

- Open two positions and each with half of the total shares/contracts
- send a limit exit order for the target for the first leg of your entry
- either send a limit exit order for the second target or use the build in Profit Target

You can get the entry price with the reserved word EntryPrice(Num).

Where Num is a numeric expression representing the number of positions ago (up to a maximum of ten).

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40


thanks, i have been working on this development but haven't been able to make it work up to now.



right now the code looks like this, i only modified the structure for the entries/exits based on some information i found on some other internet pages:



if (long entry conditions met)... then begin


buy("hr") (PSize1) Shares next bar at open;
buy("lr") (PSize2) Shares next bar at open;
entr=c;

end;


sell("sl lr") next bar from entry("lr") (entr-sl) stop;
sell("sl hr") next bar from entry("hr") (entr-sl) stop;
sell("pt hr") next bar from entry("hr") (entr+pt2) limit;
sell("pt lr") next bar from entry("lr") (entr+pt1) limit;




setexitonclose;




so far only the first buy command is executed, whether i have the hr or lr command, only the one on top is filled. and, entryprice does not work, i am using close of last bar. if i change it to entr=entryprice; the strategy sells at the same spot it buys at.


are there any evident mistakes in this structure?


thanks.

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

maggtrading,

did you allow multiple entries in one direction? If not Tradestation might simply block the second entry although your code is correct. By default this is not enabled.
Go to the strategy properties and check "Allow up to ... entry orders in the same direction"



I am not sure what you did with EntryPrice, but if you post the code I can take a look at it.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40

ABCTG,



danke schön.



effectively, once i changed the properties for all strategies i can get more than one position at once.


the code above seems to be working, so it should help in case anyone is searching for something similar.


now, i haven't been able to get the true entry price with the reserved word entryprice, the best approximation is - c -, the previous bar's close. i have tried entryprice, entryprice(0) and entryprice(1) but to no avail.

Reply With Quote
  #6 (permalink)
maggtrading
quintana roo, méxico
 
Posts: 84 since Mar 2013
Thanks Given: 222
Thanks Received: 40

in the end i was able to code exactly what i was looking for: a hard limit profit target that drops only a fraction of a position. i share the code in case it can be of help for someone:


more profit target points can be added or removed using the same logic.




inputs: Price(Close),
pt1(1.7),
pt2(4),
psize1(100),
psize2(100);


variables:
MP(0),
ptp1(0),
ptp2(0);



MP = marketposition;




If MP = 1 then begin
ptp1 = Entryprice + pt1;
ptp1 = Entryprice + pt2;

End else
If MP = -1 then begin
ptp1 = Entryprice - pt1;
ptp2 = Entryprice - pt2;

End;



If Marketposition = 1 then begin

sell (psize1) Shares next bar ptp1 limit;
sell (psize2) Shares next bar ptp2 limit;


end;



If Marketposition = -1 then begin

Buy to cover (psize1) Shares next bar ptp1 limit;
Buy to cover (psize2) Shares next bar ptp2 limit;


end;

Reply With Quote
Thanked by:
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

maggtrading,

good job and thanks for sharing it.

Regards,
ABCTG

Follow me on Twitter Reply With Quote




Last Updated on April 16, 2014


© 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