NexusFi: Find Your Edge


Home Menu

 





John Ehlers Zero Lag


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one jeffro with 2 posts (3 thanks)
    2. looks_two ebtrader with 1 posts (1 thanks)
    3. looks_3 greymatter with 1 posts (0 thanks)
    4. looks_4 FunTrade with 1 posts (0 thanks)
    1. trending_up 12,950 views
    2. thumb_up 5 thanks given
    3. group 17 followers
    1. forum 20 posts
    2. attach_file 1 attachments




 
Search this Thread

John Ehlers Zero Lag

  #21 (permalink)
 trepidation 
San Jose, California
 
Experience: Intermediate
Platform: Sierra Chart
Posts: 139 since Apr 2018
Thanks Given: 25
Thanks Received: 167

Here's the code by Mobius. Not sure why we're hoarding code. It's not like you can compile ThinkScript and prevent the source from being viewed lol...

 
Code
# Zero Lag EMA (Using an Error Correcting Filter)
# Mobius
# Ported to TOS 08.31.2016 from Article by John Ehlers
# Using an EMA error term, the current price ? EMA[1], the amplitude of the error term is altered by multiplying the error by a gain term. The new filter is an EC or Error Corrected EMA.

# Inputs:
input Length = 20;
input GainLimit = 50;
input LabelsOn = yes;

# Vars:
def alpha;
def BestGain;
def EC1;
def Gain;
def EC;
def Error;
def LeastError;
def EMA;
alpha = 2 / (Length + 1);
EMA = alpha * close + (1 - alpha) * EMA[1];
plot EMAdata = EMA;
EMAdata.SetDefaultColor(Color.Yellow);
Gain = fold g = -GainLimit to GainLimit
       do getValue(g / 10, g);
EC1 = fold V = -GainLimit to GainLimit
      do alpha * (EMA + (fold i = -GainLimit to GainLimit
                         do i / 10) * (Close - EC1[1])) + (1 - alpha) * EC1[1];
Error = AbsValue(Close - EC1);
If Error < 1000000
Then {
LeastError = Error;
BestGain = Gain;
} else {
LeastError = LeastError[1];
BestGain = 0;
}
EC = alpha * (EMA + BestGain * (Close - EC1)) + (1 - alpha) * EC1;
Plot ECdata = EC;
ECdata.SetDefaultColor(Color.Cyan);
AddLabel(LabelsOn, "Standard EMA", color.yellow);
AddLabel(LabelsOn, "Error Corrected EMA", color.cyan);
#End Code Error Corrected EMA

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Quantum physics & Trading dynamics
The Elite Circle
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
 




Last Updated on February 17, 2020


© 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