NexusFi: Find Your Edge


Home Menu

 





Moving Average With Colors TOS Code


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one txsroper with 2 posts (0 thanks)
    2. looks_two leaky01ch with 2 posts (1 thanks)
    3. looks_3 cory with 1 posts (0 thanks)
    4. looks_4 matthew2582 with 1 posts (0 thanks)
    1. trending_up 17,527 views
    2. thumb_up 15 thanks given
    3. group 12 followers
    1. forum 10 posts
    2. attach_file 3 attachments




 
Search this Thread

Moving Average With Colors TOS Code

  #11 (permalink)
 txsroper 
Austin Tx
 
Experience: Intermediate
Platform: NT, TOS, TradeStation
Trading: ES, NQ, CL, GC, Option Spreads
Posts: 24 since Sep 2013
Thanks Given: 9
Thanks Received: 13


Marty3 View Post
Here is the TOS code I wrote for a moving average that is green when up and red when down. You can select the following:
  • Color (up, down, flat)
  • Average type (simple, exponential, weighted, Wilders, or Hull)
  • Length
  • Line Type
  • Price (close, open, high, low, etc.)

Good trading!

Attachment 117647


I found a Moving Average Cross "cloud" see attached comparison. On the left is the Marty's code for the moving averages change color. Love the idea !!
On the right is a static code that can not be changed. These moving averages are pre coded at 5 and 21 and paints area in-between the 2 moving averages.

Can Marty's be coded to paint the area between the 2 moving averages and also label the moving average out at right end edge of the moving average?

Here is the code for the Paint Cloud 5 / 21 Moving Average on the right.

plot EMA5 = Average(close, 5);
plot EMA21 = Average(close, 21);
defineGlobalColor("cloud up",color.green);
defineGlobalColor("cloud down",color.red);
addcloud(EMA5,EMA21,globalColor("cloud up"),globalColor("cloud down"));
def crossUp = crosses(EMA5, EMA21, crossingDirection.ABOVE);
def crossDown = crosses(EMA5, EMA21, crossingDirection.BELOW);
plot signal = if crossUp then low-1*tickSize() else if crossDown then high+1*tickSize() else double.nan;
##assignPriceColor(if crossUp then color.yellow else if ##crossDown then color.white else color.current);

signal.setPaintingStrategy(paintingStrategy.triangles);
signal.setDefaultColor(color.cyan);

I love the idea of being able to select different moving averages and have it paint the cloud between them as well as label the moving averages. This would facilitate multiple comparisons easily.
Many Thanks.

Attached Thumbnails
Click image for larger version

Name:	Test MAs.png
Views:	399
Size:	134.3 KB
ID:	308987  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Cheap historycal L1 data for stocks
Stocks and ETFs
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
 




Last Updated on February 7, 2021


© 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