Request how to solve the think script below for ehler MESA moving average - ThinkOrSwim | futures io social day trading

Request how to solve the think script below for ehler MESA moving average
 Updated: August 27th, 2016 (09:50 PM) Views / Replies: 424 / 0 Created: August 27th, 2016 (09:50 PM) by Danielwalker Attachments: 0

 Welcome to futures io.

# Request how to solve the think script below for ehler MESA moving average

 August 27th, 2016, 09:50 PM #1 (permalink) Trading Apprentice Singapore   Futures Experience: Intermediate Platform: Thinkorswim Favorite Futures: Stocks   Posts: 1 since May 2015 Thanks: 0 given, 0 received Request how to solve the think script below for ehler MESA moving average Dear All, I found source code from trading view for the ehler adaptive moving average and try to convert it directly into think script and found a problem. The think script compile the code top down sequence but the code define the variables p at the bottom while the variable p is being used at the top part of the source code giving me the variable error. Does anyone able help me how to correct the code in such a way that it will work in think script? tradingView source code: ----------------------------------------------------------------------------------------------------------------------- src=input(hl2, title="Source") fl=input(.5, title="Fast Limit") sl=input(.05, title="Slow Limit") sp = (4*src + 3*src[1] + 2*src[2] + src[3]) / 10.0 dt = (.0962*sp + .5769*nz(sp[2]) - .5769*nz(sp[4])- .0962*nz(sp[6]))*(.075*nz(p[1]) + .54) q1 = (.0962*dt + .5769*nz(dt[2]) - .5769*nz(dt[4])- .0962*nz(dt[6]))*(.075*nz(p[1]) + .54) i1 = nz(dt[3]) jI = (.0962*i1 + .5769*nz(i1[2]) - .5769*nz(i1[4])- .0962*nz(i1[6]))*(.075*nz(p[1]) + .54) jq = (.0962*q1 + .5769*nz(q1[2]) - .5769*nz(q1[4])- .0962*nz(q1[6]))*(.075*nz(p[1]) + .54) i2_ = i1 - jq q2_ = q1 + jI i2 = .2*i2_ + .8*nz(i2[1]) q2 = .2*q2_ + .8*nz(q2[1]) re_ = i2*nz(i2[1]) + q2*nz(q2[1]) im_ = i2*nz(q2[1]) - q2*nz(i2[1]) re = .2*re_ + .8*nz(re[1]) im = .2*im_ + .8*nz(im[1]) p1 = iff(im!=0 and re!=0, 360/atan(im/re), nz(p[1])) p2 = iff(p1 > 1.5*nz(p1[1]), 1.5*nz(p1[1]), iff(p1 < 0.67*nz(p1[1]), 0.67*nz(p1[1]), p1)) p3 = iff(p2<6, 6, iff (p2 > 50, 50, p2)) p = .2*p3 + .8*nz(p3[1]) spp = .33*p + .67*nz(spp[1]) phase = atan(q1 / i1) dphase_ = nz(phase[1]) - phase dphase = iff(dphase_< 1, 1, dphase_) alpha_ = fl / dphase alpha = iff(alpha_ < sl, sl, iff(alpha_ > fl, fl, alpha_)) mama = alpha*src + (1 - alpha)*nz(mama[1]) fama = .5*alpha*mama + (1 - .5*alpha)*nz(fama[1]) pa=input(false, title="Mark crossover points") plotarrow(pa?(cross(mama, fama)?mamafama?mama:fama):na, style=circles, color=gray, linewidth=0, title="DummyL") mamal=plot(mama, title="MAMA", color=red, linewidth=2) famal=plot(fama, title="FAMA", color=green, linewidth=2) fill(duml, mamal, red, transp=70, title="NegativeFill") fill(duml, famal, green, transp=70, title="PositiveFill") ebc=input(false, title="Enable Bar colors") bc=mama>fama?lime:red barcolor(ebc?bc:na) ------------------------------------------------------------------------------------------------------------------------------ my think script source code: input h = high; input l = low; input fl = 0.5; input sl = 0.05; def hl2 = (h + l) / 2; def sp = (4 * hl2 + 3 * hl2[1] + 2 * hl2[2] + hl2[3] / 10.0); def dt = (0.0962 * sp + 0.5769 * (if IsNaN(sp[2]) then 0 else sp[2]) - 0.5769 * (if IsNaN(sp[4]) then 0 else sp[4]) - 0.0962 * (if IsNaN(sp[6]) then 0 else sp[6])) * (0.075 * (if IsNaN(p[1]) then 0 else p[1]) + 0.54); def q1 = (0.0962 * dt + 0.5769 * (if IsNaN(dt[2]) then 0 else dt[2]) - 0.5769 * (if IsNaN(dt[4]) then 0 else dt[4]) - 0.0962 * (if IsNaN(dt[6]) then 0 else dt[6])) * (0.075 * (if IsNaN(p[1]) then 0 else p[1]) + 0.54); def i1 = (if IsNaN(dt[3]) then 0 else dt[3]); def jl = (0.0962 * i1 + 0.5769 * (if IsNaN(i1[2]) then 0 else i1[2]) - 0.5769 * (if IsNaN(i1[4]) then 0 else i1[4]) - 0.0962 * (if IsNaN(i1[6]) then 0 else i1[6])) * (0.075 * (if IsNaN(p[1]) then 0 else p[1]) + 0.54); def jq = (0.0962 * q1 + 0.5769 * (if IsNaN(q1[2]) then 0 else q1[2]) - 0.5769 * (if IsNaN(q1[4]) then 0 else q1[4]) - 0.0962 * (if IsNaN(q1[6]) then 0 else q1[6])) * (.075 * (if IsNaN(p[1]) then 0 else p[1]) + .54); def i2_ = i1 - jq; def q2_ = q1 + jl; def i2 = .2 * i2_ + .8 * (if IsNaN(i2[1]) then 0 else i2[1]); def q2 = .2 * q2_ + .8 * (if IsNaN(q2[1]) then 0 else q2[1]); def re_ = i2 * (if IsNaN(i2[1]) then 0 else i2[1]) + q2 * (if IsNaN(q2[1]) then 0 else q2[1]); def im_ = i2 * (if IsNaN(q2[1]) then 0 else q2[1]) - q2 * (if IsNaN(i2[1]) then 0 else i2[1]); def re = .2 * re_ + .8 * (if IsNaN(re[1]) then 0 else re[1]); def im = .2 * im_ + .8 * (if IsNaN(im[1]) then 0 else im[1]); def p1 = if (im != 0 and re != 0) then 360 / Tan(im / re) else (if IsNaN(p[1]) then 0 else p[1]); def p2 = if p1 > 1.5 * (if IsNaN(p1[1]) then 0 else p1[1]) then 1.5 * (if IsNaN(p1[1]) then 0 else p1[1]) else if p1 < 0.67 * (if IsNaN(p1[1]) then 0 else p1[1]) then 0.67 * (if IsNaN(p1[1]) then 0 else p1[1]) else p1; def p3 = if (p2 < 6) then 6 else if (p2 > 50) then 50 else p2; rec p = .2 * p3 + .8 * (if IsNaN(p3[1]) then 0 else p3[1]); def spp = .33 * p + .67 * (if IsNaN(spp[1]) then 0 else spp[1]); def phase = Tan(q1 / i1); def dphase_ = (if IsNaN(phase[1]) then 0 else phase[1]) – phase; def dphase = if (dphase_ < 1) then 1 else dphase_ ; def alpha_ = fl / dphase; def alpha = if (alpha_ < sl) then sl else if (alpha_ > fl) then fl else alpha_ ; plot mama = alpha * hl2 + (1 - alpha) * (if IsNaN(mama[1]) then 0 else mama[1]); plot fama = .5 * alpha * mama + (1 - .5 * alpha) * (if IsNaN(fama[1]) then 0 else fama[1]);

 futures io > Request how to solve the think script below for ehler MESA moving average

Upcoming Webinars and Events (4:30PM ET unless noted)

Elite only

## Ran Aroussi: Python and Machine Learning (part 4) [special time 11AM ET]

Elite only

 Similar Threads Thread Thread Starter Forum Replies Last Post thescream80 ThinkOrSwim 2 June 18th, 2015 07:40 PM compupix ThinkOrSwim Programming 0 November 22nd, 2014 04:02 PM mcteague NinjaTrader Programming 3 November 12th, 2012 06:57 PM motoko Platforms and Indicators 0 August 29th, 2011 05:02 PM Henrik Platforms and Indicators 2 January 4th, 2010 01:23 PM

All times are GMT -4. The time now is 07:53 AM.

 Copyright © 2018 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
Page generated 2018-04-21 in 0.09 seconds with 19 queries on phoenix via your IP 54.81.117.119