top of page

Free indicators

Public·5 members

MTF Swing Arm 1 minute Chart

# ─────────────────────────────────────────────

# │ MarketFragments.com | DNA & Market │

# │ info@marketfragments.com │

# │ www.marketfragments.com │

# ─────────────────────────────────────────────

# Time →

# │

# █ █ █│ █

# █ █ █ │ █ █

# █ █ █ │ █ █ █ ╭─╮

# █ █ █ │ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ █ █╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ ╰─────╯

# ──────┴──────────────────────────────────────────────────────────────

# T1 T2 T3 T4 T5 T6

# MTF Swing Arm

declare lower;

#COLORS

DefineGlobalColor("Sync1", Color.MAGENTA);

DefineGlobalColor("Sync2", Color.ORANGE);

DefineGlobalColor("Up", Color.UPTICK);

DefineGlobalColor("Down", Color.DOWNTICK);

DefineGlobalColor("NUp", Color.DARK_GREEN);

DefineGlobalColor("NDown", Color.DARK_RED);

DefineGlobalColor("NUp2", Color.LIME);

DefineGlobalColor("NDown2", Color.ORANGE);

DefineGlobalColor("NUp3", Color.GREEN);

DefineGlobalColor("NDown3", Color.RED);

DefineGlobalColor("NUp4", Color.LIME);

DefineGlobalColor("NDown4", Color.PINK);

DefineGlobalColor("NUp5", Color.LIGHT_GREEN);

DefineGlobalColor("NDown5", Color.LIGHT_RED);

DefineGlobalColor("On", Color.GREEN);

DefineGlobalColor("Off", Color.DARK_GRAY);

DefineGlobalColor("Off2", Color.GRAY);

DefineGlobalColor("Bullish", Color.GREEN);

DefineGlobalColor("Bearish", Color.RED);

DefineGlobalColor("Neutral", Color.BLUE);

DefineGlobalColor("Neutral1", Color.YELLOW);

DefineGlobalColor("Neutral2", Color.CYAN);

DefineGlobalColor("Neutral3", Color.WHITE);

#name: MTF Swing Arm mod

#INPUTS CORE

input chartPlacement = { upper, default lower, lower2, debug};

input showPlots = yes; #plot main plots

input showLabels = yes; #show main labels

input showTitle = yes; #show title buttons

input showStats = yes; #show stats buttons

input showTrading = yes; #show trading buttons

input showBubbles = no; #show bubbles in dashboard

input enableAlerts = no; #enable alerts

input aggregationLimit = 9;

input displace = 0;

input entryThreshold = 4;

input caclLongerTimeFrame = no;

def na = Double.NaN;

def SYNC = BarNumber() % 2 == 0;


#AGGREGATIONS

def h_M1 = high(period = AggregationPeriod.MIN);

def l_M1 = low(period = AggregationPeriod.MIN);

def o_M1 = open(period = AggregationPeriod.MIN);

def c_M1 = close(period = AggregationPeriod.MIN);

def hl_M1 = hl2(period = AggregationPeriod.MIN);

def hlc_M1 = hlc3(period = AggregationPeriod.MIN);

def v_M1 = volume(period = AggregationPeriod.MIN);

def vw_M1 = vwap(period = AggregationPeriod.MIN);


def h_M2 = high(period = AggregationPeriod.TWO_MIN);

def l_M2 = low(period = AggregationPeriod.TWO_MIN);

def o_M2 = open(period = AggregationPeriod.TWO_MIN);

def c_M2 = close(period = AggregationPeriod.TWO_MIN);

def hl_M2 = hl2(period = AggregationPeriod.TWO_MIN);

def hlc_M2 = hlc3(period = AggregationPeriod.TWO_MIN);

def v_M2 = volume(period = AggregationPeriod.TWO_MIN);

def vw_M2 = vwap(period = AggregationPeriod.TWO_MIN);


def h_M3 = high(period = AggregationPeriod.THREE_MIN);

def l_M3 = low(period = AggregationPeriod.THREE_MIN);

def o_M3 = open(period = AggregationPeriod.THREE_MIN);

def c_M3 = close(period = AggregationPeriod.THREE_MIN);

def hl_M3 = hl2(period = AggregationPeriod.THREE_MIN);

def hlc_M3 = hlc3(period = AggregationPeriod.THREE_MIN);

def v_M3 = volume(period = AggregationPeriod.THREE_MIN);

def vw_M3 = vwap(period = AggregationPeriod.THREE_MIN);


def h_M4 = high(period = AggregationPeriod.FOUR_MIN);

def l_M4 = low(period = AggregationPeriod.FOUR_MIN);

def o_M4 = open(period = AggregationPeriod.FOUR_MIN);

def c_M4 = close(period = AggregationPeriod.FOUR_MIN);

def hl_M4 = hl2(period = AggregationPeriod.FOUR_MIN);

def hlc_M4 = hlc3(period = AggregationPeriod.FOUR_MIN);

def v_M4 = volume(period = AggregationPeriod.FOUR_MIN);

def vw_M4 = vwap(period = AggregationPeriod.FOUR_MIN);


def h_M5 = high(period = AggregationPeriod.FIVE_MIN);

def l_M5 = low(period = AggregationPeriod.FIVE_MIN);

def o_M5 = open(period = AggregationPeriod.FIVE_MIN);

def c_M5 = close(period = AggregationPeriod.FIVE_MIN);

def hl_M5 = hl2(period = AggregationPeriod.FIVE_MIN);

def hlc_M5 = hlc3(period = AggregationPeriod.FIVE_MIN);

def v_M5 = volume(period = AggregationPeriod.FIVE_MIN);

def vw_M5 = vwap(period = AggregationPeriod.FIVE_MIN);


def h_M10 = high(period = AggregationPeriod.TEN_MIN);

def l_M10 = low(period = AggregationPeriod.TEN_MIN);

def o_M10 = open(period = AggregationPeriod.TEN_MIN);

def c_M10 = close(period = AggregationPeriod.TEN_MIN);

def hl_M10 = hl2(period = AggregationPeriod.TEN_MIN);

def hlc_M10 = hlc3(period = AggregationPeriod.TEN_MIN);

def v_M10 = volume(period = AggregationPeriod.TEN_MIN);

def vw_M10 = vwap(period = AggregationPeriod.TEN_MIN);


def h_M15 = high(period = AggregationPeriod.FIFTEEN_MIN);

def l_M15 = low(period = AggregationPeriod.FIFTEEN_MIN);

def o_M15 = open(period = AggregationPeriod.FIFTEEN_MIN);

def c_M15 = close(period = AggregationPeriod.FIFTEEN_MIN);

def hl_M15 = hl2(period = AggregationPeriod.FIFTEEN_MIN);

def hlc_M15 = hlc3(period = AggregationPeriod.FIFTEEN_MIN);

