NexusFi: Find Your Edge


Home Menu

 





Proper Sequence of Executions


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #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?
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
Iran War Prediction Markets: Ceasefire 16%, Ground Invas …
Prediction Markets & Event Contracts
Q1 2026 Shatters All Derivatives Volume Records -- CME H …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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 X 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


© 2026 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 - Downloads - Top
no new posts