JeffryBatista
Member
I hope everyone is having an amazing day. I have been trying to make a scan identify when the displacedEMA is greater than the VariableMA, on the 15min, EXT turned on. I already tried saving it as a study and then plugging it into the scan but it didn't work. It sounds so simple but when I tried to code it into the scan I keep getting no results back and cant figure out why. I will leave the 3 different codes I have been putting in the scan down below. I would greatly appreciate any help given.
-------------------Test 1--------------------
DisplacedEMA("length" = 20, "displace length" = -15) is greater than VariableMA("length" = 15)
------------------Test 2--------------------
#DISPLACEDEMA
input price = close;
input length = 20;
input DisplaceLength = -15;
def DisplacedEMA = ExpAverage(data = price[DisplaceLength], length = length);
#VMA
input vprice = close;
input vlength = 15;
def tmp1 = if vprice > vprice[1] then vprice - vprice[1] else 0;
def tmp2 = if vprice[1] > vprice then vprice[1] - vprice else 0;
def d2 = sum(tmp1, vlength);
def d4 = sum(tmp2, vlength);
def cond = d2 + d4 == 0;
def ad3 = if cond then 0 else (d2 - d4) / (d2 + d4) * 100;
def coeff = 2 / (vlength + 1) * AbsValue(ad3) / 100;
def asd = compoundValue("visible data" = coeff * vprice + (if IsNaN(asd[1]) then 0 else asd[1]) * (1 - coeff), "historical data" = vprice
);
def VMA = asd;
plot scan = DisplacedEMA is greater than VMA;
-------------------Test 3--------------------
CrossoverSTRAT() is true within 2 bars
I basically made the 2 codes above custom studies, and offset them 2 bars and still got no results back
Scan Photos
This is what I want the scanner to tell me. In this case when the displacedEMA (blue line) is greater than VariableEMA(purple line) add "AAPL" to the scan results
-------------------Test 1--------------------
DisplacedEMA("length" = 20, "displace length" = -15) is greater than VariableMA("length" = 15)
------------------Test 2--------------------
#DISPLACEDEMA
input price = close;
input length = 20;
input DisplaceLength = -15;
def DisplacedEMA = ExpAverage(data = price[DisplaceLength], length = length);
#VMA
input vprice = close;
input vlength = 15;
def tmp1 = if vprice > vprice[1] then vprice - vprice[1] else 0;
def tmp2 = if vprice[1] > vprice then vprice[1] - vprice else 0;
def d2 = sum(tmp1, vlength);
def d4 = sum(tmp2, vlength);
def cond = d2 + d4 == 0;
def ad3 = if cond then 0 else (d2 - d4) / (d2 + d4) * 100;
def coeff = 2 / (vlength + 1) * AbsValue(ad3) / 100;
def asd = compoundValue("visible data" = coeff * vprice + (if IsNaN(asd[1]) then 0 else asd[1]) * (1 - coeff), "historical data" = vprice
);
def VMA = asd;
plot scan = DisplacedEMA is greater than VMA;
-------------------Test 3--------------------
CrossoverSTRAT() is true within 2 bars
I basically made the 2 codes above custom studies, and offset them 2 bars and still got no results back
Scan Photos
This is what I want the scanner to tell me. In this case when the displacedEMA (blue line) is greater than VariableEMA(purple line) add "AAPL" to the scan results
Last edited: