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.

tradernicky

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;

 

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("HiAlert", GetColor(5));

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

PercentChg.DefineColor("LoAlert", GetColor(1));

PercentChg.AssignValueColor(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

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.


  • Topics

  • Posts

    • CCL Carnival stock watch, pullback to 23.94 triple support area with bullish indicators at https://stockconsultant.com/?CCL
    • KD Kyndryl stock watch, pullback to 38.37 triple support area with bullish indicators at https://stockconsultant.com/?KD
    • AUR Aurora Innovation stock watch, attempting to move higher off the 7.08 triple support area at https://stockconsultant.com/?AUR
    • MA Mastercard stock, nice close and bull flag breakout at https://stockconsultant.com/?MA
    • Of course, I had to ask what he thought about AI.   Because if you can make an entire film on a laptop in your bedroom, do we even need Hollywood anymore?   Will’s answer: Yes, AI will take jobs. (Production, sets, background extras, you name it.)   Yes, it will make movies cheaper.   But no, it won’t replace human storytelling.   Because AI doesn’t know why you care.   It can generate dialogue, sure. But can it make you feel? Can it tell the definitive story of your life?   (Well, unless you’re a robot, in which case… congratulations on reading this far.)   Confidence Is a Muscle—Here’s How to Build It   Will brought up something crucial.   Most people wait until they feel confident.   That’s a mistake.   Confidence comes after action.   Not before.   So how do you build it?   Manufacture wins—Set tiny goals. Don’t climb the whole mountain. Just put on your hiking boots. Control your input—Stop giving away your power. Just because someone in authority tells you no, doesn’t mean you stop. Hack your own brain—Every morning, tell yourself what you need to hear. And just like that, you’re training your mind the way an athlete trains their body. By James A.  Profits from free accurate cryptos signals: https://www.predictmag.com/ 
×
×
  • Create New...

Important Information

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