Moving average with Lag reduction - futures io
futures io futures trading



Moving average with Lag reduction


Discussion in NinjaTrader

Updated by Ozquant
    1. trending_up 973 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 2 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Moving average with Lag reduction

(login for full post details)
  #1 (permalink)
Pune + India
 
Experience: None
Platform: new
Trading: new
 
Posts: 1 since Aug 2018
Thanks: 0 given, 0 received

Hi All

I came across an indicator in Tradingview. This is based on moving average (ma)

This indicator as lag value calculated based on the MA ; the code is below (please see line:2)

*************************
Line:1 - MA3 = WMA (Close, 100)
Line:2 - MA2lagFilter = exp(20*log(MA3 / MA3[1]))*MA3
Line:3 - MA1 = wma(close,3)

q1=plot(MA3, "MOV AVG PLOT", color= MA3>MA3[1]?lime:red, transp=1, linewidth=3 )
q2=plot(filter?MA2lagFilter:na, "LAG FILTER", color= black, transp=1, linewidth=2 )
q3=plot(MA1, "3 PERIOD WMA", color= black, transp=50, linewidth=1 )
*************************

When I try to write a similar code in AFL, it doesn't give the same output as Tradingview. (please note i'm not a coder)

Looking for help or guidance, not sure where I'm going wrong.

can someone please write this code for ninjatrader-7

Have attached an image of the indicator from Tradingview

Attached Thumbnails
Click image for larger version

Name:	indicator image.png
Views:	179
Size:	72.7 KB
ID:	295173  
Reply With Quote

Can you help answer these questions
from other members on futures io?
Chart text fixed and move with time
NinjaTrader
highest high help
NinjaTrader
Scan by comparing SMAs within 5 mins
ThinkOrSwim
With 1 click place orders on two accounts (rithmic and cqg)
NinjaTrader
FYI plot bug & workaround: changing color or width is delayed 1 bar
EasyLanguage Programming
 
 
(login for full post details)
  #2 (permalink)
Ladysmith BC, Canada
 
Experience: Intermediate
Platform: Meta Trader
Trading: Crude Oil
 
Posts: 14 since Feb 2017
Thanks: 15 given, 3 received

Sweeet thats what an MA should look and be like.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #3 (permalink)
Brisbane Queensland Australia
 
 
Posts: 203 since Aug 2017
Thanks: 142 given, 330 received



seveera View Post
Hi All

I came across an indicator in Tradingview. This is based on moving average (ma)

This indicator as lag value calculated based on the MA ; the code is below (please see line:2)

*************************
Line:1 - MA3 = WMA (Close, 100)
Line:2 - MA2lagFilter = exp(20*log(MA3 / MA3[1]))*MA3
Line:3 - MA1 = wma(close,3)

q1=plot(MA3, "MOV AVG PLOT", color= MA3>MA3[1]?lime:red, transp=1, linewidth=3 )
q2=plot(filter?MA2lagFilter:na, "LAG FILTER", color= black, transp=1, linewidth=2 )
q3=plot(MA1, "3 PERIOD WMA", color= black, transp=50, linewidth=1 )
*************************

When I try to write a similar code in AFL, it doesn't give the same output as Tradingview. (please note i'm not a coder)

Looking for help or guidance, not sure where I'm going wrong.

can someone please write this code for ninjatrader-7

Have attached an image of the indicator from Tradingview


Here is the actual correct pinescript code , no-one has any hope of translating that code above with many errors in it

study("CHK TimeSeriesLagReductionFilter[MULTI MA]", overlay=true)

//-----
//Moving Average Types

almaIn = 'ALMA: Arnaud Legoux'
emaIn = 'EMA'
etmaIn = 'ETMA: Triangular (Exponential)'
ssmaIn = 'SSMA Super Smoothed'
hullIn = 'Hull MA'
mgIn = 'McGinley Dynamic'
rmaIn = 'SMMA -/RMA/Wilders: Smoothed'
smaIn = 'SMA'
tmaIn = 'TRIMA: Triangular'
wmaIn = 'WMA'
vwmaIn = 'EVWMA : ElasticVolWMA'


////-----
//General Input