def v_M15 = volume(period = AggregationPeriod.FIFTEEN_MIN);

def vw_M15 = vwap(period = AggregationPeriod.FIFTEEN_MIN);


def h_M30 = high(period = AggregationPeriod.THIRTY_MIN);

def l_M30 = low(period = AggregationPeriod.THIRTY_MIN);

def o_M30 = open(period = AggregationPeriod.THIRTY_MIN);

def c_M30 = close(period = AggregationPeriod.THIRTY_MIN);

def hl_M30 = hl2(period = AggregationPeriod.THIRTY_MIN);

def hlc_M30 = hlc3(period = AggregationPeriod.THIRTY_MIN);

def v_M30 = volume(period = AggregationPeriod.THIRTY_MIN);

def vw_M30 = vwap(period = AggregationPeriod.THIRTY_MIN);


def h_H1 = high(period = AggregationPeriod.HOUR);

def l_H1 = low(period = AggregationPeriod.HOUR);

def o_H1 = open(period = AggregationPeriod.HOUR);

def c_H1 = close(period = AggregationPeriod.HOUR);

def hl_H1 = hl2(period = AggregationPeriod.HOUR);

def hlc_H1 = hlc3(period = AggregationPeriod.HOUR);

def v_H1 = volume(period = AggregationPeriod.HOUR);

def vw_H1 = vwap(period = AggregationPeriod.HOUR);


input trailType = {default modified, unmodified};

input ATRPeriod = 28;

input ATRFactor = 5.0;

input firstTrade = {default long, short};

input fibLevel = 88.6;


def M1_HILO = Min(h_M1 - l_M1, 1.5 * Average(h_M1 - l_M1, ATRPeriod));

def M1_HREF = if l_M1 <= h_M1[1]

then h_M1 - c_M1[1]

else (h_M1 - c_M1[1]) - 0.5 * (l_M1 - h_M1[1]);

def M1_LREF = if h_M1 >= l_M1[1]

then c_M1[1] - l_M1

else (c_M1[1] - l_M1) - 0.5 * (l_M1[1] - h_M1);

def M1_TRUERANGEV;

switch (trailType) {

case modified:

M1_TRUERANGEV = Max(M1_HILO, Max(M1_HREF, M1_LREF));

case unmodified:

M1_TRUERANGEV = TrueRange(h_M1, c_M1, l_M1);

}

def M1_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M1_TRUERANGEV, ATRPeriod);

def M1_STATE = {default init, long, short};

def M1_TRAIL;

switch (M1_STATE[1]) {

case init:

if (!IsNaN(M1_LOSS)) {

switch (firstTrade) {

case long:

M1_STATE = M1_STATE.long;

M1_TRAIL = c_M1 - M1_LOSS;

case short:

M1_STATE = M1_STATE.short;

M1_TRAIL = c_M1 + M1_LOSS;

}

} else {

M1_STATE = M1_STATE.init;

M1_TRAIL = Double.NaN;

}

case long:

if (c_M1 > M1_TRAIL[1]) {

M1_STATE = M1_STATE.long;

M1_TRAIL = Max(M1_TRAIL[1], c_M1 - M1_LOSS);

} else {

M1_STATE = M1_STATE.short;

M1_TRAIL = c_M1 + M1_LOSS;

}

case short:

if (c_M1 < M1_TRAIL[1]) {

M1_STATE = M1_STATE.short;

M1_TRAIL = Min(M1_TRAIL[1], c_M1 + M1_LOSS);

} else {

M1_STATE = M1_STATE.long;

M1_TRAIL = c_M1 - M1_LOSS;

}

}

def M1_BUYSIGNAL = Crosses(M1_STATE == M1_STATE.long, 0, CrossingDirection.ABOVE);

def M1_SELLSIGNAL = Crosses(M1_STATE == M1_STATE.short, 0, CrossingDirection.ABOVE);

def M1_EX = CompoundValue(1, if M1_BUYSIGNAL then h_M1 else if M1_SELLSIGNAL then l_M1 else if M1_STATE == M1_STATE.long then Max(M1_EX[1], h_M1) else if M1_STATE == M1_STATE.short then Min(M1_EX[1], l_M1) else M1_EX[1], 0);

def M1_FIB = M1_EX + (M1_TRAIL - M1_EX) * fibLevel / 100;

def M1_SDIR = if M1_STATE == M1_STATE.long then 100 else -100;

def M1_INZONE = If(M1_SDIR == 100, l_M1 < M1_FIB, h_M1 > M1_FIB);

def M1_SSTATE1 =

if M1_SDIR == 100 and M1_INZONE then 10 else

if M1_SDIR == 100 then 100 else

if M1_SDIR == -100 and M1_INZONE then -10 else

if M1_SDIR == -100 then -100 else M1_SSTATE1[1];

def M1_SSTATE2 = If(M1_SSTATE1 != M1_SSTATE1[1], M1_SSTATE1, 0);

def M1_SSTATE = M1_SSTATE1;


def M2_HILO = Min(h_M2 - l_M2, 1.5 * Average(h_M2 - l_M2, ATRPeriod));

def M2_HREF = if l_M2 <= h_M2[1]

then h_M2 - c_M2[1]

else (h_M2 - c_M2[1]) - 0.5 * (l_M2 - h_M2[1]);

def M2_LREF = if h_M2 >= l_M2[1]

then c_M2[1] - l_M2

else (c_M2[1] - l_M2) - 0.5 * (l_M2[1] - h_M2);

def M2_TRUERANGEV;

switch (trailType) {

case modified:

M2_TRUERANGEV = Max(M2_HILO, Max(M2_HREF, M2_LREF));

case unmodified:

M2_TRUERANGEV = TrueRange(h_M2, c_M2, l_M2);

}

def M2_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M2_TRUERANGEV, ATRPeriod);

def M2_STATE = {default init, long, short};

def M2_TRAIL;

switch (M2_STATE[1]) {

case init:

if (!IsNaN(M2_LOSS)) {

switch (firstTrade) {

case long:

M2_STATE = M2_STATE.long;

M2_TRAIL = c_M2 - M2_LOSS;

case short:

M2_STATE = M2_STATE.short;

M2_TRAIL = c_M2 + M2_LOSS;

}

} else {

M2_STATE = M2_STATE.init;

M2_TRAIL = Double.NaN;

}

case long:

if (c_M2 > M2_TRAIL[1]) {

M2_STATE = M2_STATE.long;

M2_TRAIL = Max(M2_TRAIL[1], c_M2 - M2_LOSS);

} else {

M2_STATE = M2_STATE.short;

M2_TRAIL = c_M2 + M2_LOSS;

}

case short:

if (c_M2 < M2_TRAIL[1]) {

M2_STATE = M2_STATE.short;

M2_TRAIL = Min(M2_TRAIL[1], c_M2 + M2_LOSS);

} else {

M2_STATE = M2_STATE.long;

M2_TRAIL = c_M2 - M2_LOSS;

}

}

