Hi,
I am new to writing the code and am struggling to get my first indicator to work.
What I am trying to achieve is:
- Based on daily closing prices
- Close > 200 day simple moving average
- Close has pulled back > 3% from the previous highest point
- Close > 5 day simple moving average
- Return 1
Please could someone help me understand where to start with this.
Thanks,
Chris
There you go (I only tested it for syntax errors):
HH = highest[100](high) //100 lookback periods to find highest point
c1 = close > average[200,0](close) //close > sma200
c2 = close <= (HH * 0.97) //close at least equal to or less than 3% pullback
c3 = close > average[5,0](close) //close > sma5
RETURN c1 AND c2 AND c3
Here is an alternative. It resets the high to the current candle if the conditions are met so it can then look for a new drop from that fresh start.
(not tested)
hh = max(high,hh)
flag = 0
if close < hh*0.97 and close > average[200,0](close) and close > average[5,0](close) then
flag = 1
hh = high
endif
RETURN flag
Note: I have edited the title of your topic. Please try to use more meaningful titles that describe your topic rather than things like ‘Help needed’ otherwise we end up with a forum full of topics with meaningless titles! 🙂