Welcome to the Traders Laboratory.

Support Center Have any questions regarding the site? Submit a support ticket here. Check this section for announcements also.

Reply
Old 08-22-2015, 11:41 AM   #1

Join Date: Aug 2015
Posts: 3
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

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

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;

input hiAlert = 0;
input loAlert = 0;


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("H iAlert", GetColor(5));
PercentChg.DefineColor("N ormal", GetColor(7));
PercentChg.DefineColor("L oAlert", GetColor(1));
PercentChg.AssignValueCol or(if PercentChg > hiAlert then PercentChg.color("HiAlert ") else if PercentChg < loAlert then PercentChg.color("LoAlert ") else PercentChg.color("Normal" ));

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
tradernicky is offline  
Reply With Quote

Reply

« Ct Power Rsi Pivot | - »
Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expected Rate of Return - Just Needs a Bit of Tweaking tradernicky Trading Indicators 0 08-22-2015 11:35 AM
How to Benefit from an Expected Rise in IV's marinemonk Options Trading Laboratory 3 11-29-2013 05:25 AM
Is Trading What You Expected? Mysticforex Trading and the Markets 46 04-04-2012 04:37 AM
Rate of Annual Return 156 Coding Forum 9 08-01-2008 01:34 AM
Expected System Maintenance Tonight Soultrader Support Center 7 02-12-2008 11:00 AM

All times are GMT -4. The time now is 06:29 AM.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
2006-2011 Traders Laboratory, All Rights Reserved.