EMA &BLSH Strategy

				
					////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////
study(title="EMA & MA Crossover", shorttitle="EMA & MA Crossover", overlay = true)
LengthMA = input(5, minval=1)
LengthEMA = input(7,minval=1)
xMA = sma(close, LengthMA)
xEMA = ema(xMA, LengthEMA)
pos = iff(xEMA < xMA , 1,
	    iff(xEMA > xMA, -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? red: pos == 1 ? green : blue)
plot(xMA, color=red, title="MA")
plot(xEMA, color=blue, title="EMA")

				
			
				
					//@version=3
study(title="Buy Low Sell High Composite", shorttitle="BLSH")

// normalize values into the range -1 to +1
normalize(value, minValue, maxValue) =>
    range = maxValue - minValue == 0 ? 0.0001 : maxValue - minValue
    -1 + (((value - minValue) / range) * 2)

atrValue = atr(9)
priceRange = 2 * atrValue

// RSI
rsiValue = rsi(close, 14)
rsiValueNormalized = normalize(rsiValue, 25, 75)
rsiColor = rsiValueNormalized <= 0 ? orange : yellow

// Elliot Wave
emaDiff = ema(close, 5) - ema(close, 35)
emaDiffNormalized = normalize(emaDiff, -priceRange, priceRange)
emaColor = emaDiff <= 0 ? red : lime

// MACD
fastMovingAverage = ema(close, 12)
slowMovingAverage = ema(close, 26)
macd = fastMovingAverage - slowMovingAverage
macdSignal = sma(macd, 9)
macdHistogram = macd - macdSignal
macdNormalized = normalize(macd, -priceRange, priceRange)
macdSignalNormalized = normalize(macdSignal, -priceRange, priceRange)
macdHistogramNormalized = normalize(macdHistogram, -priceRange, priceRange)

isMACDAbove = macd >= macdSignal
crossoverColor = isMACDAbove ? lime : red
crossoverValue = cross(macd, macdSignal) ? macdSignalNormalized : na

// MFI
positiveFlow = sum(volume * (change(hlc3) <= 0 ? 0 : hlc3), 14)
negativeFlow = sum(volume * (change(hlc3) >= 0 ? 0 : hlc3), 14)
mfiValue = rsi(positiveFlow, negativeFlow)
mfiValueNormalized = normalize(mfiValue, 25, 75)

// Composite
compositeValue = emaDiffNormalized + rsiValueNormalized + macdHistogramNormalized + mfiValueNormalized
compositeNormalized = normalize(compositeValue, -4, 4)
compositeColor = compositeValue <= 0 ? red : lime
compositeStyle = histogram

// Plots
plot(compositeNormalized, title="Composite", color=compositeColor, style=area, linewidth=2, transp=60)
plot(macdSignalNormalized, title="MacD Signal", style=line, linewidth=1, color=crossoverColor)
plot(crossoverValue, title="Crossover", style=circles, linewidth=3, color=crossoverColor)
				
			

How to Apply an Indicator Code in Pine Script on TradingView

Follow this step-by-step guide to apply an indicator code in Pine Script on TradingView:

Step 1: Log in to TradingView

  • Visit TradingView and log in to your account.

  • If you don’t have an account, create one by clicking on Sign Up.


Step 2: Open the Chart

  • Click on the “Chart” option in the top navigation bar.

  • A default chart will load, which you can use to apply your indicator.


Step 3: Open Pine Script Editor

  • At the bottom of the chart, you’ll see a tab labeled “Pine Script Editor”. Click on it.

    • If it’s not visible, right-click on the blank area below the chart and enable “Pine Script Editor”.


Step 4: Paste Your Indicator Code

  • Copy the indicator code you want to use.

  • Paste the code into the Pine Script Editor.


Step 5: Save the Script

  • Click the “Save” button at the top of the editor.

  • Enter a name for your script (e.g., “My Custom Indicator”) and save it.


Step 6: Add the Indicator to the Chart

  • After saving, click the “Add to Chart” button.

  • The indicator will now appear on your chart.