Percent Distance Between EMAs or VWAP or Any 2 Plots

MerryDay

Administrative
Staff member
Staff
VIP
Scan For Price Within A Percentage Of Moving Average
  1. Where price is below 100 ma
  2. Where price is rising (hl2 is greater than hl2 from 1 bars ago)
  3. Where price is within -2% of the 100 ma
The scan below utilizes @markos script from post #8
Ruby:
# MA Distance Percentage
# Paris
# 4.13.2018
# Computes percentage the current close is above/below the 200 DSMA
# Displays on a lower chart

declare lower;

input length = 200;

def data = close;
def avg = Average(data, length);
def pct = (data/avg) - 1;

plot dist = pct;
plot zero = 0;

zero.SetDefaultColor(Color.WHITE);
zero.SetLineWeight(2);
AddLabel(1, "Percentage from " + length + " MA: " + AsPercent(pct), if pct > 0 then Color.GREEN else Color.PINK);
Copy the above code
In Studies, click Create
Paste the above study
Name the study: Pct_From_MA
Save
Click on the scanner.

Where price is below ma
  1. Click on +Add filter
  2. Click on the pencil icon next to the filter you just added
  3. Click edit
  4. In the left column, click on the 1st pull-down window, click study
  5. Type in Pct_From_MA
  6. Under Plot, click on the pull-down window, choose dist
  7. In length change the 200 ma length to 100 ma length .... (or whatever moving average length that you want)
  8. In the middle column, choose Less than or equal to .... (if scanning for above ma change this to Greater than)
  9. In the right column, click on the pull-down window, click value
  10. Change 100 in the next box to 0
  11. Save

Where price is rising (hl2 is greater than hl2 from 1 bars ago)
  1. Click on +Add filter
  2. Click on the pencil icon next to the filter you just added
  3. Click edit
  4. In the left column, click on the 1st pull-down window, click price
  5. Click hl2 .... (or what ever representation of price that floats your boat)
  6. In the middle column, choose greater than or equal to
  7. In the right column, click on the pull-down window, click price
  8. Click hl2 .... (or what ever representation of price that floats your boat)
  9. In the box under hl2, change the 0 to 1 offset
  10. Save

Where price is within -2% of the ma
  1. Click on +Add filter
  2. Click on the pencil icon next to the filter you just added
  3. Click edit
  4. In the left column, click on the 1st pull-down window, click study
  5. Type in Pct_From_MA
  6. Under Plot, click on the pull-down window, choose dist
  7. In length change the 200 ma length to 100 ma length .... (or whatever moving average length that you want)
  8. In the middle column, choose greater than or equal to .... (or Less than if scanning for above ma)
  9. In the right column, click on the pull-down window, click value
  10. In the box under value, change the value from 100 to -0.02 .... (negative values represent under ma; positive values for above ma)
  11. Save .... (change the percentage to anything you want)

Remember: Change the aggregation of each filter to what you want
83orWtu.png


Here is a Shared Link: http://tos.mx/kXoe4Db
The shared link will only work if you copy and pasted the above study and named it: Pct_From_MA
A poster was having difficulty scanning for within a percentage of ma so I wrote this brief tutorial. I don't use moving average studies so I can not assist w/ how people are utilizing this in their strategies.
 
Last edited:

klepa

New member
Hi,

Trying to find if the current price(close) is more than X% than lowest green candle's close price, during the reg session (or at least within last X bars). Is there better way to code this?

Code:
plot digg =
(close[1] > open[1] and SecondsFromTime(0930)[1] > 0 and (close/close[1]-1)*100>1) or
(close[2] > open[2] and SecondsFromTime(0930)[2] > 0 and (close/close[2]-1)*100>1) or
(close[3] > open[3] and SecondsFromTime(0930)[3] > 0 and (close/close[3]-1)*100>1) or
(close[4] > open[4] and SecondsFromTime(0930)[4] > 0 and (close/close[4]-1)*100>1) or
(close[5] > open[5] and SecondsFromTime(0930)[5] > 0 and (close/close[5]-1)*100>1) or
(close[6] > open[6] and SecondsFromTime(0930)[6] > 0 and (close/close[6]-1)*100>1)
# and so on...
;


diff.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
 
Last edited:

klepa

New member
Figured out myself, if anyone is interested, here's the solution:

Code:
plot l = if SecondsFromTime(0930) > 0 then (Lowest(if close > open then close else Highest(high, 10), 10)) else double.nan;
 

diazlaz

Well-known member
2019 Donor
VIP
@klepa - tried something - how would you use/trade this?

8SbormU.png


Ruby:
#Find percent distance between lowest green candle and current price?
#https://usethinkscript.com/threads/find-percent-distance-between-lowest-green-candle-and-current-price.1234/#post-11205
#Request by @klepa
#
#2019.12.07 - diazlaz - initial port/Interpretation
input lookbackPeriod = 100; #1 to 256 bars
input showColorBars = yes;