def M2_BUYSIGNAL = Crosses(M2_STATE == M2_STATE.long, 0, CrossingDirection.ABOVE);

def M2_SELLSIGNAL = Crosses(M2_STATE == M2_STATE.short, 0, CrossingDirection.ABOVE);

def M2_EX = CompoundValue(1, if M2_BUYSIGNAL then h_M2 else if M2_SELLSIGNAL then l_M2 else if M2_STATE == M2_STATE.long then Max(M2_EX[1], h_M2) else if M2_STATE == M2_STATE.short then Min(M2_EX[1], l_M2) else M2_EX[1], 0);

def M2_FIB = M2_EX + (M2_TRAIL - M2_EX) * fibLevel / 100;

def M2_SDIR = if M2_STATE == M2_STATE.long then 100 else -100;

def M2_INZONE = If(M2_SDIR == 100, l_M2 < M2_FIB, h_M2 > M2_FIB);

def M2_SSTATE1 =

if M2_SDIR == 100 and M2_INZONE then 10 else

if M2_SDIR == 100 then 100 else

if M2_SDIR == -100 and M2_INZONE then -10 else

if M2_SDIR == -100 then -100 else M2_SSTATE1[1];

def M2_SSTATE2 = If(M2_SSTATE1 != M2_SSTATE1[1], M2_SSTATE1, 0);

def M2_SSTATE = M2_SSTATE1;


def M3_HILO = Min(h_M3 - l_M3, 1.5 * Average(h_M3 - l_M3, ATRPeriod));

def M3_HREF = if l_M3 <= h_M3[1]

then h_M3 - c_M3[1]

else (h_M3 - c_M3[1]) - 0.5 * (l_M3 - h_M3[1]);

def M3_LREF = if h_M3 >= l_M3[1]

then c_M3[1] - l_M3

else (c_M3[1] - l_M3) - 0.5 * (l_M3[1] - h_M3);

def M3_TRUERANGEV;

switch (trailType) {

case modified:

M3_TRUERANGEV = Max(M3_HILO, Max(M3_HREF, M3_LREF));

case unmodified:

M3_TRUERANGEV = TrueRange(h_M3, c_M3, l_M3);

}

def M3_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M3_TRUERANGEV, ATRPeriod);

def M3_STATE = {default init, long, short};

def M3_TRAIL;

switch (M3_STATE[1]) {

case init:

if (!IsNaN(M3_LOSS)) {

switch (firstTrade) {

case long:

M3_STATE = M3_STATE.long;

M3_TRAIL = c_M3 - M3_LOSS;

case short:

M3_STATE = M3_STATE.short;

M3_TRAIL = c_M3 + M3_LOSS;

}

} else {

M3_STATE = M3_STATE.init;

M3_TRAIL = Double.NaN;

}

case long:

if (c_M3 > M3_TRAIL[1]) {

M3_STATE = M3_STATE.long;

M3_TRAIL = Max(M3_TRAIL[1], c_M3 - M3_LOSS);

} else {

M3_STATE = M3_STATE.short;

M3_TRAIL = c_M3 + M3_LOSS;

}

case short:

if (c_M3 < M3_TRAIL[1]) {

M3_STATE = M3_STATE.short;

M3_TRAIL = Min(M3_TRAIL[1], c_M3 + M3_LOSS);

} else {

M3_STATE = M3_STATE.long;

M3_TRAIL = c_M3 - M3_LOSS;

}

}

def M3_BUYSIGNAL = Crosses(M3_STATE == M3_STATE.long, 0, CrossingDirection.ABOVE);

def M3_SELLSIGNAL = Crosses(M3_STATE == M3_STATE.short, 0, CrossingDirection.ABOVE);

def M3_EX = CompoundValue(1, if M3_BUYSIGNAL then h_M3 else if M3_SELLSIGNAL then l_M3 else if M3_STATE == M3_STATE.long then Max(M3_EX[1], h_M3) else if M3_STATE == M3_STATE.short then Min(M3_EX[1], l_M3) else M3_EX[1], 0);

def M3_FIB = M3_EX + (M3_TRAIL - M3_EX) * fibLevel / 100;

def M3_SDIR = if M3_STATE == M3_STATE.long then 100 else -100;

def M3_INZONE = If(M3_SDIR == 100, l_M3 < M3_FIB, h_M3 > M3_FIB);

def M3_SSTATE1 =

if M3_SDIR == 100 and M3_INZONE then 10 else

if M3_SDIR == 100 then 100 else

if M3_SDIR == -100 and M3_INZONE then -10 else

if M3_SDIR == -100 then -100 else M3_SSTATE1[1];

def M3_SSTATE2 = If(M3_SSTATE1 != M3_SSTATE1[1], M3_SSTATE1, 0);

def M3_SSTATE = M3_SSTATE1;


def M4_HILO = Min(h_M4 - l_M4, 1.5 * Average(h_M4 - l_M4, ATRPeriod));

def M4_HREF = if l_M4 <= h_M4[1]

then h_M4 - c_M4[1]

else (h_M4 - c_M4[1]) - 0.5 * (l_M4 - h_M4[1]);

def M4_LREF = if h_M4 >= l_M4[1]

then c_M4[1] - l_M4

else (c_M4[1] - l_M4) - 0.5 * (l_M4[1] - h_M4);

def M4_TRUERANGEV;

switch (trailType) {

case modified:

M4_TRUERANGEV = Max(M4_HILO, Max(M4_HREF, M4_LREF));

case unmodified:

M4_TRUERANGEV = TrueRange(h_M4, c_M4, l_M4);

}

def M4_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M4_TRUERANGEV, ATRPeriod);

def M4_STATE = {default init, long, short};

def M4_TRAIL;

switch (M4_STATE[1]) {

case init:

if (!IsNaN(M4_LOSS)) {

switch (firstTrade) {

case long:

M4_STATE = M4_STATE.long;

M4_TRAIL = c_M4 - M4_LOSS;

case short:

M4_STATE = M4_STATE.short;

M4_TRAIL = c_M4 + M4_LOSS;

}

} else {

M4_STATE = M4_STATE.init;

M4_TRAIL = Double.NaN;

}

case long:

if (c_M4 > M4_TRAIL[1]) {

M4_STATE = M4_STATE.long;

M4_TRAIL = Max(M4_TRAIL[1], c_M4 - M4_LOSS);

} else {

M4_STATE = M4_STATE.short;

M4_TRAIL = c_M4 + M4_LOSS;

}

case short:

if (c_M4 < M4_TRAIL[1]) {

M4_STATE = M4_STATE.short;

M4_TRAIL = Min(M4_TRAIL[1], c_M4 + M4_LOSS);

} else {

M4_STATE = M4_STATE.long;

M4_TRAIL = c_M4 - M4_LOSS;

}

}

