NexusFi: Find Your Edge


Home Menu

 





Trading System: improve it with 3 Exit


Discussion in EasyLanguage Programming

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




 
Search this Thread

Trading System: improve it with 3 Exit

  #1 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Good morning,

in my archive, I found this Trading System, and the author recommended to do tests with 3 Exit, to improve the efficiency and robustness of the T.S.
If someone could kindly transform the 3 Exit into Easylanguage and insert them into the formula, which I will try one at a time with the use of parentheses: { }.

These are the 3 Exit to be included in the formula; I will also turn them into: (after SellShort): Exit ....:


(after Buy): Exit with a profit after 30 bars, if the closing is less than the exponential moving average of 5 days.
(after Buy): Exit with a limit order if the open profit exceeds 20%.
(after Buy): Exit with a profit if the trade lasts for more than 50 bars.


This is the formula of the T.S. for Tradestation 8 or higher:
-----------------------------------------------------------------

Inputs: length(30), MaxEntryLB(60), MinEntryLB(20), MaxExitLB(30), MinExitLB(10);
Vars: HistVol(O), YestHistVol(O), DeltaHistVol(O), EntryLB(O), ExitLB(O),
YestEntryLB(O), YestExitLB(O);

YestHistVol = HistVol;
HistVol = StdDev(C, length);
DeltaHistVol = (HistVol-YestHistVol) / HistVol;
If CurrentBar = 1 Then EntryLB = 20;
YestEntryLB = EntryLB;
EntryLB = YestEntryLB * (1 + DeltaHistVol);
EntryLB = MaxList(EntryLB, MinEntryLB);
EntryLB = MinList(EntryLB, MaxEntryLB);
YestExitLB = ExitLB;
ExitLB = YestExitLB * (1 - DeltaHistVol);
ExitLB = MinList(ExitLB, MaxExitLB);
ExitLB = MaxList(ExitLB, MinExitLB);
Buy next bar at Highest(High, EntryLB) Stop;
Sellshort next bar at Lowest(Low, EntryLB) Stop;
Sell next bar at Lowest(Low, ExitLB) Stop;
Buytocover next bar at Highest(High, ExitLB) Stop;
Setstoploss(1500);

------------------------------------------------------------------------------

I thank you in advance for your collaboration.

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
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
67 thanks
Battlestations: Show us your trading desks!
48 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #3 (permalink)
Tom1978
Houston Texas
 
Posts: 15 since Dec 2019
Thanks Given: 6
Thanks Received: 11


Only after buy? Not after entering a short position?

Reply With Quote
  #4 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129


Tom1978 View Post
Only after buy? Not after entering a short position?

Hi,
yes, of course, also Sellshort (I would have done it , for not to disturb you too much).
Thank you very much.

------------------------------------------------

{after Buy}: Exit with a profit after 30 bars, if the closing is less than the exponential moving average of 5 days.
{after Sellshort}: Exit with a profit after 30 bars, if the closing is higher than the exponential moving average of 5 days.

{after Buy}: Exit with a limit order if the open profit exceeds 20%.
{after Sellshort}: Exit with a limit order if the open profit exceeds 20%.

{after Buy}: Exit with a profit if the trade lasts for more than 50 bars.
{after Sellshort}: Exit with a profit if the trade lasts for more than 50 bars.

--------------------------------------------------

Reply With Quote
  #5 (permalink)
Tom1978
Houston Texas
 
Posts: 15 since Dec 2019
Thanks Given: 6
Thanks Received: 11

Something like this?

{after Buy}: Exit with a profit after 30 bars, if the closing is less than the exponential moving average of 5 days.
What do you do your trade is profitable after 30 bars, but closing > mov avg 5 days?

{after Sellshort}: Exit with a profit after 30 bars, if the closing is higher than the exponential moving average of 5 days.

{after Buy}: Exit with a limit order if the open profit exceeds 20%.
You can use setprofittarget, but what is the 20%? 20% of what?

{after Sellshort}: Exit with a limit order if the open profit exceeds 20%.

{after Buy}: Exit with a profit if the trade lasts for more than 50 bars.
if marketposition = 1 and barssinceentry = 50 and close>entryprice then sell this bar at close; //market order
or
if marketposition = 1 and barssinceentry = 50 then sell next bar at entryprice limit; //limit order
And what are you going to do if the trade is not profitable after 50 bars?

{after Sellshort}: Exit with a profit if the trade lasts for more than 50 bars.

Reply With Quote
  #6 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

For Tom 1978,

You have a PM.

Reply With Quote
  #7 (permalink)
Tom1978
Houston Texas
 
Posts: 15 since Dec 2019
Thanks Given: 6
Thanks Received: 11


Shaban View Post
For Tom 1978,

You have a PM.

You've got one too!

All the best,
Tom

Reply With Quote
The following user says Thank You to Tom1978 for this post:
  #8 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Hi Tom,

You have another P.M.

Reply With Quote
  #9 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

If it may be useful to someone, I insert here the 3 Exit translated in Esylanguage (thanks to Tom 1978):

If marketposition=1 and close>entryprice and barssinceentry=30 and close<xaverage(close,5) then Sell("LX 30") next bar at market;
If marketposition=-1 and close<entryprice and barssinceentry=30 and close>xaverage(close,5) then Buytocover("SX 30") next bar at market;

If marketposition=1 and close>1.20*Entryprice then Sell("LX target") this bar at close;
If marketposition=-1 and close<0.8*Entryprice then Buytocover("SX target") this bar at close;

If marketposition=1 and close>entryprice and barssinceentry=50 then Sell("LX 50") this bar at close;
If marketposition=-1 and close<entryprice and barssinceentry=50 then Buytocover("SX 50") this bar at close;

Reply With Quote
The following user says Thank You to Shaban for this post:
  #10 (permalink)
Tom1978
Houston Texas
 
Posts: 15 since Dec 2019
Thanks Given: 6
Thanks Received: 11


Hi Shaban,

Did the 3 additional exits work the way you want them to?

Tom

Reply With Quote





Last Updated on February 26, 2020


© 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