NexusFi: Find Your Edge


Home Menu

 





TOS- Plotting Mov Avg. within a buffer zone


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,128 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 7 posts
    2. attach_file 6 attachments




 
Search this Thread

TOS- Plotting Mov Avg. within a buffer zone

  #1 (permalink)
nyckingo
NYC, New York, USA
 
Posts: 5 since Feb 2020
Thanks Given: 1
Thanks Received: 1

Hi Folks, I just joined forum. Looking forward to growing my experience with all of you. I'd scoured the web but have struggled to do these 2 things in TOS with thinkscript editor.

1. Plot chart of an adjustment factor/ buffer zone of say +.5% and - .5% around 2 separate mov. averages - a 13 period EMA and a special moving average defined as (O+H+L+2*C)/5. The adjustment factor could change (say be .7% or .8% instead of 0.5% so if it can be chosen/editable would be great). I've attached a picture to try to be clear. So it will chart 3 lines - moving avg line in middle and a green line above .5% and yellow line .5% below the MA. (see attached pic/drawing for clarity) .


2. Need to add 3 custom columns in say Watchlist (which will be used for trading strategy analysis)- 2 of those columns will be user entered by me- Col 1 =Qty, Col 2 =Purchase price and Col 3= run p/l- will be calculated as Col 1 * (last price- purchase price). I guess, TOS would keep updated last price with realtime quotes; and I should be able to fire alerts off of any of these 3 new custom columns?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 trepidation 
San Jose, California
 
Experience: Intermediate
Platform: Sierra Chart
Posts: 139 since Apr 2018
Thanks Given: 25
Thanks Received: 167

That is metatrader :P

The first part or making an indicator is pretty straightforward. The second one I don't think is possible to do with ToS. You might be better off using a spreadsheet for that.

Reply With Quote
  #3 (permalink)
nyckingo
NYC, New York, USA
 
Posts: 5 since Feb 2020
Thanks Given: 1
Thanks Received: 1



trepidation View Post
That is metatrader :P
The first part or making an indicator is pretty straightforward. The second one I don't think is possible to do with ToS. You might be better off using a spreadsheet for that.

I have used XLS with RTD before but how wud the indicator be handled in thinkscript?

Reply With Quote
  #4 (permalink)
 trepidation 
San Jose, California
 
Experience: Intermediate
Platform: Sierra Chart
Posts: 139 since Apr 2018
Thanks Given: 25
Thanks Received: 167

If I understood you correctly, this is what you're looking for:

 
Code
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
# Modified by trepidation

input length = 13;
input pctAbove = 0.5;
input pctBelow = 0.5;
input averageType = AverageType.EXPONENTIAL;
def specialFormula = (open+high+low+2*close)/5;

plot Middle = MovingAverage(averageType, close, length);
Middle.setDefaultColor(GetColor(1));

plot Upper = MovingAverage(averageType, specialFormula, length) * (1 + pctAbove/100);
Upper.setDefaultColor(GetColor(6));

Plot Lower = MovingAverage(averageType, specialFormula, length) * (1 - pctBelow/100);
Lower.setDefaultColor(GetColor(4));
0.5%, 5% and settings tab





Reply With Quote
  #5 (permalink)
nyckingo
NYC, New York, USA
 
Posts: 5 since Feb 2020
Thanks Given: 1
Thanks Received: 1


trepidation View Post
If I understood you correctly, this is what you're looking for:

thanks...I put it in -

seems that EMA is working fine but there's no way to pick that special formula (instead of EMA)- unless I'm missing something!

Reply With Quote
  #6 (permalink)
 trepidation 
San Jose, California
 
Experience: Intermediate
Platform: Sierra Chart
Posts: 139 since Apr 2018
Thanks Given: 25
Thanks Received: 167


nyckingo View Post
thanks...I put it in -

seems that EMA is working fine but there's no way to pick that special formula (instead of EMA)- unless I'm missing something!

Ah, I see. You said and so I misunderstood what you meant. Here's the updated code. You can toggle between the close or the specialFormula using the useSpecial in the settings page

 
Code
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
# Modified by trepidation

input useSpecial = no;
input length = 13;
input pctAbove = 0.5;
input pctBelow = 0.5;
input averageType = AverageType.EXPONENTIAL;
def specialFormula = (open + high + low + 2 * close) / 5;
def formula = if useSpecial then specialFormula else close;
plot Middle = MovingAverage(averageType, formula, length);
Middle.SetDefaultColor(GetColor(1));

plot Upper = MovingAverage(averageType, formula, length) * (1 + pctAbove / 100);
Upper.SetDefaultColor(GetColor(6));

plot Lower = MovingAverage(averageType, formula, length) * (1 - pctBelow / 100);
Lower.SetDefaultColor(GetColor(4));

Reply With Quote
  #7 (permalink)
nyckingo
NYC, New York, USA
 
Posts: 5 since Feb 2020
Thanks Given: 1
Thanks Received: 1


trepidation View Post
Ah, I see. You said and so I misunderstood what you meant. Here's the updated code. You can toggle between the close or the specialFormula using the useSpecial in the settings page

No - I must not have explained properly .

it seems to work...I will chekc values later..so I guess the logic is if special is set to yes, then dont use exponential but use special, otherwise use EMA.

What perplexes me is that you only coded NO- so how did system get the yes option?

Reply With Quote
  #8 (permalink)
 trepidation 
San Jose, California
 
Experience: Intermediate
Platform: Sierra Chart
Posts: 139 since Apr 2018
Thanks Given: 25
Thanks Received: 167


nyckingo View Post
No - I must not have explained properly .

it seems to work...I will chekc values later..so I guess the logic is if special is set to yes, then dont use exponential but use special, otherwise use EMA.

What perplexes me is that you only coded NO- so how did system get the yes option?

In the indicator settings, you can choose yes or no as well as change the colors of the plots and adjust the settings.

Attached Thumbnails
Click image for larger version

Name:	nyc_MA settings.png
Views:	188
Size:	30.4 KB
ID:	287828  
Reply With Quote




Last Updated on February 19, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts