NexusFi: Find Your Edge


Home Menu

 





Entry at every bar, exit ATR trailing


Discussion in MultiCharts

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




 
Search this Thread

Entry at every bar, exit ATR trailing

  #1 (permalink)
 Loop 
Sydney
 
Experience: Intermediate
Platform: Multichart
Trading: Gold
Posts: 26 since Aug 2016
Thanks Given: 22
Thanks Received: 4

Hola

does anyone know how to Easy language a research strategy where its entry at every single bar and then followed by a ATR trailing stop? Long only. And short only.

I think code below is a start... But I don't understand what ts is??

Kind regards

Loop



Inputs: Price(Close),atrPeriod(14),atrMult(1.75);

Vars:
atr(0), ts(0), shstp(0), lgstp(0), trend(0), TriggerPrice(0), dir(0);

atr = AvgTrueRange(AtrPeriod);

lgstp = Price - atr * atrMult;
shstp = Price + atr * atrMult;

TriggerPrice = close;

if TriggerPrice >= ts[1] then
trend = 1
else if TriggerPrice < ts[1] then
trend = -1;

if trend > 0 then
if trend[1] < 0 then ts=lgstp[0]
else if lgstp >= ts[1] then ts=lgstp[0]
else ts=ts[1];

if trend < 0 then
if trend[1] > 0 then ts=shstp[0]
else if shstp <= ts[1] then ts=shstp[0]
else ts=ts[1];

if trend[1] < 0 and trend >= 0 then buy next bar at market;
if trend[1] > 0 and trend < 0 then sellshort next bar at market;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
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
35 thanks
Tao te Trade: way of the WLD
25 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

Loop,

what exactly don't you understand regarding "ts"? It's just a variable, that could have (almost) any other name.
From the code it appears to be holding the value of a trailing stop, hence the abbreviation "ts" was probably used for its name.
It will hold either of the two values below, depending on the trend (as computed by the study).
 
Code
lgstp = Price - atr * atrMult;
shstp = Price + atr * atrMult;
When the TriggerPrice variable is less than the previous bars value for ts, then the study will assume that a down trend exists and update the ts variable following this logic:
 
Code
if trend < 0 then
if trend[1] > 0 then ts=shstp[0]
else if shstp <= ts[1] then ts=shstp[0]
else ts=ts[1];
It will be vice versa for an up trend.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 Loop 
Sydney
 
Experience: Intermediate
Platform: Multichart
Trading: Gold
Posts: 26 since Aug 2016
Thanks Given: 22
Thanks Received: 4


Thank you for heads up!!

Any idea how to have an entry at every bar in order to do trend research?

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

Loop,

by the way you can show your appreciation for posts on nexusfi.com by clicking the "Thanks" button next to the code.

An entry on every (!) bar will require a bit of work most likely as you have to deal with pyramiding and scaling out of positions. Do you actually want that or do you want to enter only again when flat?
Feel free to post your code attempts and I am sure someone is able to steer you in the right direction.

If you are looking for someone to code it for you, you might be able to find help in the " Want your [AUTOLINK]EasyLanguage[/AUTOLINK] Indicator Created free" thread.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on August 9, 2016


© 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