def M4_BUYSIGNAL = Crosses(M4_STATE == M4_STATE.long, 0, CrossingDirection.ABOVE);

def M4_SELLSIGNAL = Crosses(M4_STATE == M4_STATE.short, 0, CrossingDirection.ABOVE);

def M4_EX = CompoundValue(1, if M4_BUYSIGNAL then h_M4 else if M4_SELLSIGNAL then l_M4 else if M4_STATE == M4_STATE.long then Max(M4_EX[1], h_M4) else if M4_STATE == M4_STATE.short then Min(M4_EX[1], l_M4) else M4_EX[1], 0);

def M4_FIB = M4_EX + (M4_TRAIL - M4_EX) * fibLevel / 100;

def M4_SDIR = if M4_STATE == M4_STATE.long then 100 else -100;

def M4_INZONE = If(M4_SDIR == 100, l_M4 < M4_FIB, h_M4 > M4_FIB);

def M4_SSTATE1 =

if M4_SDIR == 100 and M4_INZONE then 10 else

if M4_SDIR == 100 then 100 else

if M4_SDIR == -100 and M4_INZONE then -10 else

if M4_SDIR == -100 then -100 else M4_SSTATE1[1];

def M4_SSTATE2 = If(M4_SSTATE1 != M4_SSTATE1[1], M4_SSTATE1, 0);

def M4_SSTATE = M4_SSTATE1;


def M5_HILO = Min(h_M5 - l_M5, 1.5 * Average(h_M5 - l_M5, ATRPeriod));

def M5_HREF = if l_M5 <= h_M5[1]

then h_M5 - c_M5[1]

else (h_M5 - c_M5[1]) - 0.5 * (l_M5 - h_M5[1]);

def M5_LREF = if h_M5 >= l_M5[1]

then c_M5[1] - l_M5

else (c_M5[1] - l_M5) - 0.5 * (l_M5[1] - h_M5);

def M5_TRUERANGEV;

switch (trailType) {

case modified:

M5_TRUERANGEV = Max(M5_HILO, Max(M5_HREF, M5_LREF));

case unmodified:

M5_TRUERANGEV = TrueRange(h_M5, c_M5, l_M5);

}

def M5_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M5_TRUERANGEV, ATRPeriod);

def M5_STATE = {default init, long, short};

def M5_TRAIL;

switch (M5_STATE[1]) {

case init:

if (!IsNaN(M5_LOSS)) {

switch (firstTrade) {

case long:

M5_STATE = M5_STATE.long;

M5_TRAIL = c_M5 - M5_LOSS;

case short:

M5_STATE = M5_STATE.short;

M5_TRAIL = c_M5 + M5_LOSS;

}

} else {

M5_STATE = M5_STATE.init;

M5_TRAIL = Double.NaN;

}

case long:

if (c_M5 > M5_TRAIL[1]) {

M5_STATE = M5_STATE.long;

M5_TRAIL = Max(M5_TRAIL[1], c_M5 - M5_LOSS);

} else {

M5_STATE = M5_STATE.short;

M5_TRAIL = c_M5 + M5_LOSS;

}

case short:

if (c_M5 < M5_TRAIL[1]) {

M5_STATE = M5_STATE.short;

M5_TRAIL = Min(M5_TRAIL[1], c_M5 + M5_LOSS);

} else {

M5_STATE = M5_STATE.long;

M5_TRAIL = c_M5 - M5_LOSS;

}

}

def M5_BUYSIGNAL = Crosses(M5_STATE == M5_STATE.long, 0, CrossingDirection.ABOVE);

def M5_SELLSIGNAL = Crosses(M5_STATE == M5_STATE.short, 0, CrossingDirection.ABOVE);

def M5_EX = CompoundValue(1, if M5_BUYSIGNAL then h_M5 else if M5_SELLSIGNAL then l_M5 else if M5_STATE == M5_STATE.long then Max(M5_EX[1], h_M5) else if M5_STATE == M5_STATE.short then Min(M5_EX[1], l_M5) else M5_EX[1], 0);

def M5_FIB = M5_EX + (M5_TRAIL - M5_EX) * fibLevel / 100;

def M5_SDIR = if M5_STATE == M5_STATE.long then 100 else -100;

def M5_INZONE = If(M5_SDIR == 100, l_M5 < M5_FIB, h_M5 > M5_FIB);

def M5_SSTATE1 =

if M5_SDIR == 100 and M5_INZONE then 10 else

if M5_SDIR == 100 then 100 else

if M5_SDIR == -100 and M5_INZONE then -10 else

if M5_SDIR == -100 then -100 else M5_SSTATE1[1];

def M5_SSTATE2 = If(M5_SSTATE1 != M5_SSTATE1[1], M5_SSTATE1, 0);

def M5_SSTATE = M5_SSTATE1;


def M10_HILO = Min(h_M10 - l_M10, 1.5 * Average(h_M10 - l_M10, ATRPeriod));

def M10_HREF = if l_M10 <= h_M10[1]

then h_M10 - c_M10[1]

else (h_M10 - c_M10[1]) - 0.5 * (l_M10 - h_M10[1]);

def M10_LREF = if h_M10 >= l_M10[1]

then c_M10[1] - l_M10

else (c_M10[1] - l_M10) - 0.5 * (l_M10[1] - h_M10);

def M10_TRUERANGEV;

switch (trailType) {

case modified:

M10_TRUERANGEV = Max(M10_HILO, Max(M10_HREF, M10_LREF));

case unmodified:

M10_TRUERANGEV = TrueRange(h_M10, c_M10, l_M10);

}

def M10_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M10_TRUERANGEV, ATRPeriod);

def M10_STATE = {default init, long, short};

def M10_TRAIL;

switch (M10_STATE[1]) {

case init:

if (!IsNaN(M10_LOSS)) {

switch (firstTrade) {

case long:

M10_STATE = M10_STATE.long;

M10_TRAIL = c_M10 - M10_LOSS;

case short:

M10_STATE = M10_STATE.short;

M10_TRAIL = c_M10 + M10_LOSS;

}

} else {

M10_STATE = M10_STATE.init;

M10_TRAIL = Double.NaN;

}

case long:

if (c_M10 > M10_TRAIL[1]) {

M10_STATE = M10_STATE.long;

M10_TRAIL = Max(M10_TRAIL[1], c_M10 - M10_LOSS);

} else {

M10_STATE = M10_STATE.short;

M10_TRAIL = c_M10 + M10_LOSS;

}

case short:

if (c_M10 < M10_TRAIL[1]) {

M10_STATE = M10_STATE.short;

M10_TRAIL = Min(M10_TRAIL[1], c_M10 + M10_LOSS);

} else {

M10_STATE = M10_STATE.long;

M10_TRAIL = c_M10 - M10_LOSS;

}

}

