Hey hope you are doing great!
To summarize my script it basically looks for engulfing candles and once it finds that it checks if the 13ema crosses thru the bodies of both candles. If that is true then a signal shape immediately appears on the open of the next candle.
So what I'm trying to implement is something that makes the signal shape only appear if the 50ema is at least 10 pips away from the close of the candle right before the signal appear. I will do my best to give some examples!
https://www.tradingview.com/x/o9HnCVQ6/ (Sell Example)
https://www.tradingview.com/x/fCKcHdD4/ (Buy Example) Btw the shape would be facing up and green for buys
Lets say the 50ema happens to be:
-Above the 13 ema for the sell signal
-Below the 13ema for the buy signal
I want it to calculate the at least 10 pips using the close of the previous candle but instead of the 50ema it uses the 200ema.
https://www.tradingview.com/x/STD4mX4F/ (Sell Example)
https://www.tradingview.com/x/1M3qxoHw/ (Buy Example)
Lets say the 50ema and the 200ema happens to be:
-Above the 13 ema for the sell signal
-Below the 13ema for the buy signal
I want it to calculate the at least 10 pips using the close of the previous candle but instead of the 50ema or the 200 ema it uses the 800ema.
https://www.tradingview.com/x/zqQaKFPj/ (Sell Example)
https://www.tradingview.com/x/hTyBGsyn/ (Buy Example)
If on a buy signal all ema are below the buy it doesn't call it vice versa with a sell. I already did this so don't worry about this part!
I got a hint that I need to use syminfo.pointvalue to do this but I'm very new to this so I'm not sure how to implement it in the script.
I tried reading this but even this breakdown is a bit advanced for me to understand. https://kodify.net/tradingview/info/syminfo-pointvalue/
Thank you in advance!! :)
study("Test 1", overlay=true)
//Colors
_color5 = #ffff00
_color13 = #ff0000
_color50 = #00ffff
_color200 = #434651
_color800 = #0000ff
//EMA value
_ema5 = ema(close, 5)
_ema13 = ema(close, 13)
_ema50 = ema(close, 50)
_ema200 = ema(close, 200)
_ema800 = ema(close, 800)
//Plots EMAs
//plot(_ema5, color=#ffff00, transp=100 )
//plot(_ema13, color=#ff0000, transp=100)
//plot(_ema50, color=#00ffff, transp=100)
//plot(_ema200, color=#434651, transp=100)
//plot(_ema800, color=#0000ff, transp=100)
//_c13 and _c50 is true if the ema
_c13 = cross(close, _ema13)
_c50 = cross(close, _ema50)
//Line that the EMAs actually cross
plot(close, style=plot.style_line, color=color.black, transp=100)
//b2 is candle 1 and b1 is candle 2 (IN PINE YOU COUNT CANDLES BACKWARDS FORM THE CURRENT CANDLE)
//Gives us the size of the candles (Regardless of bull or bear)
_b1size = max(open[1], close[1]) - min(open[1], close[1])
_b2size = max(open[2], close[2]) - min(open[2], close[2])
//Ratios of the candle size so you can filter out different sized candles
_szRatio = _b2size/_b1size
_szCondition = _szRatio >= 0.01 and _szRatio<=0.99
//Compares the MAX of candle 1 body against MAX of candle 2 body (same with min)
_engulfing = max(open[1], close[1]) >= max(open[2], close[2]) and min(open[1], close[1]) <= min(open[2], close[2])
//Check the conditions here is true for the EMA to cross candles
_crossed13 = _c13[1] and _c13[2]
_crossed50 = _c50[1] or _c50[2]
//if ema cuts either candle but is also above/below (bear/bull) the 13ema
_crossed50above13ema = _crossed50 and _ema50 > _ema13 //bearsignal
_crossed50below13ema = _crossed50 and _ema50 < _ema13 //bullsignal
//Shows the condidtions for the Signal to Show BULLISH
_emaCondbull = (open<_ema200 or open<_ema800 or (open<_ema50 or _crossed50below13ema)) and not (open>_ema200 and open>_ema800 and open>_ema50)
_bullSignal = _engulfing and _crossed13 and close[1] > max(open[2], close[2]) and _szCondition and _emaCondbull
//Plots the Signal if Conditions are true
plotshape(_bullSignal?close:na, location=location.belowbar, style=shape.triangleup, size=size.tiny, color=#00ff73)
//Shows the condidtions for the Signal to Show BEARISH
_emaCondbear = (open>_ema200 or open>_ema800 or (open>_ema50 or _crossed50above13ema)) and not (open<_ema200 and open<_ema800 and open<_ema50)
_bearSignal =_engulfing and _crossed13 and close[1] < min(open[2], close[2]) and _szCondition and _emaCondbear
//Plots the Signal if Conditions are true
plotshape(_bearSignal?close:na, style=shape.triangledown, size=size.tiny, color=#ff0000)