Page 1 of 1

Coding Bar Pattern

Posted: Fri Apr 01, 2022 9:46 pm
by AnthonyB
In Forex, in a down market, sometimes the top of the price candles will use the ema as resistance

Is this the right syntax for coding this pattern

//This code should detect the high of the previous bar when the high is equal to the ema or within 11 pips of the ema and the bar closed down.

(HIGH [1] <= (ta.ema - 0.09%) and (close [1] < ta.ema)

Re: Coding Bar Pattern

Posted: Wed Feb 01, 2023 11:51 am
by processingclouds
Hey,

Pinescript is case-sensitive, so therefore your statement is going to return errors.
HIGH should be high
also (ta.ema - 0.09%) is not correct. If you are trying to say 0.09% less from ema than it would be ta.ema*99.91.
There is an extra ( in the beginning.
Lastly to use ta.ema you need to provide two parameters ta.ema(source, length)

So your line will be something like:

Code: Select all

x = high[1] <= (ta.ema(close,14) * 99.91) and (close [1] < ta.ema(close,14))