def M10_BUYSIGNAL = Crosses(M10_STATE == M10_STATE.long, 0, CrossingDirection.ABOVE);

def M10_SELLSIGNAL = Crosses(M10_STATE == M10_STATE.short, 0, CrossingDirection.ABOVE);

def M10_EX = CompoundValue(1, if M10_BUYSIGNAL then h_M10 else if M10_SELLSIGNAL then l_M10 else if M10_STATE == M10_STATE.long then Max(M10_EX[1], h_M10) else if M10_STATE == M10_STATE.short then Min(M10_EX[1], l_M10) else M10_EX[1], 0);

def M10_FIB = M10_EX + (M10_TRAIL - M10_EX) * fibLevel / 100;

def M10_SDIR = if M10_STATE == M10_STATE.long then 100 else -100;

def M10_INZONE = If(M10_SDIR == 100, l_M10 < M10_FIB, h_M10 > M10_FIB);

def M10_SSTATE1 =

if M10_SDIR == 100 and M10_INZONE then 10 else

if M10_SDIR == 100 then 100 else

if M10_SDIR == -100 and M10_INZONE then -10 else

if M10_SDIR == -100 then -100 else M10_SSTATE1[1];

def M10_SSTATE2 = If(M10_SSTATE1 != M10_SSTATE1[1], M10_SSTATE1, 0);

def M10_SSTATE = M10_SSTATE1;


def M15_HILO = Min(h_M15 - l_M15, 1.5 * Average(h_M15 - l_M15, ATRPeriod));

def M15_HREF = if l_M15 <= h_M15[1]

then h_M15 - c_M15[1]

else (h_M15 - c_M15[1]) - 0.5 * (l_M15 - h_M15[1]);

def M15_LREF = if h_M15 >= l_M15[1]

then c_M15[1] - l_M15

else (c_M15[1] - l_M15) - 0.5 * (l_M15[1] - h_M15);

def M15_TRUERANGEV;

switch (trailType) {

case modified:

M15_TRUERANGEV = Max(M15_HILO, Max(M15_HREF, M15_LREF));

case unmodified:

M15_TRUERANGEV = TrueRange(h_M15, c_M15, l_M15);

}

def M15_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M15_TRUERANGEV, ATRPeriod);

def M15_STATE = {default init, long, short};

def M15_TRAIL;

switch (M15_STATE[1]) {

case init:

if (!IsNaN(M15_LOSS)) {

switch (firstTrade) {

case long:

M15_STATE = M15_STATE.long;

M15_TRAIL = c_M15 - M15_LOSS;

case short:

M15_STATE = M15_STATE.short;

M15_TRAIL = c_M15 + M15_LOSS;

}

} else {

M15_STATE = M15_STATE.init;

M15_TRAIL = Double.NaN;

}

case long:

if (c_M15 > M15_TRAIL[1]) {

M15_STATE = M15_STATE.long;

M15_TRAIL = Max(M15_TRAIL[1], c_M15 - M15_LOSS);

} else {

M15_STATE = M15_STATE.short;

M15_TRAIL = c_M15 + M15_LOSS;

}

case short:

if (c_M15 < M15_TRAIL[1]) {

M15_STATE = M15_STATE.short;

M15_TRAIL = Min(M15_TRAIL[1], c_M15 + M15_LOSS);

} else {

M15_STATE = M15_STATE.long;

M15_TRAIL = c_M15 - M15_LOSS;

}

}

def M15_BUYSIGNAL = Crosses(M15_STATE == M15_STATE.long, 0, CrossingDirection.ABOVE);

def M15_SELLSIGNAL = Crosses(M15_STATE == M15_STATE.short, 0, CrossingDirection.ABOVE);

def M15_EX = CompoundValue(1, if M15_BUYSIGNAL then h_M15 else if M15_SELLSIGNAL then l_M15 else if M15_STATE == M15_STATE.long then Max(M15_EX[1], h_M15) else if M15_STATE == M15_STATE.short then Min(M15_EX[1], l_M15) else M15_EX[1], 0);

def M15_FIB = M15_EX + (M15_TRAIL - M15_EX) * fibLevel / 100;

def M15_SDIR = if M15_STATE == M15_STATE.long then 100 else -100;

def M15_INZONE = If(M15_SDIR == 100, l_M15 < M15_FIB, h_M15 > M15_FIB);

def M15_SSTATE1 =

if M15_SDIR == 100 and M15_INZONE then 10 else

if M15_SDIR == 100 then 100 else

if M15_SDIR == -100 and M15_INZONE then -10 else

if M15_SDIR == -100 then -100 else M15_SSTATE1[1];

def M15_SSTATE2 = If(M15_SSTATE1 != M15_SSTATE1[1], M15_SSTATE1, 0);

def M15_SSTATE = M15_SSTATE1;


def M30_HILO = Min(h_M30 - l_M30, 1.5 * Average(h_M30 - l_M30, ATRPeriod));

def M30_HREF = if l_M30 <= h_M30[1]

then h_M30 - c_M30[1]

else (h_M30 - c_M30[1]) - 0.5 * (l_M30 - h_M30[1]);

def M30_LREF = if h_M30 >= l_M30[1]

then c_M30[1] - l_M30

else (c_M30[1] - l_M30) - 0.5 * (l_M30[1] - h_M30);

def M30_TRUERANGEV;

switch (trailType) {

case modified:

M30_TRUERANGEV = Max(M30_HILO, Max(M30_HREF, M30_LREF));

case unmodified:

M30_TRUERANGEV = TrueRange(h_M30, c_M30, l_M30);

}

def M30_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, M30_TRUERANGEV, ATRPeriod);

def M30_STATE = {default init, long, short};

def M30_TRAIL;

switch (M30_STATE[1]) {

case init:

if (!IsNaN(M30_LOSS)) {

switch (firstTrade) {

case long:

M30_STATE = M30_STATE.long;

M30_TRAIL = c_M30 - M30_LOSS;

case short:

M30_STATE = M30_STATE.short;

M30_TRAIL = c_M30 + M30_LOSS;

}

} else {

M30_STATE = M30_STATE.init;

M30_TRAIL = Double.NaN;

}

case long:

if (c_M30 > M30_TRAIL[1]) {

M30_STATE = M30_STATE.long;

M30_TRAIL = Max(M30_TRAIL[1], c_M30 - M30_LOSS);

} else {

M30_STATE = M30_STATE.short;

M30_TRAIL = c_M30 + M30_LOSS;

}

case short:

if (c_M30 < M30_TRAIL[1]) {

M30_STATE = M30_STATE.short;

M30_TRAIL = Min(M30_TRAIL[1], c_M30 + M30_LOSS);

} else {

M30_STATE = M30_STATE.long;

M30_TRAIL = c_M30 - M30_LOSS;

}

}

