glendale ca usa
Posts: 97 since Sep 2017
Thanks Given: 11
Thanks Received: 88
|
#NICA_ZEROLAG
#This is my version, anyone is welcome to play with it and modify it for better results.
input length = 20;
input GainLimit = 50;
input length2 = 4;
input GainLimit2 = 20;
def alpha = 2/ (length + 1);
def alpha2 = 2/ (length2 + 4);
def EMA = alpha*close + (1 - alpha)*EMA[1];
def EMA2 = alpha2*close + (1 - alpha2)*EMA2[1];
def Value1 = -GainLimit + GainLimit;
def Gain = Value1/10;
def Value2 = -GainLimit2 + GainLimit2;
def Gain2 = Value2/10;
def EC = alpha*(EMA + Gain*(close-EC[1]))+ (1 - alpha)*EC[1];
def Error = Close - EC;
def EC2_ = alpha2*(EMA2 + Gain2*(close-EC[1]))+ (1 - alpha2)*EC[1];
def Error2 = Close - EC2_;
def BestGain = Gain;
def BestGain2 = Gain2;
DEF LeastError = 1000000;
plot EC1 = alpha*(EMA + BestGain*(Close - EC[1])) + (1 - alpha)*EC[1];
EC1.setDefaultColor(color.orange);
plot EC2 = alpha2*(EMA + BestGain2*(Close - EC[1])) + (1 - alpha2)*EC[1];
EC2.setDefaultColor(color.UPTICK);
plot EMA44 = alpha2*close + (1 - alpha2)*EMA[1];
#Plot1(EC);
#Plot3(EMA);
addcloud(EC1, EC2, COLOR.RED, COLOR.GREEN);
ASSIGnPriceColor(IF EC1<EC2 [1] then color.cyan else if EC1>EC2[1] then color.yellow else color.current);
##
|