maType = input(wmaIn, "Moving Average Type",
options=[almaIn, ssmaIn ,emaIn, etmaIn, hullIn,
mgIn, vwmaIn, rmaIn, smaIn,tmaIn,wmaIn])


periodd = input(100, "MA Length input", minval=1)
lagReduce = input(20.0, title="Lag Reduction input", minval=1)
filter=input(true, title="Plot Time Series Lag Reduction Filter?")


//-----
//MA & Misc. Input

offAl = 0.85//input(0.85, "ALMA: Offset", step=0.05)
sigmaAl = 6 //FOR ALMA
//alpha = 0.7 //// FOR T3 TILSON
src = close



//-----
//MA Function Declaration

Alma(_src, _len) =>
alma = alma(_src, _len, offAl, sigmaAl)

//// ETMA EXPONENTIAL TRIANGULAR MOV AVG
//// from https://www.tradingview.com/script/UQAv1U0c-MA-Study-Different-Types-and-More-NeoButane/
//// however chnaged ema to wma
eTma(_src, _len) =>
tma = ema(ema(_src, _len), _len)


Hull(_src, _len) =>
hullma = wma(2*wma(_src, _len/2)-wma(_src, _len), round(sqrt(_len)))


Mg(_src, _len) =>
mg = 0.0
mg := na(mg[1]) ? ema(_src, _len) : mg[1] + (_src - mg[1]) / (_len * pow(_src/mg[1], 4))

Tma(_src, _len) =>
tma = sma(sma(_src, _len), _len)


Wild(_src, _len) =>
wild = 0.0
alpha = 1 / _len
wild := alpha * _src + (1.0 - alpha) * nz(wild[1], _src)

// SUPER SMOOTHED MOV AVG////////
//// SSMA SuperSmoother filter 2013 John F. Ehlers, https://www.tradingview.com/script/3e6VWRq7-Multi-MA-Ribbon/
ssma(_src, _len) =>
if (_len>0)
a1=exp(-1.414*3.14159 / _len)
b1=2*a1*cos(1.414*3.14159 /_len)
c2=b1
c3=(-a1)*a1
c1=1 - c2 - c3
v9=0.0
v9:=c1*(_src + nz(_src[1])) / 2 + c2*nz(v9[1]) + c3*nz(v9[2])
v9
else
na

// EVWMA ELASTIC VOL WEIGHTED MOV AVG////////
func_evwma(_src, _len) =>
volumeSum = sum(volume, _len)
evwma3 = 0.0
evwma3 := ((volumeSum - volume) * nz(evwma3[1]) + volume * _src) / volumeSum
evwma3


ma(_type, _src, _len) =>
_type == almaIn ? Alma(_src, _len) :
_type == emaIn ? ema(_src, _len) :
_type == ssmaIn ? ssma(_src, _len) :
_type == etmaIn ? eTma(_src, _len) :
_type == mgIn ? Mg(_src, _len) :
_type == rmaIn ? rma(_src, _len) :
_type == smaIn ? sma(_src, _len) :
_type == tmaIn ? Tma(_src, _len) :
_type == vwmaIn ? func_evwma(_src, _len) :
_type == hullIn ? Hull(_src, _len) :
_type == wmaIn ? wma(_src, _len) : na



MA3 = ma(maType, src, periodd)
MA2lagFilter = exp(lagReduce*log(MA3 / MA3[1]))*MA3
MA1 = wma(close,3)


q1=plot(MA3, "MOV AVG PLOT", color= MA3>MA3[1]?lime:red, transp=1, linewidth=3 )
q2=plot(filter?MA2lagFilter:na, "LAG FILTER", color= black, transp=1, linewidth=2 )
q3=plot(MA1, "3 PERIOD WMA", color= black, transp=50, linewidth=1 )

/// LIME #00FF00 // #fd1206 RED

fill(q3, q2, MA1 > MA2lagFilter ? #00FF00 : #fd1206, title="FILL BETWEEN CANDLE AND LAG", transp=10)
fill(q2, q1, MA3 > MA2lagFilter ?#fd1206 : #00FF00, title="FILL BETWEEN LAG AND MOV AVG", transp=70)

Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Moving average with Lag reduction


June 16, 2020


Upcoming Webinars and Events
 

Every journal equals ten meals for the hungry

Now
     



Copyright © 2020 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