def M30_BUYSIGNAL = Crosses(M30_STATE == M30_STATE.long, 0, CrossingDirection.ABOVE);

def M30_SELLSIGNAL = Crosses(M30_STATE == M30_STATE.short, 0, CrossingDirection.ABOVE);

def M30_EX = CompoundValue(1, if M30_BUYSIGNAL then h_M30 else if M30_SELLSIGNAL then l_M30 else if M30_STATE == M30_STATE.long then Max(M30_EX[1], h_M30) else if M30_STATE == M30_STATE.short then Min(M30_EX[1], l_M30) else M30_EX[1], 0);

def M30_FIB = M30_EX + (M30_TRAIL - M30_EX) * fibLevel / 100;

def M30_SDIR = if M30_STATE == M30_STATE.long then 100 else -100;

def M30_INZONE = If(M30_SDIR == 100, l_M30 < M30_FIB, h_M30 > M30_FIB);

def M30_SSTATE1 =

if M30_SDIR == 100 and M30_INZONE then 10 else

if M30_SDIR == 100 then 100 else

if M30_SDIR == -100 and M30_INZONE then -10 else

if M30_SDIR == -100 then -100 else M30_SSTATE1[1];

def M30_SSTATE2 = If(M30_SSTATE1 != M30_SSTATE1[1], M30_SSTATE1, 0);

def M30_SSTATE = M30_SSTATE1;


def H1_HILO = Min(h_H1 - l_H1, 1.5 * Average(h_H1 - l_H1, ATRPeriod));

def H1_HREF = if l_H1 <= h_H1[1]

then h_H1 - c_H1[1]

else (h_H1 - c_H1[1]) - 0.5 * (l_H1 - h_H1[1]);

def H1_LREF = if h_H1 >= l_H1[1]

then c_H1[1] - l_H1

else (c_H1[1] - l_H1) - 0.5 * (l_H1[1] - h_H1);

def H1_TRUERANGEV;

switch (trailType) {

case modified:

H1_TRUERANGEV = Max(H1_HILO, Max(H1_HREF, H1_LREF));

case unmodified:

H1_TRUERANGEV = TrueRange(h_H1, c_H1, l_H1);

}

def H1_LOSS = ATRFactor * MovingAverage(AverageType.WILDERS, H1_TRUERANGEV, ATRPeriod);

def H1_STATE = {default init, long, short};

def H1_TRAIL;

switch (H1_STATE[1]) {

case init:

if (!IsNaN(H1_LOSS)) {

switch (firstTrade) {

case long:

H1_STATE = H1_STATE.long;

H1_TRAIL = c_H1 - H1_LOSS;

case short:

H1_STATE = H1_STATE.short;

H1_TRAIL = c_H1 + H1_LOSS;

}

} else {

H1_STATE = H1_STATE.init;

H1_TRAIL = Double.NaN;

}

case long:

if (c_H1 > H1_TRAIL[1]) {

H1_STATE = H1_STATE.long;

H1_TRAIL = Max(H1_TRAIL[1], c_H1 - H1_LOSS);

} else {

H1_STATE = H1_STATE.short;

H1_TRAIL = c_H1 + H1_LOSS;

}

case short:

if (c_H1 < H1_TRAIL[1]) {

H1_STATE = H1_STATE.short;

H1_TRAIL = Min(H1_TRAIL[1], c_H1 + H1_LOSS);

} else {

H1_STATE = H1_STATE.long;

H1_TRAIL = c_H1 - H1_LOSS;

}

}

def H1_BUYSIGNAL = Crosses(H1_STATE == H1_STATE.long, 0, CrossingDirection.ABOVE);

def H1_SELLSIGNAL = Crosses(H1_STATE == H1_STATE.short, 0, CrossingDirection.ABOVE);

def H1_EX = CompoundValue(1, if H1_BUYSIGNAL then h_H1 else if H1_SELLSIGNAL then l_H1 else if H1_STATE == H1_STATE.long then Max(H1_EX[1], h_H1) else if H1_STATE == H1_STATE.short then Min(H1_EX[1], l_H1) else H1_EX[1], 0);

def H1_FIB = H1_EX + (H1_TRAIL - H1_EX) * fibLevel / 100;

def H1_SDIR = if H1_STATE == H1_STATE.long then 100 else -100;

def H1_INZONE = If(H1_SDIR == 100, l_H1 < H1_FIB, h_H1 > H1_FIB);

def H1_SSTATE1 =

if H1_SDIR == 100 and H1_INZONE then 10 else

if H1_SDIR == 100 then 100 else

if H1_SDIR == -100 and H1_INZONE then -10 else

if H1_SDIR == -100 then -100 else H1_SSTATE1[1];

def H1_SSTATE2 = If(H1_SSTATE1 != H1_SSTATE1[1], H1_SSTATE1, 0);

def H1_SSTATE = H1_SSTATE1;

#### modon030s additions

Def z = close;

def fx1 = if(M1_FIB > z, 1, -1);

def fx2 = if(M2_FIB > z, 1, -1);

def fx3 = if(M3_FIB > z, 1, -1);

def fx4 = if(M4_FIB > z, 1, -1);

def fx5 = if(M5_FIB > z, 1, -1);

def fx6 = if(M10_FIB > z, 1, -1);

def fx7 = if(M15_FIB > z, 1, -1);

def fx8 = if(M30_FIB > z, 1, -1);

def fx9 = if(H1_FIB > z, 1, -1);

##def fx9 = if(H1_FIB > z, 1, -1);

def sum = (fx1+fx2+fx3+fx4+fx5+fx6+fx7+fx8+fx9);

def sumabs = absvalue(sum);

def e1 = if(M1_FIB , M1_FIB, double.nan);

def e2 = if(M2_FIB, M2_FIB, double.nan);

def e3 = if(M3_FIB, M3_FIB, double.nan);

def e4 = if(M4_FIB , M4_FIB, double.nan);

def e5 = if(M5_FIB, M5_FIB, double.nan);

def e6 = if(M10_FIB, M10_FIB, double.nan);

def e7 = if(M15_FIB,M15_FIB, double.nan);

def e8 = if(M30_FIB, M30_FIB, double.nan);

def e9 = if(H1_FIB, H1_FIB, double.nan);

##def e9 = if(H1_FIB, H1_FIB, double.nan);

def hf3rnk =Max(e1,max(e2,max(e3,max(e4,max(e5,max(e6,max(e7,max(e8,e9))))))));

def hf3;

if sumabs && sum!=-9 then { hf3=hf3rnk ;

} else {hf3=double.nan ;}

