This page shows you
TradingView App settings that have been used successfully.
This page shows you
TradingView App settings that have been used successfully.
DISCLOSURE
General Disclaimer and Release. Nothing contained herein constitutes tax, legal, insurance or investment advice, or the recommendation of or an offer to sell, or the solicitation of an offer to buy or invest in any investment product, vehicle, service or instrument. This information may include statements concerning financial market trends and/or individual stocks, and are based on current market conditions, which will fluctuate and may be superseded by subsequent market events or for other reasons. Historic market trends are not reliable indicators of actual future market behavior or future performance of any particular investment which may differ materially, and should not be relied upon as such. The investment strategy and broad themes discussed herein may be inappropriate for investors depending on their specific investment objectives and financial situation. Information contained in the material has been obtained from sources believed to be reliable, but not guaranteed. You should note that the materials are provided "as is" without any express or implied warranties. Past performance is not a guarantee of future results. All investments involve a degree of risk, including the risk of loss. No part of these materials may be reproduced in any form, or referred to in any other publication, without express written permission. Information provided for informational purposes only and in no way should be considered a recommendation of any particular investment product, vehicle, service or instrument or the rendering of investment advice, which must always be evaluated by a prospective investor in consultation with his or her own financial adviser and in light of his or her own circumstances, including the investor's investment horizon, appetite for risk, and ability to withstand a potential loss of some or all of an investment's value. Graphs, charts, and tables are provided for illustrative purposes only. Investing is subject to market risks. Investors acknowledge and accept the potential loss of some or all of an investment's value.
TBD

Create a new indicator. Copy paste this code. DONE!
//@version=6
indicator("WildMA(2) vs EMA(2) State + Trade Labels", overlay=true, max_labels_count=500)
// ─────────────────────────────────────────────
// Settings
// ─────────────────────────────────────────────
src = input.source(close, "Source")
wildLen = input.int(2, "WildMA Length", minval=1)
emaLen = input.int(2, "EMA Length", minval=1)
minDiff = input.float(0.1, "Min MA Difference for Red/Green Dots", step=0.01, minval=0.0)
confirmed = barstate.isconfirmed
// ─────────────────────────────────────────────
// MAs
// ─────────────────────────────────────────────
wild = ta.rma(src, wildLen)
ema = ta.ema(src, emaLen)
// Slope colors (for line color + new trade conditions)
wildUp = wild > wild[1]
wildDn = wild < wild[1]
emaUp = ema > ema[1]
emaDn = ema < ema[1]
maColor = wildUp ? color.green : wildDn ? color.red : color.yellow
// ─────────────────────────────────────────────
// Plots
// ─────────────────────────────────────────────
plot(wild, "WildMA", color=maColor, linewidth=2)
plot(ema, "EMA", color=maColor, linewidth=2)
// ─────────────────────────────────────────────
// Cross + State Dots (bottom row) with minDiff rule
// ─────────────────────────────────────────────
crossUp = ta.crossover(ema, wild)
crossDn = ta.crossunder(ema, wild)
isCross = crossUp or crossDn
emaAbove = ema > wild
diffOK = math.abs(ema - wild) >= minDiff
plotshape(not isCross and diffOK and emaAbove, title="State Dot Up", style=shape.circle, location=location.bottom, color=color.green, size=size.tiny)
plotshape(not isCross and diffOK and not emaAbove, title="State Dot Down", style=shape.circle, location=location.bottom, color=color.red, size=size.tiny)
// If diff is too small, show white X instead of red/green
plotshape(not isCross and not diffOK, title="Neutral X (Diff < min)", style=shape.xcross, location=location.bottom, color=color.white, size=size.tiny)
// ─────────────────────────────────────────────
// Trade State Machine (no overlap; exits first; no same-bar flip)
// ─────────────────────────────────────────────
// state: 0 = flat, 1 = long, -1 = short
var int state = 0
var int lastExitBar = na
// New “both green/red” conditions
bothGreen = wildUp and emaUp
bothRed = wildDn and emaDn
// Exits (priority):
// - original cross exits
// - PLUS slope exits: long exits if either turns red, short exits if either turns green
exitLong = confirmed and state == 1 and (crossDn or wildDn or emaDn)
exitShort = confirmed and state == -1 and (crossUp or wildUp or emaUp)
if exitLong
state := 0
lastExitBar := bar_index
if exitShort
state := 0
lastExitBar := bar_index
// Block same-bar flip after an exit
canEnter = confirmed and state == 0 and (na(lastExitBar) or bar_index > lastExitBar)
// Entries when flat:
// - original cross entries
// - PLUS slope entries: long if both green, short if both red
enterLong = canEnter and (crossUp or bothGreen)
enterShort = canEnter and (crossDn or bothRed)
if enterLong
state := 1
if enterShort
state := -1
// ─────────────────────────────────────────────
// Trade labels
// ─────────────────────────────────────────────
plotshape(enterLong, title="BUY LONG", text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.small)
plotshape(exitLong, title="EXIT LONG", text="EXIT", style=shape.labeldown, location=location.belowbar, color=color.yellow, textcolor=color.black, size=size.small)
plotshape(enterShort, title="SELL SHORT", text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)
plotshape(exitShort, title="EXIT SHORT", text="EXIT", style=shape.labelup, location=location.abovebar, color=color.yellow, textcolor=color.black, size=size.small)

YOU HAVE THE POWER TO CHANGE THE LIVES OF YOUR FAMILY, YOUR FRIENDS.
STRANGERS, AND MOST IMPORTANTLY, THOSE WHO ARE DESPERATELY IN NEED!
LIVE YOUR BEST LIFE !