Alert with percentage price to reach particular level

G

G81moyano

New member
Hello team.

Do you have or could help me out to create some indicator to add to WL column showing wthat percentage remain to reach a specific level or in this case a specific moving average? (EMA200)?

Thank you
 
mc01439

mc01439

Well-known member
2019 Donor
VIP
Try this;

Code:
input price = close;
input length = 200;
input Showlabels = yes;


def AvgExp = ExpAverage(price, length);
def diff = close - AvgExp;

def diffUP = diff > AvgExp;
def diffDN =  diff < AvgExp;
def diffnet = !diffUP and !diffDN;

AddLabel(Showlabels and  diffUP, "Price From 200EMA @ " + diff, Color.GREEN);
AddLabel(Showlabels and  diffDN, "Price From 200EMA @ " + diff, Color.RED);
AddLabel(Showlabels and  diffnet, "Price From 200EMA @ " + diff, Color.YELLOW);
 
G

G81moyano

New member
Thanks a lot... I have an image to show how looks like but ... Do I have a chance to see how many % I have with the price when its going to touch this EMA?
an example...if 9.35 the distance between EMA and close price is 30 cents and in 9:54 the distance is 10 cents do I have a chance to see it into a custom study into WL ( I have a picture but I dont have any idea to share it with you) :(
 
mc01439

mc01439

Well-known member
2019 Donor
VIP
Thanks a lot... I have an image to show how looks like but ... Do I have a chance to see how many % I have with the price when its going to touch this EMA?
an example...if 9.35 the distance between EMA and close price is 30 cents and in 9:54 the distance is 10 cents do I have a chance to see it into a custom study into WL ( I have a picture but I dont have any idea to share it with you) :(
Here you go. Turn which one you want with the input (yes or no).

Code:
input price = close;
input length = 200;
input Showlabels = yes;
input ShowPCTlabels = yes;

def AvgExp = ExpAverage(price, length);
def diff = close - AvgExp;
def pctdiff = (diff / AvgExp) * 100;

def waveUP = diff > AvgExp;
def waveDN =  diff < AvgExp;
def wavenet = !waveUP and !waveDN;

AddLabel(Showlabels and  waveUP, "Price From 200EMA @ " + diff, Color.GREEN);
AddLabel(Showlabels and  waveDN, "Price From 200EMA @ " + diff, Color.RED);
AddLabel(Showlabels and  wavenet, "Price From 200EMA @ " + diff, Color.YELLOW);

def pctUP = pctdiff > AvgExp;
def pctDN =  pctdiff < AvgExp;
def pctnet = !pctUP and !pctDN;

AddLabel(ShowPCTlabels and  pctUP, "Percent From 200EMA @ " + pctdiff, Color.GREEN);
AddLabel(ShowPCTlabels and  pctDN, "Percent From 200EMA @ " + pctdiff, Color.RED);
AddLabel(ShowPCTlabels and  pctnet, "Percent From 200EMA @ " + pctdiff, Color.YELLOW);
 

Similar threads

Top