I would like to know how to place trade only when a PIN bar is formed blow EMA for short and long when a bullish pin bar is formed above EMA(0).
I have a code where I check for Open and Close and High Low of PIN bar value is lower than EMA(0) to place a short trade on a berish pin bar but it seems still placing short trades when berish PIN bar is formed above EMA .
I am checking values are correct in PRINT log and it should only do a short for berish pin bar below EMA value that is higher than PIN bar.
Any suggestion or examples code would help.
My PIN bar logic is working fine. see the image attached where this PIN bar is berish and above EMA in orange but placed trade while it should be ignored. EMA1 is the input capable variable that I pass from strategy edit screen like 9 ema or 21 ema or any value and that is used to draw on chart and use for EMA value.
if (Close[0] > EMA1[0] && Open[0] > EMA1[0] && High[0] > EMA1[0] && Low[0] > EMA1[0])
// {
// ABOVE_EMA = true;
// }
// if (Close[0] < EMA1[0] && Open[0] < EMA1[0] && High[0] < EMA1[0] && Low[0] < EMA1[0])
// {
// BELOW_EMA = true;
// }
Thanks

Comment