def digg =
(close[1] > open[1] and SecondsFromTime(0930)[1] > 0 and (close/close[1]-1)*100>1) and 1 <= lookbackPeriod or
(close[2] > open[2] and SecondsFromTime(0930)[2] > 0 and (close/close[2]-1)*100>1) and 2 <= lookbackPeriod or
(close[3] > open[3] and SecondsFromTime(0930)[3] > 0 and (close/close[3]-1)*100>1) and 3 <= lookbackPeriod or
(close[4] > open[4] and SecondsFromTime(0930)[4] > 0 and (close/close[4]-1)*100>1) and 4 <= lookbackPeriod or
(close[5] > open[5] and SecondsFromTime(0930)[5] > 0 and (close/close[5]-1)*100>1) and 5 <= lookbackPeriod or
(close[6] > open[6] and SecondsFromTime(0930)[6] > 0 and (close/close[6]-1)*100>1) and 6 <= lookbackPeriod or
(close[7] > open[7] and SecondsFromTime(0930)[7] > 0 and (close/close[7]-1)*100>1) and 7 <= lookbackPeriod or
(close[8] > open[8] and SecondsFromTime(0930)[8] > 0 and (close/close[8]-1)*100>1) and 8 <= lookbackPeriod or
(close[9] > open[9] and SecondsFromTime(0930)[9] > 0 and (close/close[9]-1)*100>1) and 9 <= lookbackPeriod or
(close[10] > open[10] and SecondsFromTime(0930)[10] > 0 and (close/close[10]-1)*100>1) and 10 <= lookbackPeriod or
(close[11] > open[11] and SecondsFromTime(0930)[11] > 0 and (close/close[11]-1)*100>1) and 11 <= lookbackPeriod or
(close[12] > open[12] and SecondsFromTime(0930)[12] > 0 and (close/close[12]-1)*100>1) and 12 <= lookbackPeriod or
(close[13] > open[13] and SecondsFromTime(0930)[13] > 0 and (close/close[13]-1)*100>1) and 13 <= lookbackPeriod or
(close[14] > open[14] and SecondsFromTime(0930)[14] > 0 and (close/close[14]-1)*100>1) and 14 <= lookbackPeriod or
(close[15] > open[15] and SecondsFromTime(0930)[15] > 0 and (close/close[15]-1)*100>1) and 15 <= lookbackPeriod or
(close[16] > open[16] and SecondsFromTime(0930)[16] > 0 and (close/close[16]-1)*100>1) and 16 <= lookbackPeriod or
(close[17] > open[17] and SecondsFromTime(0930)[17] > 0 and (close/close[17]-1)*100>1) and 17 <= lookbackPeriod or
(close[18] > open[18] and SecondsFromTime(0930)[18] > 0 and (close/close[18]-1)*100>1) and 18 <= lookbackPeriod or
(close[19] > open[19] and SecondsFromTime(0930)[19] > 0 and (close/close[19]-1)*100>1) and 19 <= lookbackPeriod or
(close[20] > open[20] and SecondsFromTime(0930)[20] > 0 and (close/close[20]-1)*100>1) and 20 <= lookbackPeriod or
(close[21] > open[21] and SecondsFromTime(0930)[21] > 0 and (close/close[21]-1)*100>1) and 21 <= lookbackPeriod or
(close[22] > open[22] and SecondsFromTime(0930)[22] > 0 and (close/close[22]-1)*100>1) and 22 <= lookbackPeriod or
(close[23] > open[23] and SecondsFromTime(0930)[23] > 0 and (close/close[23]-1)*100>1) and 23 <= lookbackPeriod or
(close[24] > open[24] and SecondsFromTime(0930)[24] > 0 and (close/close[24]-1)*100>1) and 24 <= lookbackPeriod or
(close[25] > open[25] and SecondsFromTime(0930)[25] > 0 and (close/close[25]-1)*100>1) and 25 <= lookbackPeriod or
(close[26] > open[26] and SecondsFromTime(0930)[26] > 0 and (close/close[26]-1)*100>1) and 26 <= lookbackPeriod or
(close[27] > open[27] and SecondsFromTime(0930)[27] > 0 and (close/close[27]-1)*100>1) and 27 <= lookbackPeriod or
(close[28] > open[28] and SecondsFromTime(0930)[28] > 0 and (close/close[28]-1)*100>1) and 28 <= lookbackPeriod or
(close[29] > open[29] and SecondsFromTime(0930)[29] > 0 and (close/close[29]-1)*100>1) and 29 <= lookbackPeriod or
(close[30] > open[30] and SecondsFromTime(0930)[30] > 0 and (close/close[30]-1)*100>1) and 30 <= lookbackPeriod or
(close[31] > open[31] and SecondsFromTime(0930)[31] > 0 and (close/close[31]-1)*100>1) and 31 <= lookbackPeriod or
(close[32] > open[32] and SecondsFromTime(0930)[32] > 0 and (close/close[32]-1)*100>1) and 32 <= lookbackPeriod or
(close[33] > open[33] and SecondsFromTime(0930)[33] > 0 and (close/close[33]-1)*100>1) and 33 <= lookbackPeriod or
(close[34] > open[34] and SecondsFromTime(0930)[34] > 0 and (close/close[34]-1)*100>1) and 34 <= lookbackPeriod or
(close[35] > open[35] and SecondsFromTime(0930)[35] > 0 and (close/close[35]-1)*100>1) and 35 <= lookbackPeriod or
(close[36] > open[36] and SecondsFromTime(0930)[36] > 0 and (close/close[36]-1)*100>1) and 36 <= lookbackPeriod or
(close[37] > open[37] and SecondsFromTime(0930)[37] > 0 and (close/close[37]-1)*100>1) and 37 <= lookbackPeriod or
(close[38] > open[38] and SecondsFromTime(0930)[38] > 0 and (close/close[38]-1)*100>1) and 38 <= lookbackPeriod or
(close[39] > open[39] and SecondsFromTime(0930)[39] > 0 and (close/close[39]-1)*100>1) and 39 <= lookbackPeriod or
(close[40] > open[40] and SecondsFromTime(0930)[40] > 0 and (close/close[40]-1)*100>1) and 40 <= lookbackPeriod or
(close[41] > open[41] and SecondsFromTime(0930)[41] > 0 and (close/close[41]-1)*100>1) and 41 <= lookbackPeriod or
(close[42] > open[42] and SecondsFromTime(0930)[42] > 0 and (close/close[42]-1)*100>1) and 42 <= lookbackPeriod or
(close[43] > open[43] and SecondsFromTime(0930)[43] > 0 and (close/close[43]-1)*100>1) and 43 <= lookbackPeriod or
(close[44] > open[44] and SecondsFromTime(0930)[44] > 0 and (close/close[44]-1)*100>1) and 44 <= lookbackPeriod or
(close[45] > open[45] and SecondsFromTime(0930)[45] > 0 and (close/close[45]-1)*100>1) and 45 <= lookbackPeriod or
(close[46] > open[46] and SecondsFromTime(0930)[46] > 0 and (close/close[46]-1)*100>1) and 46 <= lookbackPeriod or
(close[47] > open[47] and SecondsFromTime(0930)[47] > 0 and (close/close[47]-1)*100>1) and 47 <= lookbackPeriod or
(close[48] > open[48] and SecondsFromTime(0930)[48] > 0 and (close/close[48]-1)*100>1) and 48 <= lookbackPeriod or
(close[49] > open[49] and SecondsFromTime(0930)[49] > 0 and (close/close[49]-1)*100>1) and 49 <= lookbackPeriod or
(close[50] > open[50] and SecondsFromTime(0930)[50] > 0 and (close/close[50]-1)*100>1) and 50 <= lookbackPeriod or
(close[51] > open[51] and SecondsFromTime(0930)[51] > 0 and (close/close[51]-1)*100>1) and 51 <= lookbackPeriod or
(close[52] > open[52] and SecondsFromTime(0930)[52] > 0 and (close/close[52]-1)*100>1) and 52 <= lookbackPeriod or
(close[53] > open[53] and SecondsFromTime(0930)[53] > 0 and (close/close[53]-1)*100>1) and 53 <= lookbackPeriod or
(close[54] > open[54] and SecondsFromTime(0930)[54] > 0 and (close/close[54]-1)*100>1) and 54 <= lookbackPeriod or
(close[55] > open[55] and SecondsFromTime(0930)[55] > 0 and (close/close[55]-1)*100>1) and 55 <= lookbackPeriod or
(close[56] > open[56] and SecondsFromTime(0930)[56] > 0 and (close/close[56]-1)*100>1) and 56 <= lookbackPeriod or
(close[57] > open[57] and SecondsFromTime(0930)[57] > 0 and (close/close[57]-1)*100>1) and 57 <= lookbackPeriod or
(close[58] > open[58] and SecondsFromTime(0930)[58] > 0 and (close/close[58]-1)*100>1) and 58 <= lookbackPeriod or
(close[59] > open[59] and SecondsFromTime(0930)[59] > 0 and (close/close[59]-1)*100>1) and 59 <= lookbackPeriod or
(close[60] > open[60] and SecondsFromTime(0930)[60] > 0 and (close/close[60]-1)*100>1) and 60 <= lookbackPeriod or
(close[61] > open[61] and SecondsFromTime(0930)[61] > 0 and (close/close[61]-1)*100>1) and 61 <= lookbackPeriod or
(close[62] > open[62] and SecondsFromTime(0930)[62] > 0 and (close/close[62]-1)*100>1) and 62 <= lookbackPeriod or
(close[63] > open[63] and SecondsFromTime(0930)[63] > 0 and (close/close[63]-1)*100>1) and 63 <= lookbackPeriod or
(close[64] > open[64] and SecondsFromTime(0930)[64] > 0 and (close/close[64]-1)*100>1) and 64 <= lookbackPeriod or
(close[65] > open[65] and SecondsFromTime(0930)[65] > 0 and (close/close[65]-1)*100>1) and 65 <= lookbackPeriod or
(close[66] > open[66] and SecondsFromTime(0930)[66] > 0 and (close/close[66]-1)*100>1) and 66 <= lookbackPeriod or
(close[67] > open[67] and SecondsFromTime(0930)[67] > 0 and (close/close[67]-1)*100>1) and 67 <= lookbackPeriod or
(close[68] > open[68] and SecondsFromTime(0930)[68] > 0 and (close/close[68]-1)*100>1) and 68 <= lookbackPeriod or
(close[69] > open[69] and SecondsFromTime(0930)[69] > 0 and (close/close[69]-1)*100>1) and 69 <= lookbackPeriod or
(close[70] > open[70] and SecondsFromTime(0930)[70] > 0 and (close/close[70]-1)*100>1) and 70 <= lookbackPeriod or
(close[71] > open[71] and SecondsFromTime(0930)[71] > 0 and (close/close[71]-1)*100>1) and 71 <= lookbackPeriod or
(close[72] > open[72] and SecondsFromTime(0930)[72] > 0 and (close/close[72]-1)*100>1) and 72 <= lookbackPeriod or
(close[73] > open[73] and SecondsFromTime(0930)[73] > 0 and (close/close[73]-1)*100>1) and 73 <= lookbackPeriod or
(close[74] > open[74] and SecondsFromTime(0930)[74] > 0 and (close/close[74]-1)*100>1) and 74 <= lookbackPeriod or
(close[75] > open[75] and SecondsFromTime(0930)[75] > 0 and (close/close[75]-1)*100>1) and 75 <= lookbackPeriod or
(close[76] > open[76] and SecondsFromTime(0930)[76] > 0 and (close/close[76]-1)*100>1) and 76 <= lookbackPeriod or
(close[77] > open[77] and SecondsFromTime(0930)[77] > 0 and (close/close[77]-1)*100>1) and 77 <= lookbackPeriod or
(close[78] > open[78] and SecondsFromTime(0930)[78] > 0 and (close/close[78]-1)*100>1) and 78 <= lookbackPeriod or
(close[79] > open[79] and SecondsFromTime(0930)[79] > 0 and (close/close[79]-1)*100>1) and 79 <= lookbackPeriod or
(close[80] > open[80] and SecondsFromTime(0930)[80] > 0 and (close/close[80]-1)*100>1) and 80 <= lookbackPeriod or
(close[81] > open[81] and SecondsFromTime(0930)[81] > 0 and (close/close[81]-1)*100>1) and 81 <= lookbackPeriod or
(close[82] > open[82] and SecondsFromTime(0930)[82] > 0 and (close/close[82]-1)*100>1) and 82 <= lookbackPeriod or
(close[83] > open[83] and SecondsFromTime(0930)[83] > 0 and (close/close[83]-1)*100>1) and 83 <= lookbackPeriod or
(close[84] > open[84] and SecondsFromTime(0930)[84] > 0 and (close/close[84]-1)*100>1) and 84 <= lookbackPeriod or
(close[85] > open[85] and SecondsFromTime(0930)[85] > 0 and (close/close[85]-1)*100>1) and 85 <= lookbackPeriod or
(close[86] > open[86] and SecondsFromTime(0930)[86] > 0 and (close/close[86]-1)*100>1) and 86 <= lookbackPeriod or
(close[87] > open[87] and SecondsFromTime(0930)[87] > 0 and (close/close[87]-1)*100>1) and 87 <= lookbackPeriod or
(close[88] > open[88] and SecondsFromTime(0930)[88] > 0 and (close/close[88]-1)*100>1) and 88 <= lookbackPeriod or
(close[89] > open[89] and SecondsFromTime(0930)[89] > 0 and (close/close[89]-1)*100>1) and 89 <= lookbackPeriod or
(close[90] > open[90] and SecondsFromTime(0930)[90] > 0 and (close/close[90]-1)*100>1) and 90 <= lookbackPeriod or
(close[91] > open[91] and SecondsFromTime(0930)[91] > 0 and (close/close[91]-1)*100>1) and 91 <= lookbackPeriod or
(close[92] > open[92] and SecondsFromTime(0930)[92] > 0 and (close/close[92]-1)*100>1) and 92 <= lookbackPeriod or
(close[93] > open[93] and SecondsFromTime(0930)[93] > 0 and (close/close[93]-1)*100>1) and 93 <= lookbackPeriod or
(close[94] > open[94] and SecondsFromTime(0930)[94] > 0 and (close/close[94]-1)*100>1) and 94 <= lookbackPeriod or
(close[95] > open[95] and SecondsFromTime(0930)[95] > 0 and (close/close[95]-1)*100>1) and 95 <= lookbackPeriod or
(close[96] > open[96] and SecondsFromTime(0930)[96] > 0 and (close/close[96]-1)*100>1) and 96 <= lookbackPeriod or
(close[97] > open[97] and SecondsFromTime(0930)[97] > 0 and (close/close[97]-1)*100>1) and 97 <= lookbackPeriod or
(close[98] > open[98] and SecondsFromTime(0930)[98] > 0 and (close/close[98]-1)*100>1) and 98 <= lookbackPeriod or
(close[99] > open[99] and SecondsFromTime(0930)[99] > 0 and (close/close[99]-1)*100>1) and 99 <= lookbackPeriod or
(close[100] > open[100] and SecondsFromTime(0930)[100] > 0 and (close/close[100]-1)*100>1) and 100 <= lookbackPeriod or
(close[101] > open[101] and SecondsFromTime(0930)[101] > 0 and (close/close[101]-1)*100>1) and 101 <= lookbackPeriod or
(close[102] > open[102] and SecondsFromTime(0930)[102] > 0 and (close/close[102]-1)*100>1) and 102 <= lookbackPeriod or
(close[103] > open[103] and SecondsFromTime(0930)[103] > 0 and (close/close[103]-1)*100>1) and 103 <= lookbackPeriod or
(close[104] > open[104] and SecondsFromTime(0930)[104] > 0 and (close/close[104]-1)*100>1) and 104 <= lookbackPeriod or
(close[105] > open[105] and SecondsFromTime(0930)[105] > 0 and (close/close[105]-1)*100>1) and 105 <= lookbackPeriod or
(close[106] > open[106] and SecondsFromTime(0930)[106] > 0 and (close/close[106]-1)*100>1) and 106 <= lookbackPeriod or
(close[107] > open[107] and SecondsFromTime(0930)[107] > 0 and (close/close[107]-1)*100>1) and 107 <= lookbackPeriod or
(close[108] > open[108] and SecondsFromTime(0930)[108] > 0 and (close/close[108]-1)*100>1) and 108 <= lookbackPeriod or
(close[109] > open[109] and SecondsFromTime(0930)[109] > 0 and (close/close[109]-1)*100>1) and 109 <= lookbackPeriod or
(close[110] > open[110] and SecondsFromTime(0930)[110] > 0 and (close/close[110]-1)*100>1) and 110 <= lookbackPeriod or
(close[111] > open[111] and SecondsFromTime(0930)[111] > 0 and (close/close[111]-1)*100>1) and 111 <= lookbackPeriod or
(close[112] > open[112] and SecondsFromTime(0930)[112] > 0 and (close/close[112]-1)*100>1) and 112 <= lookbackPeriod or
(close[113] > open[113] and SecondsFromTime(0930)[113] > 0 and (close/close[113]-1)*100>1) and 113 <= lookbackPeriod or
(close[114] > open[114] and SecondsFromTime(0930)[114] > 0 and (close/close[114]-1)*100>1) and 114 <= lookbackPeriod or
(close[115] > open[115] and SecondsFromTime(0930)[115] > 0 and (close/close[115]-1)*100>1) and 115 <= lookbackPeriod or
(close[116] > open[116] and SecondsFromTime(0930)[116] > 0 and (close/close[116]-1)*100>1) and 116 <= lookbackPeriod or
(close[117] > open[117] and SecondsFromTime(0930)[117] > 0 and (close/close[117]-1)*100>1) and 117 <= lookbackPeriod or
(close[118] > open[118] and SecondsFromTime(0930)[118] > 0 and (close/close[118]-1)*100>1) and 118 <= lookbackPeriod or
(close[119] > open[119] and SecondsFromTime(0930)[119] > 0 and (close/close[119]-1)*100>1) and 119 <= lookbackPeriod or
(close[120] > open[120] and SecondsFromTime(0930)[120] > 0 and (close/close[120]-1)*100>1) and 120 <= lookbackPeriod or
(close[121] > open[121] and SecondsFromTime(0930)[121] > 0 and (close/close[121]-1)*100>1) and 121 <= lookbackPeriod or
(close[122] > open[122] and SecondsFromTime(0930)[122] > 0 and (close/close[122]-1)*100>1) and 122 <= lookbackPeriod or
(close[123] > open[123] and SecondsFromTime(0930)[123] > 0 and (close/close[123]-1)*100>1) and 123 <= lookbackPeriod or
(close[124] > open[124] and SecondsFromTime(0930)[124] > 0 and (close/close[124]-1)*100>1) and 124 <= lookbackPeriod or
(close[125] > open[125] and SecondsFromTime(0930)[125] > 0 and (close/close[125]-1)*100>1) and 125 <= lookbackPeriod or
(close[126] > open[126] and SecondsFromTime(0930)[126] > 0 and (close/close[126]-1)*100>1) and 126 <= lookbackPeriod or
(close[127] > open[127] and SecondsFromTime(0930)[127] > 0 and (close/close[127]-1)*100>1) and 127 <= lookbackPeriod or
(close[128] > open[128] and SecondsFromTime(0930)[128] > 0 and (close/close[128]-1)*100>1) and 128 <= lookbackPeriod or
(close[129] > open[129] and SecondsFromTime(0930)[129] > 0 and (close/close[129]-1)*100>1) and 129 <= lookbackPeriod or
(close[130] > open[130] and SecondsFromTime(0930)[130] > 0 and (close/close[130]-1)*100>1) and 130 <= lookbackPeriod or
(close[131] > open[131] and SecondsFromTime(0930)[131] > 0 and (close/close[131]-1)*100>1) and 131 <= lookbackPeriod or
(close[132] > open[132] and SecondsFromTime(0930)[132] > 0 and (close/close[132]-1)*100>1) and 132 <= lookbackPeriod or
(close[133] > open[133] and SecondsFromTime(0930)[133] > 0 and (close/close[133]-1)*100>1) and 133 <= lookbackPeriod or
(close[134] > open[134] and SecondsFromTime(0930)[134] > 0 and (close/close[134]-1)*100>1) and 134 <= lookbackPeriod or
(close[135] > open[135] and SecondsFromTime(0930)[135] > 0 and (close/close[135]-1)*100>1) and 135 <= lookbackPeriod or
(close[136] > open[136] and SecondsFromTime(0930)[136] > 0 and (close/close[136]-1)*100>1) and 136 <= lookbackPeriod or
(close[137] > open[137] and SecondsFromTime(0930)[137] > 0 and (close/close[137]-1)*100>1) and 137 <= lookbackPeriod or
(close[138] > open[138] and SecondsFromTime(0930)[138] > 0 and (close/close[138]-1)*100>1) and 138 <= lookbackPeriod or
(close[139] > open[139] and SecondsFromTime(0930)[139] > 0 and (close/close[139]-1)*100>1) and 139 <= lookbackPeriod or
(close[140] > open[140] and SecondsFromTime(0930)[140] > 0 and (close/close[140]-1)*100>1) and 140 <= lookbackPeriod or
(close[141] > open[141] and SecondsFromTime(0930)[141] > 0 and (close/close[141]-1)*100>1) and 141 <= lookbackPeriod or
(close[142] > open[142] and SecondsFromTime(0930)[142] > 0 and (close/close[142]-1)*100>1) and 142 <= lookbackPeriod or
(close[143] > open[143] and SecondsFromTime(0930)[143] > 0 and (close/close[143]-1)*100>1) and 143 <= lookbackPeriod or
(close[144] > open[144] and SecondsFromTime(0930)[144] > 0 and (close/close[144]-1)*100>1) and 144 <= lookbackPeriod or
(close[145] > open[145] and SecondsFromTime(0930)[145] > 0 and (close/close[145]-1)*100>1) and 145 <= lookbackPeriod or
(close[146] > open[146] and SecondsFromTime(0930)[146] > 0 and (close/close[146]-1)*100>1) and 146 <= lookbackPeriod or
(close[147] > open[147] and SecondsFromTime(0930)[147] > 0 and (close/close[147]-1)*100>1) and 147 <= lookbackPeriod or
(close[148] > open[148] and SecondsFromTime(0930)[148] > 0 and (close/close[148]-1)*100>1) and 148 <= lookbackPeriod or
(close[149] > open[149] and SecondsFromTime(0930)[149] > 0 and (close/close[149]-1)*100>1) and 149 <= lookbackPeriod or
(close[150] > open[150] and SecondsFromTime(0930)[150] > 0 and (close/close[150]-1)*100>1) and 150 <= lookbackPeriod or
(close[151] > open[151] and SecondsFromTime(0930)[151] > 0 and (close/close[151]-1)*100>1) and 151 <= lookbackPeriod or
(close[152] > open[152] and SecondsFromTime(0930)[152] > 0 and (close/close[152]-1)*100>1) and 152 <= lookbackPeriod or
(close[153] > open[153] and SecondsFromTime(0930)[153] > 0 and (close/close[153]-1)*100>1) and 153 <= lookbackPeriod or
(close[154] > open[154] and SecondsFromTime(0930)[154] > 0 and (close/close[154]-1)*100>1) and 154 <= lookbackPeriod or
(close[155] > open[155] and SecondsFromTime(0930)[155] > 0 and (close/close[155]-1)*100>1) and 155 <= lookbackPeriod or
(close[156] > open[156] and SecondsFromTime(0930)[156] > 0 and (close/close[156]-1)*100>1) and 156 <= lookbackPeriod or
(close[157] > open[157] and SecondsFromTime(0930)[157] > 0 and (close/close[157]-1)*100>1) and 157 <= lookbackPeriod or
(close[158] > open[158] and SecondsFromTime(0930)[158] > 0 and (close/close[158]-1)*100>1) and 158 <= lookbackPeriod or
(close[159] > open[159] and SecondsFromTime(0930)[159] > 0 and (close/close[159]-1)*100>1) and 159 <= lookbackPeriod or
(close[160] > open[160] and SecondsFromTime(0930)[160] > 0 and (close/close[160]-1)*100>1) and 160 <= lookbackPeriod or
(close[161] > open[161] and SecondsFromTime(0930)[161] > 0 and (close/close[161]-1)*100>1) and 161 <= lookbackPeriod or
(close[162] > open[162] and SecondsFromTime(0930)[162] > 0 and (close/close[162]-1)*100>1) and 162 <= lookbackPeriod or
(close[163] > open[163] and SecondsFromTime(0930)[163] > 0 and (close/close[163]-1)*100>1) and 163 <= lookbackPeriod or
(close[164] > open[164] and SecondsFromTime(0930)[164] > 0 and (close/close[164]-1)*100>1) and 164 <= lookbackPeriod or
(close[165] > open[165] and SecondsFromTime(0930)[165] > 0 and (close/close[165]-1)*100>1) and 165 <= lookbackPeriod or
(close[166] > open[166] and SecondsFromTime(0930)[166] > 0 and (close/close[166]-1)*100>1) and 166 <= lookbackPeriod or
(close[167] > open[167] and SecondsFromTime(0930)[167] > 0 and (close/close[167]-1)*100>1) and 167 <= lookbackPeriod or
(close[168] > open[168] and SecondsFromTime(0930)[168] > 0 and (close/close[168]-1)*100>1) and 168 <= lookbackPeriod or
(close[169] > open[169] and SecondsFromTime(0930)[169] > 0 and (close/close[169]-1)*100>1) and 169 <= lookbackPeriod or
(close[170] > open[170] and SecondsFromTime(0930)[170] > 0 and (close/close[170]-1)*100>1) and 170 <= lookbackPeriod or
(close[171] > open[171] and SecondsFromTime(0930)[171] > 0 and (close/close[171]-1)*100>1) and 171 <= lookbackPeriod or
(close[172] > open[172] and SecondsFromTime(0930)[172] > 0 and (close/close[172]-1)*100>1) and 172 <= lookbackPeriod or
(close[173] > open[173] and SecondsFromTime(0930)[173] > 0 and (close/close[173]-1)*100>1) and 173 <= lookbackPeriod or
(close[174] > open[174] and SecondsFromTime(0930)[174] > 0 and (close/close[174]-1)*100>1) and 174 <= lookbackPeriod or
(close[175] > open[175] and SecondsFromTime(0930)[175] > 0 and (close/close[175]-1)*100>1) and 175 <= lookbackPeriod or
(close[176] > open[176] and SecondsFromTime(0930)[176] > 0 and (close/close[176]-1)*100>1) and 176 <= lookbackPeriod or
(close[177] > open[177] and SecondsFromTime(0930)[177] > 0 and (close/close[177]-1)*100>1) and 177 <= lookbackPeriod or
(close[178] > open[178] and SecondsFromTime(0930)[178] > 0 and (close/close[178]-1)*100>1) and 178 <= lookbackPeriod or
(close[179] > open[179] and SecondsFromTime(0930)[179] > 0 and (close/close[179]-1)*100>1) and 179 <= lookbackPeriod or
(close[180] > open[180] and SecondsFromTime(0930)[180] > 0 and (close/close[180]-1)*100>1) and 180 <= lookbackPeriod or
(close[181] > open[181] and SecondsFromTime(0930)[181] > 0 and (close/close[181]-1)*100>1) and 181 <= lookbackPeriod or
(close[182] > open[182] and SecondsFromTime(0930)[182] > 0 and (close/close[182]-1)*100>1) and 182 <= lookbackPeriod or
(close[183] > open[183] and SecondsFromTime(0930)[183] > 0 and (close/close[183]-1)*100>1) and 183 <= lookbackPeriod or
(close[184] > open[184] and SecondsFromTime(0930)[184] > 0 and (close/close[184]-1)*100>1) and 184 <= lookbackPeriod or
(close[185] > open[185] and SecondsFromTime(0930)[185] > 0 and (close/close[185]-1)*100>1) and 185 <= lookbackPeriod or
(close[186] > open[186] and SecondsFromTime(0930)[186] > 0 and (close/close[186]-1)*100>1) and 186 <= lookbackPeriod or
(close[187] > open[187] and SecondsFromTime(0930)[187] > 0 and (close/close[187]-1)*100>1) and 187 <= lookbackPeriod or
(close[188] > open[188] and SecondsFromTime(0930)[188] > 0 and (close/close[188]-1)*100>1) and 188 <= lookbackPeriod or
(close[189] > open[189] and SecondsFromTime(0930)[189] > 0 and (close/close[189]-1)*100>1) and 189 <= lookbackPeriod or
(close[190] > open[190] and SecondsFromTime(0930)[190] > 0 and (close/close[190]-1)*100>1) and 190 <= lookbackPeriod or
(close[191] > open[191] and SecondsFromTime(0930)[191] > 0 and (close/close[191]-1)*100>1) and 191 <= lookbackPeriod or
(close[192] > open[192] and SecondsFromTime(0930)[192] > 0 and (close/close[192]-1)*100>1) and 192 <= lookbackPeriod or
(close[193] > open[193] and SecondsFromTime(0930)[193] > 0 and (close/close[193]-1)*100>1) and 193 <= lookbackPeriod or
(close[194] > open[194] and SecondsFromTime(0930)[194] > 0 and (close/close[194]-1)*100>1) and 194 <= lookbackPeriod or
(close[195] > open[195] and SecondsFromTime(0930)[195] > 0 and (close/close[195]-1)*100>1) and 195 <= lookbackPeriod or
(close[196] > open[196] and SecondsFromTime(0930)[196] > 0 and (close/close[196]-1)*100>1) and 196 <= lookbackPeriod or
(close[197] > open[197] and SecondsFromTime(0930)[197] > 0 and (close/close[197]-1)*100>1) and 197 <= lookbackPeriod or
(close[198] > open[198] and SecondsFromTime(0930)[198] > 0 and (close/close[198]-1)*100>1) and 198 <= lookbackPeriod or
(close[199] > open[199] and SecondsFromTime(0930)[199] > 0 and (close/close[199]-1)*100>1) and 199 <= lookbackPeriod or
(close[200] > open[200] and SecondsFromTime(0930)[200] > 0 and (close/close[200]-1)*100>1) and 200 <= lookbackPeriod or
(close[201] > open[201] and SecondsFromTime(0930)[201] > 0 and (close/close[201]-1)*100>1) and 201 <= lookbackPeriod or
(close[202] > open[202] and SecondsFromTime(0930)[202] > 0 and (close/close[202]-1)*100>1) and 202 <= lookbackPeriod or
(close[203] > open[203] and SecondsFromTime(0930)[203] > 0 and (close/close[203]-1)*100>1) and 203 <= lookbackPeriod or
(close[204] > open[204] and SecondsFromTime(0930)[204] > 0 and (close/close[204]-1)*100>1) and 204 <= lookbackPeriod or
(close[205] > open[205] and SecondsFromTime(0930)[205] > 0 and (close/close[205]-1)*100>1) and 205 <= lookbackPeriod or
(close[206] > open[206] and SecondsFromTime(0930)[206] > 0 and (close/close[206]-1)*100>1) and 206 <= lookbackPeriod or
(close[207] > open[207] and SecondsFromTime(0930)[207] > 0 and (close/close[207]-1)*100>1) and 207 <= lookbackPeriod or
(close[208] > open[208] and SecondsFromTime(0930)[208] > 0 and (close/close[208]-1)*100>1) and 208 <= lookbackPeriod or
(close[209] > open[209] and SecondsFromTime(0930)[209] > 0 and (close/close[209]-1)*100>1) and 209 <= lookbackPeriod or
(close[210] > open[210] and SecondsFromTime(0930)[210] > 0 and (close/close[210]-1)*100>1) and 210 <= lookbackPeriod or
(close[211] > open[211] and SecondsFromTime(0930)[211] > 0 and (close/close[211]-1)*100>1) and 211 <= lookbackPeriod or
(close[212] > open[212] and SecondsFromTime(0930)[212] > 0 and (close/close[212]-1)*100>1) and 212 <= lookbackPeriod or
(close[213] > open[213] and SecondsFromTime(0930)[213] > 0 and (close/close[213]-1)*100>1) and 213 <= lookbackPeriod or
(close[214] > open[214] and SecondsFromTime(0930)[214] > 0 and (close/close[214]-1)*100>1) and 214 <= lookbackPeriod or
(close[215] > open[215] and SecondsFromTime(0930)[215] > 0 and (close/close[215]-1)*100>1) and 215 <= lookbackPeriod or
(close[216] > open[216] and SecondsFromTime(0930)[216] > 0 and (close/close[216]-1)*100>1) and 216 <= lookbackPeriod or
(close[217] > open[217] and SecondsFromTime(0930)[217] > 0 and (close/close[217]-1)*100>1) and 217 <= lookbackPeriod or
(close[218] > open[218] and SecondsFromTime(0930)[218] > 0 and (close/close[218]-1)*100>1) and 218 <= lookbackPeriod or
(close[219] > open[219] and SecondsFromTime(0930)[219] > 0 and (close/close[219]-1)*100>1) and 219 <= lookbackPeriod or
(close[220] > open[220] and SecondsFromTime(0930)[220] > 0 and (close/close[220]-1)*100>1) and 220 <= lookbackPeriod or
(close[221] > open[221] and SecondsFromTime(0930)[221] > 0 and (close/close[221]-1)*100>1) and 221 <= lookbackPeriod or
(close[222] > open[222] and SecondsFromTime(0930)[222] > 0 and (close/close[222]-1)*100>1) and 222 <= lookbackPeriod or
(close[223] > open[223] and SecondsFromTime(0930)[223] > 0 and (close/close[223]-1)*100>1) and 223 <= lookbackPeriod or
(close[224] > open[224] and SecondsFromTime(0930)[224] > 0 and (close/close[224]-1)*100>1) and 224 <= lookbackPeriod or
(close[225] > open[225] and SecondsFromTime(0930)[225] > 0 and (close/close[225]-1)*100>1) and 225 <= lookbackPeriod or
(close[226] > open[226] and SecondsFromTime(0930)[226] > 0 and (close/close[226]-1)*100>1) and 226 <= lookbackPeriod or
(close[227] > open[227] and SecondsFromTime(0930)[227] > 0 and (close/close[227]-1)*100>1) and 227 <= lookbackPeriod or
(close[228] > open[228] and SecondsFromTime(0930)[228] > 0 and (close/close[228]-1)*100>1) and 228 <= lookbackPeriod or
(close[229] > open[229] and SecondsFromTime(0930)[229] > 0 and (close/close[229]-1)*100>1) and 229 <= lookbackPeriod or
(close[230] > open[230] and SecondsFromTime(0930)[230] > 0 and (close/close[230]-1)*100>1) and 230 <= lookbackPeriod or
(close[231] > open[231] and SecondsFromTime(0930)[231] > 0 and (close/close[231]-1)*100>1) and 231 <= lookbackPeriod or
(close[232] > open[232] and SecondsFromTime(0930)[232] > 0 and (close/close[232]-1)*100>1) and 232 <= lookbackPeriod or
(close[233] > open[233] and SecondsFromTime(0930)[233] > 0 and (close/close[233]-1)*100>1) and 233 <= lookbackPeriod or
(close[234] > open[234] and SecondsFromTime(0930)[234] > 0 and (close/close[234]-1)*100>1) and 234 <= lookbackPeriod or
(close[235] > open[235] and SecondsFromTime(0930)[235] > 0 and (close/close[235]-1)*100>1) and 235 <= lookbackPeriod or
(close[236] > open[236] and SecondsFromTime(0930)[236] > 0 and (close/close[236]-1)*100>1) and 236 <= lookbackPeriod or
(close[237] > open[237] and SecondsFromTime(0930)[237] > 0 and (close/close[237]-1)*100>1) and 237 <= lookbackPeriod or
(close[238] > open[238] and SecondsFromTime(0930)[238] > 0 and (close/close[238]-1)*100>1) and 238 <= lookbackPeriod or
(close[239] > open[239] and SecondsFromTime(0930)[239] > 0 and (close/close[239]-1)*100>1) and 239 <= lookbackPeriod or
(close[240] > open[240] and SecondsFromTime(0930)[240] > 0 and (close/close[240]-1)*100>1) and 240 <= lookbackPeriod or
(close[241] > open[241] and SecondsFromTime(0930)[241] > 0 and (close/close[241]-1)*100>1) and 241 <= lookbackPeriod or
(close[242] > open[242] and SecondsFromTime(0930)[242] > 0 and (close/close[242]-1)*100>1) and 242 <= lookbackPeriod or
(close[243] > open[243] and SecondsFromTime(0930)[243] > 0 and (close/close[243]-1)*100>1) and 243 <= lookbackPeriod or
(close[244] > open[244] and SecondsFromTime(0930)[244] > 0 and (close/close[244]-1)*100>1) and 244 <= lookbackPeriod or
(close[245] > open[245] and SecondsFromTime(0930)[245] > 0 and (close/close[245]-1)*100>1) and 245 <= lookbackPeriod or
(close[246] > open[246] and SecondsFromTime(0930)[246] > 0 and (close/close[246]-1)*100>1) and 246 <= lookbackPeriod or
(close[247] > open[247] and SecondsFromTime(0930)[247] > 0 and (close/close[247]-1)*100>1) and 247 <= lookbackPeriod or
(close[248] > open[248] and SecondsFromTime(0930)[248] > 0 and (close/close[248]-1)*100>1) and 248 <= lookbackPeriod or
(close[249] > open[249] and SecondsFromTime(0930)[249] > 0 and (close/close[249]-1)*100>1) and 249 <= lookbackPeriod or
(close[250] > open[250] and SecondsFromTime(0930)[250] > 0 and (close/close[250]-1)*100>1) and 250 <= lookbackPeriod or
(close[251] > open[251] and SecondsFromTime(0930)[251] > 0 and (close/close[251]-1)*100>1) and 251 <= lookbackPeriod or
(close[252] > open[252] and SecondsFromTime(0930)[252] > 0 and (close/close[252]-1)*100>1) and 252 <= lookbackPeriod or
(close[253] > open[253] and SecondsFromTime(0930)[253] > 0 and (close/close[253]-1)*100>1) and 253 <= lookbackPeriod or
(close[254] > open[254] and SecondsFromTime(0930)[254] > 0 and (close/close[254]-1)*100>1) and 254 <= lookbackPeriod or
(close[255] > open[255] and SecondsFromTime(0930)[255] > 0 and (close/close[255]-1)*100>1) and 255 <= lookbackPeriod or
(close[256] > open[256] and SecondsFromTime(0930)[256] > 0 and (close/close[256]-1)*100>1) and 256 <= lookbackPeriod;

def sClose = if digg then close else sClose[1];
AddLabel(1,"Last: " + AsDollars(sClose));

#COLORBARS
AssignPriceColor(if showColorBars then
if digg then Color.WHITE
  else Color.GRAY
else
  COLOR.CURRENT
);
 

tomsk

Well-known member
VIP
Here is a scan for stocks with a close that is 10% above 50 day EMA. I just ran that scan query on the S&P 500 and found 2 results on a daily agg.

Code:
close crosses above ExpAverage(close, 50) * 1.1
 

Jimmy

New member
Looking to put together a watch column/chart label that shows the following:
1) distance from the 9 sma both in percentage and actual price difference
2) distance from VWAP both in percentage and actual price difference.
Then label with percentage and actual price difference with the following conditions.
If price is above both the 9sma and VWAP label is green.
If price is below the 9 but above VWAP label is yellow.
If price is below VWAP but above the 9 label is orange
If price is below both the 9sma and VWAP label is red.
Would like to use on multiple time frames.
Example... daily, hourly, 10 min.

I can make individual labels showing percentage away from the 9 and VWAP but don't know the input for actual price or how to combine all the info into one label.
Thanks in advance for any insight,
Jimmy
 

dj45

New member
I'm guessing someone has built this wheel before. Basically looking to plot the distance in % that close price is from a moving average. Since this plot will essentially oscillate, plotting horizontal lines to mark x% above and x% below makes it easy to see if price is overextended in either direction. So user defined inputs would be:
  1. length of MA
  2. simple or exponential
  3. values for horizontal lines
Edit: here the code I found:

Code:
# MovingAvgDistance
# DREWGRIFFITH5 (C) 2015

declare lower;

input price = close;
input averageType = {default Exponential, Simple, Weighted, Wilders, Hull};
input length = 300;

def avg;

switch (averageType) {

case Exponential:
    avg = ExpAverage(price, length);
 case Simple:
    avg = Average(price, length);
 case Weighted:
    avg = wma(price, length);
 case Wilders:
    avg = WildersAverage(price, length);
 case Hull:
    avg = HullMovingAvg(price, length);

}

plot dist = ((price - avg) / ((price + avg) / 2)) * 100;
dist.SETLINEWEIGHT(3);

plot prev_high = Highest(dist, LENGTH = length)[1];
plot prev_low = Lowest(dist, LENGTH = length)[1];
prev_high.hide();
prev_low.hide();

dist.SETDEFAULTCOLOR(Color.cyan);
dist.AssignValueColor(if dist > prev_high then Color.RED else if dist < prev_low then Color.GREEN else Color.gray);

plot centerline = 0;
centerline.SETDEFAULTCOLOR(Color.yellow);

# Add label
AddLabel(dist, dist, if dist > prev_high then Color.RED else if dist < prev_low then Color.GREEN else Color.gray);
 
Last edited by a moderator:

horserider

Well-known member
VIP
Code:
declare lower;

input price = close;
input length = 200;
input AverageType = {default Simple, Exponential};
input pdl = 3;
input ndl = -3;
def MA = MovingAverage(AverageType, ( price[0]), length);
plot DEV = (price / MA - 1 ) * 1000;

plot pdll = pdl;
plot ndll = ndl;
plot zero = 0;

DEV.SetDefaultColor(GetColor(1));

AddLabel(1, "Percentage from " + length + " MA: " + AsPercent(DEV * .01), if DEV > 0 then Color.GREEN else Color.PINK);
 
Last edited:

markos

Well-known member
VIP
Here's another way to do it in a label:

Code:
# MA Distance Percentage
# Paris
# 4.13.2018
# Computes percentage the current close is above/below the 200 DSMA
# Displays on a lower chart

declare lower;

input length = 200;

def data = close;
def avg = Average(data, length);
def pct = (data/avg) - 1;

plot dist = pct;
plot zero = 0;

zero.SetDefaultColor(Color.WHITE);
zero.SetLineWeight(2);

AddLabel(1, "Percentage from " + length + " MA: " + AsPercent(pct), if pct > 0 then Color.GREEN else Color.PINK);

The script below can be used if you want to scan for price trading between two different moving averages.

Code:
# Stock price trading between two moving averages

input price = close;
input length1 = 50;
input length2 = 200;
input displace = 0;

def AvgExp1 = ExpAverage(price[-displace], length1);
def AvgExp2 = ExpAverage(price[-displace], length2);

def between_ma = price > AvgExp1 and price < AvgExp2;
plot scan = if between_ma then 1 else 0;
 

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

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);
 

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

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);
 

nervo88

New member
Hello All !

I'm new for scripts in the scanner.

1. I'm trying to create a scan with two conditions but with the OR option:

EMA 9 crosses 50 EMA , price closed

OR

EMA 9 cross 200 EMA , price closed

2. Is there an option to add conditions like: EMA9 very close to 50 EMA (like in % maybe? ) so it will almost indicate a cross. ofcorse not a 100% , but still, is this possible?


Thank you for your help !
 

Similar threads

Top