NexusFi: Find Your Edge


Home Menu

 





plotting the difference between two moving averages as a lower study in ToS


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one RedK with 3 posts (3 thanks)
    2. looks_two JTun with 2 posts (0 thanks)
    3. looks_3 xaifax with 1 posts (0 thanks)
    4. looks_4 StephenAndersen with 1 posts (0 thanks)
    1. trending_up 8,974 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

plotting the difference between two moving averages as a lower study in ToS

  #1 (permalink)
StephenAndersen
Wilton, CT U.S.A.
 
Posts: 6 since Mar 2013
Thanks Given: 1
Thanks Received: 0

Does anyone know how to take the difference between a 7 period SMA and 1 period SMA and plot it as an oscillator in a separate frame on ToS? Any help would be greatly appreciated.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
What broker to use for trading palladium futures
Commodities
 
  #2 (permalink)
 
RedK's Avatar
 RedK 
Dubai, UAE
 
Experience: Intermediate
Platform: TOS, TradeStation
Broker: OX, TradeStation
Trading: Stocks & Basic Options
Posts: 171 since May 2012
Thanks Given: 44
Thanks Received: 145

Hi, 1 period SMA is in reality the price itself, say close.. so i'll add the option to input (in study settings) a fast and slow periods.. if you like still to use 1 for fast, that would be ok
also added the choice to input which price to use (close, HL2, HLC3,...etc)

so your code should look like this (from memory, I didn't try it but should work, if you copy/paste in a new study in ToS) ..

also this will produce a non-restricted oscillator .. so no high/low limits for where it can go.. similar to MACD basically .. if we need to restrict it, we may think of relating it to the highest/lowest values for a certain timeframe and they become the 100% limits (like a stochastic) .. does that help?

 
Code
declare lower;
Input price = close;
Input Fast = 1;
Input Slow = 7;
def FastSMA = Average(Price, Fast);
def SlowSMA = Average(price, Slow);
plot Diff = FastSMA - SlowSMA;

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
xaifax
toronto
 
Posts: 1 since Jun 2014
Thanks Given: 1
Thanks Received: 0


I used that it was very helpful thanks
i have that set up and i threw in a zero line too
but i wanna but a boolean or something to show the cross over and under the zero line
...is there any way to do that?

Reply With Quote
  #4 (permalink)
 
RedK's Avatar
 RedK 
Dubai, UAE
 
Experience: Intermediate
Platform: TOS, TradeStation
Broker: OX, TradeStation
Trading: Stocks & Basic Options
Posts: 171 since May 2012
Thanks Given: 44
Thanks Received: 145

@xaifax, this would be a straight forward thing to do in ToS - we even have few options to how to display that signal to help a quality trade decision:
1 - can draw a vertical line when it happens, and change the color (red/green) based on the crossing direction
2 - can use an Arrow up/down on the lower study when the crossing happen
3 - can show that arrow up/down signal (or any other type of signal basically) on the price chart itself - there's a trick here, the upper study will need to be a separate one that does the calculation in the background but only plots the signal. it's up to you to ensure both that upper signal study and the lower one are in sync in terms of settings. then this becomes a regular MA crossing signal study (which I think is already built-in in ToS)
4 - other ideas .. audible alerts, display a study label that says "crossing-up" or "long" or something like that,

if you have a preference from above (or other ideas) and need help coding it, i'll be glad to help,
K

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
JTun
Singapore
 
Posts: 4 since Mar 2015
Thanks Given: 1
Thanks Received: 0

Hi all,

Sorry to hijack this thread temporarily.

I want to plot a lower study that shows the difference between close price and its 50days Moving Average in an oscillator fashion (similar to RSI).

How do I go about doing it?

Reply With Quote
  #6 (permalink)
 
RedK's Avatar
 RedK 
Dubai, UAE
 
Experience: Intermediate
Platform: TOS, TradeStation
Broker: OX, TradeStation
Trading: Stocks & Basic Options
Posts: 171 since May 2012
Thanks Given: 44
Thanks Received: 145


JTun View Post
Hi all,

Sorry to hijack this thread temporarily.

I want to plot a lower study that shows the difference between close price and its 50days Moving Average in an oscillator fashion (similar to RSI).

How do I go about doing it?

you can use a MACD with settings of 1 and 50 and 1 - i'm doing this from memory but I think that should give you what you're looking for if i'm not mistaken,

Cheers,
K

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
JTun
Singapore
 
Posts: 4 since Mar 2015
Thanks Given: 1
Thanks Received: 0

Thanks K.

I sorted out what I wanted with a zero line, much like what TS has done.

Cheers =)

Reply With Quote




Last Updated on March 2, 2015


© 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