AnthonyB
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: April 1st, 2022

Coding Bar Pattern

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)

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: Coding Bar Pattern

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))

Return to “Pine Script Q&A”