Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

lonew0lf

Lookback Easy Language Help

Recommended Posts

Can anyone assist, i'm trying to include the ability on this indicator to look back over a longer period of time rather than just the previous bar. Ideally, I want to be able to set the lookback period anywhere from 1- 500 bars in order to ascertain the trend of the ADX based on the resolution of the chart:

 

{1.0 Inputs and Variables}

 

{1.1. Declaration of Inputs}

Inputs:

ADXLenght (14),

UpColor (cyan),

DnColor (magenta),

UnChngColor (white);

 

 

{1.2. Declaration of Variables}

variables:

var0 (0),

var1 (0),

var2 (0),

var3 (0),

var4 (0),

var5 (0);

 

{2.0. Start Code}

 

{2.1. Call ADX & DMI}

Value1 = DirMovement(High, Low, Close, ADXLenght, var0, var1, var2, var3, var4, var5);

 

{2.2. Check Slope and SetPlotColor}

 

if var3 > var3[1] then

SetPlotColor[1](3, UpColor)

else

if var3 < var3[1] then

SetPlotColor[1](3, DnColor)

else

SetPlotColor[1](3, UnChngColor);

 

 

{3.0. Plot Values}

Plot1(var0, "DMI+");

Plot2(var1, "DMI-");

Plot3(var3, "ADX");

Share this post


Link to post
Share on other sites

If I understand your requirement correctly then the code below will enable you to change the lookback period using input parameters. They are set as a default to a lookback period of 1, but you can change them at runtime to any value you wish by using format analysis techniques.

 

Furthermore you could make this a calculated variable. So for example you could include a statement such as

 

 

 

if datacompression = 1 then length = 50 else

if datacompression = 0 then length = 100 else length = 1;

 

This will change the lookback period according to the data compression chosen at run time, so in this example if the chart is intra-day then it uses a lookback period of 50, for a tick chart 100 and for everything else 1.

 

0 for tick, 1 for intra-day, 2 for dly, 3 for wkly, 4 for mnthly, 5 for P&&F

 

Charlton

 

{1.0 Inputs and Variables}

 

{1.1. Declaration of Inputs}

Inputs:

ADXLenght (14),

UpColor (cyan),

DnColor (magenta),

UnChngColor (white),

LENGTH(1);

 

 

{1.2. Declaration of Variables}

variables:

var0 (0),

var1 (0),

var2 (0),

var3 (0),

var4 (0),

var5 (0);

 

{2.0. Start Code}

 

{2.1. Call ADX & DMI}

Value1 = DirMovement(High, Low, Close, ADXLenght, var0, var1, var2, var3, var4, var5);

 

{2.2. Check Slope and SetPlotColor}

 

if var3 > var3[LENGTH] then

SetPlotColor[LENGTH](3, UpColor)

else

if var3 < var3[LENGTH] then

SetPlotColor[LENGTH](3, DnColor)

else

SetPlotColor[LENGTH](3, UnChngColor);

 

 

{3.0. Plot Values}

Plot1(var0, "DMI+");

Plot2(var1, "DMI-");

Plot3(var3, "ADX");

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.