def hf2rnk;

if hf3rnk==e1 { hf2rnk= max(e2,max(e3,max(e4,max(e5,max(e6,max(e7,max(e8,e9)))))));

} else if hf3rnk==e2 then { hf2rnk=max(e1,max(e3,max(e4,max(e5,max(e6,max(e7,max(e8,e9)))))));

}else if hf3rnk==e3 then { hf2rnk= max(e1,max(e2,max(e4,max(e5,max(e6,max(e7,max(e8,e9)))))));

}else if hf3rnk==e4 then { hf2rnk=max(e1,max(e2,max(e3,max(e5,max(e6,max(e7,max(e8,e9)))))));

}else if hf3rnk==e5 then { hf2rnk=max(e1,max(e2,max(e3,max(e4,max(e6,max(e7,max(e8,e9)))))));

}else if hf3rnk==e6 then { hf2rnk=max(e1,max(e2,max(e3,max(e4,max(e5,max(e7,max(e8,e9)))))));

}else if hf3rnk==e7 then { hf2rnk=max(e1,max(e2,max(e3,max(e4,max(e5,max(e6,max(e8,e9)))))));

}else if hf3rnk==e8 then { hf2rnk=max(e1,max(e2,max(e3,max(e4,max(e5,max(e6,max(e7,e9)))))));

}else { hf2rnk=max(e1,max(e2,max(e3,max(e4,max(e5,max(e6,max(e7,e8)))))));}

def hf2;

if sumabs && sumabs>=5 then { hf2=hf2rnk ;

} else {hf2=double.nan ;}

def hf1rnk;

if hf3rnk==e1 && hf2rnk==e2 then { hf1rnk=max(e3,max(e4,max(e5,max(e6,max(e7,max(e8,e9))))));

}else if hf3rnk==e1 && hf2rnk==e3 then { hf1rnk=max(e2,max(e4,max(e5,max(e6,max(e7,max(e8,e9))))));

}else if hf3rnk==e1 && hf2rnk==e4 then { hf1rnk=max(e2,max(e3,max(e5,max(e6,max(e7,max(e8,e9))))));

}else if hf3rnk==e1 && hf2rnk==e5 then { hf1rnk=max(e2,max(e3,max(e4,max(e6,max(e7,max(e8,e9))))));

}else if hf3rnk==e1 && hf2rnk==e6 then { hf1rnk=max(e2,max(e3,max(e4,max(e5,max(e7,max(e8,e9))))));

}else if hf3rnk==e1 && hf2rnk==e7 then { hf1rnk=max(e2,max(e3,max(e4,max(e5,max(e6,max(e8,e9))))));

}else if hf3rnk==e1 && hf2rnk==e8 then { hf1rnk=max(e2,max(e3,max(e4,max(e5,max(e6,max(e7,e9))))));

}else { hf1rnk=max(e2,max(e3,max(e4,max(e5,max(e6,max(e7,e8))))));}


def hf1;

if sumabs && sumabs<=3 then { hf1=hf1rnk ;

} else {hf1=double.nan ;}

def lf3rnk =min(e1,min(e2,min(e3,min(e4,min(e5,min(e6,min(e7,min(e8,e9))))))));

def lf3;

if sumabs && sum!=9 then { lf3=lf3rnk ;

} else {lf3=double.nan ;}

def lf2rnk;

if lf3rnk==e1 then { lf2rnk=min(e2,min(e3,min(e4,min(e5,min(e6,min(e7,min(e8,e9)))))));

}else if lf3rnk==e2 then { lf2rnk=min(e1,min(e3,min(e4,min(e5,min(e6,min(e7,min(e8,e9)))))));

}else if lf3rnk==e3 then { lf2rnk=min(e1,min(e2,min(e4,min(e5,min(e6,min(e7,min(e8,e9)))))));

}else if lf3rnk==e4 then { lf2rnk=min(e1,min(e2,min(e3,min(e5,min(e6,min(e7,min(e8,e9)))))));

}else if lf3rnk==e5 then { lf2rnk=min(e1,min(e2,min(e3,min(e4,min(e6,min(e7,min(e8,e9)))))));

}else if lf3rnk==e6 then { lf2rnk=min(e1,min(e2,min(e3,min(e4,min(e5,min(e7,min(e8,e9)))))));

}else if lf3rnk==e7 then { lf2rnk=min(e1,min(e2,min(e3,min(e4,min(e5,min(e6,min(e8,e9)))))));

}else if lf3rnk==e8 then { lf2rnk=min(e1,min(e2,min(e3,min(e4,min(e5,min(e6,min(e7,e9)))))));

}else { lf2rnk=min(e1,min(e2,min(e3,min(e4,min(e5,min(e6,min(e7,e8)))))));}

def lf2;

if sumabs && sumabs>=5 then { lf2=lf2rnk ;

} else {lf2=double.nan ; }

def lf1rnk;

if lf3rnk==e1 && lf2rnk==e2 then { lf1rnk=min(e3,min(e4,min(e5,min(e6,min(e7,min(e8,e9))))));

}else if lf3==e1 && lf2==e3 then { lf1rnk=min(e2,min(e4,min(e5,min(e6,min(e7,min(e8,e9))))));

}else if lf3==e1 && lf2==e4 then { lf1rnk=min(e2,min(e3,min(e5,min(e6,min(e7,min(e8,e9))))));

}else if lf3==e1 && lf2==e5 then { lf1rnk=min(e2,min(e3,min(e4,min(e6,min(e7,min(e8,e9))))));

}else if lf3==e1 && lf2==e6 then { lf1rnk=min(e2,min(e3,min(e4,min(e5,min(e7,min(e8,e9))))));

}else if lf3==e1 && lf2==e7 then { lf1rnk=min(e2,min(e3,min(e4,min(e5,min(e6,min(e8,e9))))));

}else if lf3==e1 && lf2==e8 then { lf1rnk=min(e2,min(e3,min(e4,min(e5,min(e6,min(e7,e9))))));

}else { lf1rnk=min(e2,min(e3,min(e4,min(e5,min(e6,min(e7,e8))))));}

def lf1;

if sumabs && sumabs<=3 then { lf1=lf1rnk ;

} else {lf1=double.nan ; }

def set1 =compoundvalue(1,if !isnan(hf3) then if hf3>close then 10 else if hf3<close then -10 else 0 else 0,0);

def set2 =compoundvalue(1,if !isnan(hf2) then if hf2>close then 10 else if hf2<close then -10 else 0 else 0,0);

def set3 =compoundvalue(1,if !isnan(hf1) then if hf1>close then 10 else if hf1<close then -10 else 0 else 0,0);

def set4 =compoundvalue(1,if !isnan(lf3) then if lf3>close then 10 else if lf3<close then -10 else 0 else 0,0);

