NexusFi: Find Your Edge


Home Menu

 





Help with easy language ma indicator for tradestation


Discussion in EasyLanguage Programming

Updated
    1. trending_up 379 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Help with easy language ma indicator for tradestation

  #1 (permalink)
 cjshu99 
lake charles, la
 
Experience: Intermediate
Platform: tradestation
Trading: futures, options
Posts: 3 since Jun 2022
Thanks Given: 5
Thanks Received: 0

Found this on trading view and can't get it to work in tradestation 10.

It will change the color of the moving average depending on direction - up or down.

Can anyone help?


Quoting 
//@version=4
//Color MA colors the moving average plot based on direction
//MA types are:
// 1 - simple
// 2 - exponential
// 3 - Hull
// 4 - weighted
// 5 - volume weighted

study(title = "Color MA", shorttitle="CMA", overlay = true)
length = input(9, minval=1, title="Length")
src = input(close, title="Source")
matype = input(1, minval=1, maxval=5, title="AvgType")

simplema = sma(src,length)
exponentialma = ema(src,length)
hullma = wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))
weightedma = wma(src, length)
volweightedma = vwma(src, length)

avgval = matype==1 ? simplema : matype==2 ? exponentialma : matype==3 ? hullma : matype==4 ? weightedma : matype==5 ? volweightedma : na
Pcolor = avgval > avgval[1] ? color.green : color.red

plot(avgval,title='Color MA', color=Pcolor, linewidth=4)


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 
Tripken's Avatar
 Tripken 
Knoxville, TN/USA
Market Wizard
 
Experience: Beginner
Platform: TradeStation
Broker: TradeStation
Trading: ES
Frequency: Several times daily
Duration: Minutes
Posts: 624 since Feb 2010
Thanks Given: 1,583
Thanks Received: 1,368


cjshu99 View Post
Found this on trading view and can't get it to work in tradestation.

It will change the color of the moving average depending on direction - up or down.

Can anyone help?

Here's some EL code that is similar. It changes color based on direction and calculates the angle. That can be commented out.
Perhaps you can take this and adapt your code to get it working. This one uses "Exponential" but that can be changed.

Hope it helps.
//////////////////////////////////////////////////////////
Input: Flat(LightGray), Up(Cyan), Down(Red),
Price(Close), Length(20), Displace(0);
Variables: myPlot(0), Color(green), myAngle(0);


myPlot = XAverage(Price,Length);

plot1[Displace](myPlot, "Xavg");

if C > myPlot then
SetPlotColor[1](1, Up);
if C < myPlot then
SetPlotColor[1](1, Down);
if C = myPlot then
SetPlotColor[1](1, Flat);

if C crosses above myPlot Then
Alert( " Crossing up") ;

if C crosses below myPlot Then
Alert( " crossing down ") ;


myangle = LinearRegAngle(XAverage(Price,Length), 2);


condition1 = DrawTextOnLastBar(-999999, 2, NumToStr(myangle,2) + "*", XAverage(Price,Length), white, 0);
/////////////////////////////////////////////////////////////////////////////////////////////////////

Reply With Quote
Thanked by:
  #3 (permalink)
 cjshu99 
lake charles, la
 
Experience: Intermediate
Platform: tradestation
Trading: futures, options
Posts: 3 since Jun 2022
Thanks Given: 5
Thanks Received: 0


Thanks. That looks good. Will see about making it use a sma

Started this thread Reply With Quote
  #4 (permalink)
 jwwjcw 
Washington DC
 
Experience: Intermediate
Platform: TradeStation
Trading: EC
Posts: 9 since Sep 2012
Thanks Given: 0
Thanks Received: 5

Inputs: Price(Close), matype(1), malength(9);

// Simple MA
if matype = 1 then Value1 = Average(Price, malength);

// Exponential
if matype = 2 then Value1 = XAverage(Price, malength);

// Hull
if matype = 3 then Value1 = HMA(Price, malength);

// Weighted
if matype = 4 then Value1 = WAverage(Price, malength);

// Vol Weighted - you can find this formula in the
// Mov Avg Volume-weighted indicator in Easy Language

if Value1 > Value1[1] then plot1(Value1, "MA", green)
else plot1(Value1, "MA", red);

You can use the properties tab to customize

Reply With Quote
Thanked by:




Last Updated on July 30, 2023


© 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