NexusFi: Find Your Edge


Home Menu

 





Proper Sequence of Executions


Discussion in EasyLanguage Programming

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




 
Search this Thread

Proper Sequence of Executions

  #1 (permalink)
arashf
Washington, DC
 
Posts: 8 since Jul 2014
Thanks Given: 1
Thanks Received: 0

Hi Guys,
I'm totally a newb to this site and programming. I have been trying to solve this problem for a couple of days now , and i would greatly appreciate any sort of guidance on this subject. I'm missing a line of code that will trigger my "trailing stop" after my "target". Is there a way to always have "TrailingStop" triggered after "Target"?
Here's What i have as of now for long:

//Entry
If Condition1 then buy this bar at close;

//Exits
If marketposition=1 then
begin
Sell ("StopLoss") at xxx Stop;
If condition2 then sell ("Target") (CurrentShares/2) shares at close;
Sell ("TrailingStop")current shares at next bar at xxx stop;
End;

Thank you in advance for your help.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Strategy stop orders partially filled
EasyLanguage Programming
Cheap historycal L1 data for stocks
Stocks and ETFs
Footprint for strategy Builder
NinjaTrader
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
72 thanks
Spoo-nalysis ES e-mini futures S&P 500
21 thanks
Self sabotage reframed
15 thanks
The Trading Pit "Futures VIP" Account Journal
15 thanks
GFIs1 1 DAX trade per day journal
14 thanks
  #3 (permalink)
arashf
Washington, DC
 
Posts: 8 since Jul 2014
Thanks Given: 1
Thanks Received: 0


If it helps, all the buy and sell triggers are based on bar patterns and not set by $ amount target or stops. That's why sometimes "TrailingStop" is triggered before the "Target" is met.

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 484
Thanks Received: 1,629

arashf,

you would need a flag that enables the trailing stop when your target conditions become true. Something like this might work with using a boolean variable called UseTrailingStop:

 
Code
//Entry
If Condition1 then buy this bar at close;

//reset the flag
if marketposition < 1 and UseTrailingStop then
UseTrailingStop = false;

//Exits
If marketposition=1 then
begin
Sell ("StopLoss") at xxx Stop;
If condition2 then 
begin
UseTrailingStop = true;
sell ("Target") (CurrentShares/2) shares at close;
end;
if UseTrailingStop then
Sell ("TrailingStop")current shares at next bar at xxx stop;
End;
Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
arashf
Washington, DC
 
Posts: 8 since Jul 2014
Thanks Given: 1
Thanks Received: 0

A 1000 thanks ABCTG, that is exactly what i was looking for.

Reply With Quote




Last Updated on September 24, 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