def set5 =compoundvalue(1,if !isnan(lf2) then if lf2>close then 10 else if lf2<close then -10 else 0 else 0,0);

def set6 =compoundvalue(1,if !isnan(lf1) then if lf1>close then 10 else if lf1<close then -10 else 0 else 0,0);

def sumset = set1+set2+set3+set4+set5+set6;

def sumsettabs = absvalue(sumset);

def sumabs123456 = absvalue(set1)+absvalue(set2)+absvalue(set3)+absvalue(set4)+absvalue(set5)+absvalue(set6);

def absdif =(sumabs123456-sumsettabs);


def position;

#if (sumset==0){position=0;}

if (sumset==0){position=0;}

else if (sumset>0 && absdif ==20){position=2;}

else if (sumset<0 && absdif ==20){position=-2;}

else if (sumset>0 && absdif ==0){position=1;}

else if (sumset<0 && absdif ==0){position=-1;}

else {position=position[1];}


input showColorBars = yes;

AssignPriceColor (

if showColorBars then

if position == -1 then color.green

else if position== 1 then color.red

else if position== -2 then color.dark_green

else if position== 2 then color.dark_red

else color.dark_gray

else COLOR.gray);



plot pZeroline = close;

pZeroline.SetDefaultColor(Color.WHITE);

pZeroline.SetLineWeight(2);

pZeroline.HideTitle();

pZeroline.HideBubble();

pZeroline.SetHiding(1);

plot hf3pu = hf3;

hf3pu.AssignValueColor(if hf3>close then color.red else color.green);

hf3pu.setLineWeight(2);

hf3pu.setPaintingStrategy(paintingStrategy.DASHES);

plot hf2pu = hf2;

hf2pu.AssignValueColor(if hf2>close then color.red else color.green);

hf2pu.setLineWeight(2);

hf2pu.setPaintingStrategy(paintingStrategy.DASHES);

plot hf1pu = hf1;

hf1pu.AssignValueColor(if hf1>close then color.red else color.green);

hf1pu.setLineWeight(2);

hf1pu.setPaintingStrategy(paintingStrategy.DASHES);

plot lf3pd = lf3;

lf3pd.AssignValueColor(if lf3>close then color.red else color.green);

lf3pd.setLineWeight(2);

lf3pd.setPaintingStrategy(paintingStrategy.DASHES);

plot lf2pd = lf2;

lf2pd.AssignValueColor(if lf2>close then color.red else color.green);

lf2pd.setLineWeight(2);

lf2pd.setPaintingStrategy(paintingStrategy.DASHES);

plot lf1pd = lf1;

lf1pd.AssignValueColor(if lf1>close then color.red else color.green);

lf1pd.setLineWeight(2);

lf1pd.setPaintingStrategy(paintingStrategy.DASHES);

# Labels

AddLabel(1, "TRADE",

if position == -1 then color.green else if position== 1 then color.red else color.dark_gray);

#AddLabel (showLabels, "SwingArm Trading Panel ->", Color.ORANGE);

AddLabel (showLabels, "S ", if SYNC then GlobalColor("Sync1") else GlobalColor("Sync2"));

AddLabel(showLabels, "M1", if IsNaN(M1_SSTATE[displace]) then GlobalColor("Off") else

if M1_SSTATE[displace] == 100 then GlobalColor("Up") else

if M1_SSTATE[displace] == -100 then GlobalColor("Down") else

if M1_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M1_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M1_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M1_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M1


AddLabel(showLabels, "M2", if IsNaN(M2_SSTATE[displace]) then GlobalColor("Off") else

if M2_SSTATE[displace] == 100 then GlobalColor("Up") else

if M2_SSTATE[displace] == -100 then GlobalColor("Down") else

if M2_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M2_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M2_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M2_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M2


AddLabel(showLabels, "M3", if IsNaN(M3_SSTATE[displace]) then GlobalColor("Off") else

if M3_SSTATE[displace] == 100 then GlobalColor("Up") else

if M3_SSTATE[displace] == -100 then GlobalColor("Down") else

if M3_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M3_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M3_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M3_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M3


AddLabel(showLabels, "M4", if IsNaN(M4_SSTATE[displace]) then GlobalColor("Off") else

if M4_SSTATE[displace] == 100 then GlobalColor("Up") else

if M4_SSTATE[displace] == -100 then GlobalColor("Down") else

if M4_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M4_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M4_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M4_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M4


AddLabel(showLabels, "M5", if IsNaN(M5_SSTATE[displace]) then GlobalColor("Off") else

if M5_SSTATE[displace] == 100 then GlobalColor("Up") else

if M5_SSTATE[displace] == -100 then GlobalColor("Down") else

if M5_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M5_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M5_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M5_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M5


AddLabel(showLabels, "M10", if IsNaN(M10_SSTATE[displace]) then GlobalColor("Off") else

if M10_SSTATE[displace] == 100 then GlobalColor("Up") else

if M10_SSTATE[displace] == -100 then GlobalColor("Down") else

if M10_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M10_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M10_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M10_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M10


AddLabel(showLabels, "M15", if IsNaN(M15_SSTATE[displace]) then GlobalColor("Off") else

if M15_SSTATE[displace] == 100 then GlobalColor("Up") else

if M15_SSTATE[displace] == -100 then GlobalColor("Down") else

if M15_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M15_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M15_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M15_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M15


AddLabel(showLabels, "M30", if IsNaN(M30_SSTATE[displace]) then GlobalColor("Off") else

if M30_SSTATE[displace] == 100 then GlobalColor("Up") else

if M30_SSTATE[displace] == -100 then GlobalColor("Down") else

if M30_SSTATE[displace] == 10 then GlobalColor("NUp") else

if M30_SSTATE[displace] == -10 then GlobalColor("NDown") else

if M30_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if M30_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #M30


AddLabel(showLabels, "H1", if IsNaN(H1_SSTATE[displace]) then GlobalColor("Off") else

if H1_SSTATE[displace] == 100 then GlobalColor("Up") else

if H1_SSTATE[displace] == -100 then GlobalColor("Down") else

if H1_SSTATE[displace] == 10 then GlobalColor("NUp") else

if H1_SSTATE[displace] == -10 then GlobalColor("NDown") else

if H1_SSTATE[displace] == -1 then GlobalColor("Neutral") else

if H1_SSTATE[displace] == 1 then GlobalColor("Neutral") else

GlobalColor("Off2")); #H1


AddLabel (showLabels, "S ", if SYNC then GlobalColor("Sync1") else GlobalColor("Sync2"));

44 Views
Brain with financial data analysis.

Inquiries at :

tel#: (843) 321-8514

Important Risk Notice: Trading involves substantial risk of loss. This is educational content only—not advice. Full details here  ------------>  

Proceed only if you're prepared.

bottom of page