MultiSMAs "Dashboard"... - ThinkOrSwim | futures io social day trading
futures io futures trading


MultiSMAs "Dashboard"...
Updated: Views / Replies:525 / 1
Created: by netarchitech Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

MultiSMAs "Dashboard"...

  #1 (permalink)
Trading Apprentice
NY, NY
 
Futures Experience: Intermediate
Platform: TOS
Favorite Futures: Stocks, ETFs
 
Posts: 30 since Dec 2011
Thanks: 19 given, 5 received

MultiSMAs "Dashboard"...

In my continuing efforts to learn Thinkscript, I have cobbled together my first "Hello World"-type script. This script is in response to my wanting to efficiently condense multiple moving average studies/settings/property pages into one single "dashboard", so to speak...

Rather than try to describe what I have tried to accomplish, below is the code and "dashboard" for any/all to review:

 
Code
declare upper;

input price1 = close;
input length1 = 8;
input displace1 = 0;

plot SMA1 = Average(price1[-displace1], length1);
         SMA1.SetDefaultColor(GetColor(4));
	 SMA1.SetLineWeight(2);
	 SMA1.SetStyle(Curve.FIRM);
	 SMA1.DefineColor("Up", GetColor(6));
	 SMA1.DefineColor("Down", GetColor(5));
	 SMA1.AssignValueColor(if SMA1 > SMA1[1] then SMA1.color("Up" ) else SMA1.color("Down" ));

input price2 = close;
input length2 = 20;
input displace2 = 0;

plot SMA2 = Average(price2[-displace2], length2);
	 SMA2.SetDefaultColor(GetColor(1));
	 SMA2.SetLineWeight(1);
	 SMA2.SetStyle(Curve.FIRM);

input price3 = close;
input length3 = 50;
input displace3 = 0;

plot SMA3 = Average(price3[-displace3], length3);
	 SMA3.SetDefaultColor(GetColor(2));
	 SMA3.SetLineWeight(1);
	 SMA3.SetStyle(Curve.FIRM);

input price4 = close;
input length4 = 100;
input displace4 = 0;

plot SMA4 = Average(price4[-displace4], length4);
	 SMA4.SetDefaultColor(GetColor(5));
	 SMA4.SetLineWeight(2);
	 SMA4.SetStyle(Curve.SHORT_DASH);

input price5 = close;
input length5 = 200;
input displace5 = 0;

plot SMA5 = Average(price5[-displace5], length5);
	 SMA5.SetDefaultColor(GetColor(5));
	 SMA5.SetLineWeight(2);
	 SMA5.SetStyle(Curve.LONG_DASH);

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


While the script basically works, I have one outstanding issue. I think the lookback is associated with longest SMA length, in this case 200 bars, so charts with fewer than 200 bars will be drawn without any SMAs. Is there a solution/workaround?

Comments/modifications are certainly welcome

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
NY, NY
 
Futures Experience: Intermediate
Platform: TOS
Favorite Futures: Stocks, ETFs
 
Posts: 30 since Dec 2011
Thanks: 19 given, 5 received

As a result of further research, I scrapped my original code. I came across TOS' MovAvgTwoLines study, which simply plots two MAs on a chart, with only the length parameter available for individual customization. The AverageType also offers a degree of flexibility/customization, but it applies to both MAs globally.

I wanted to have all the MAs (whether it be 2 or, in my case, 5) be individually customizable with the customizability available from one settings/property page. Now, using the new script below, I can have 5 MAs plotted with different price calculations, different lengths, different displacements and different average types.

 
Code
declare upper;

input price1 = close;
input length1 = 8;
input displace1 = 0;
input averageType1 = AverageType.SIMPLE;

input price2 = close;
input length2 = 20;
input displace2 = 0;
input averageType2 = AverageType.SIMPLE;

input price3 = close;
input length3 = 50;
input displace3 = 0;
input averageType3 = AverageType.SIMPLE;

input price4 = close;
input length4 = 100;
input displace4 = 0;
input averageType4 = AverageType.SIMPLE;

input price5 = close;
input length5 = 200;
input displace5 = 0;
input averageType5 = AverageType.SIMPLE;

plot MA1 = MovingAverage(averageType1, price1[-displace1], length1);
     MA1.SetDefaultColor(GetColor(4));
     MA1.SetLineWeight(2);
     MA1.SetStyle(Curve.FIRM);
     MA1.DefineColor("Up", GetColor(6));
     MA1.DefineColor("Down", GetColor(5));
     MA1.AssignValueColor(if MA1 > MA1[1] then MA1.color("Up" ) else MA1.color("Down" ));

plot MA2 = MovingAverage(averageType2, price2[-displace2], length2);
     MA2.SetDefaultColor(GetColor(1));
     MA2.SetLineWeight(1);
     MA2.SetStyle(Curve.FIRM);

plot MA3 = MovingAverage(averageType3, price3[-displace3], length3);
     MA3.SetDefaultColor(GetColor(2));
     MA3.SetLineWeight(1);
     MA3.SetStyle(Curve.FIRM);

plot MA4 = MovingAverage(averageType4, price4[-displace4], length4);
     MA4.SetDefaultColor(GetColor(5));
     MA4.SetLineWeight(2);
     MA4.SetStyle(Curve.SHORT_DASH);

plot MA5 = MovingAverage(averageType5, price5[-displace5], length5);
     MA5.SetDefaultColor(GetColor(5));
     MA5.SetLineWeight(2);
     MA5.SetStyle(Curve.LONG_DASH);

At least now I can access all the MAs on my chart from one centralized "dashboard" or settings/property page, as opposed to keeping track of 5 different applied MA studies. Nothing major, to be sure, but nice from a learning perspective...

While it feels good to create something useful, I came across an issue using the new study. When I plot the study in some cases, it doesn't draw the study to the left edge of the chart. See the sample below:

AAPL 180 d 4h
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


In my prior post, I speculated about this:


Quoting 
I think the lookback is associated with longest SMA length, in this case 200 bars, so charts with fewer than 200 bars will be drawn without any SMAs.

I further thought this may have been a problem with the original code, but it is happening with new code as well. I'm stumped and hoping someone might have an insight or solution to this dilemma...

Any thoughts?

Reply With Quote

Reply



futures io > > > > MultiSMAs "Dashboard"...

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sal Starzun's Trading systems info on "Eclipse" and "Moon" Naples Trading Reviews and Vendors 2 January 7th, 2015 08:56 AM
Saxo Bank's 10 "Outrageous Predictions" For "2012: The Perfect Storm" Quick Summary News and Current Events 0 December 17th, 2011 08:10 PM
Fukushima: "China Syndrome Is Inevitable" ... "Huge Steam Explosions", or "Nuclear Bo Quick Summary News and Current Events 0 November 22nd, 2011 02:50 AM
How to change "Stop Loss" and "Take Profit" in "shElderImpulse" Strategy javed759 NinjaTrader 1 November 1st, 2011 11:44 PM
"mid", "buy", "sell" volumes lokgotkent Traders Hideout 6 September 30th, 2011 02:24 PM


All times are GMT -4. The time now is 10:20 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-12 in 0.09 seconds with 19 queries on phoenix via your IP 54.90.92.204