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.

# TOS - Expected Rate of Return - Just Needs a Bit of Tweaking

## Recommended Posts

Hey guys

I created a study for TOS (expected Rate of Return) - just wondering if someone can help me tweak it.

it is as follows:

declare lower;

input length = 5;

input returnLength = 1;

input index = {default DJUSHC, SPX, "Nasdaq Composite", NDX, Dow30, "Russell 2000"};

Assert(returnLength > 0, "'return length' must be positive: " + returnLength);

def primary = if close[returnLength] == 0 then 0 else (close - close[returnLength]) / close[returnLength] * 100;

def logic;

switch (index) { case SPX: logic = close("SPX");

case "Nasdaq Composite": logic = close("COMP");

case NDX: logic = close("NDX");

case "Dow30": logic = close("\$DJI");

case "Russell 2000": logic = close("RUT");

case "DJUSHC": logic = close("\$DJUSHC");

}

def secondary = if logic[returnLength] == 0 then 0 else (logic - logic[returnLength]) / logic[returnLength] * 100;

def Beta = Covariance(primary, secondary, length) / Sqr(StDev(secondary, length));

assert(length > 0, "'length' must be positive: " + length);

plot PercentChg = (100 * (logic / logic[length] - 1) * Beta);

PercentChg.DefineColor("Normal", GetColor(7));

I'm pretty sure the Formula is correct however i'm not sure what the Length variable is for

I am plotting it for the Dow Health Care Index

Beta * % change in the index

I have also created a Beta study for the same index

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

• 1053
• 162
• 0
• -1
• 0
• ### Posts

• \$ADD Color Star Technology stock bottom breakout watch above 1.66 , see https://stockconsultant.com/?ADD