Hi there,
I need a code for an indicator that shows the following rules. At best as a line similar to a Donchian?
The following rules:
H4 timeframe
Bullish:
EMA50> EMA50 [1]
Red candle (open> close)
Lowest high of the last RED CANDLE [5]
Bearish:
EMA50 <EMA50 [1]
Green candle (close> open)
highest low of the last GREEN CANDLE [5]
In addition, only those candles of the respective color that are in line with the trend of the EMA specification are taken into account.
The aim is to get a stop order at the respective point (high / low) as an entry condition for a trading system.
It is important that only candles of the respective direction / color are taken into account and that the entry point is then determined.
Here is an instructional video of the original version of Long Hang Seng. I just added some rules of my own. Maybe you can also code the original setup to see which system is better? So two versions?
Short:
Long:
Hang Seng’s original setup should explain the videos well.
My setup in short:
Long: EMA50 rises, stop buy order at the high of the lowest high of the last 5 RED candles.
Short: EMA50 goes down, stop sell short order at the low of the highest low of the last 5 GREEN candles.
Attached as a picture. Sorry for the quality. Created on the smartphone.
EurUsd short signals last week as a picture.
There you go:
Offset = average[100,0](range)
Ema50 = Average[50,1](close)
EmaUP = Ema50 > Ema50[1]
EmaDN = Ema50 < Ema50[1]
Bullish = close > open
Bearish = close < open
Bulls = 0
Bears = 0
hh = 9999999
ll = 0
FOR i = 0 TO BarIndex
IF Bullish[i] AND (Bulls < 5) THEN
Bulls = Bulls + 1
ll = max(ll,low[i])
ENDIF
IF Bearish[i] AND (Bears < 5) THEN
Bears = Bears + 1
hh = min(hh,high[i])
ENDIF
IF (Bulls >= 5) AND (Bears >= 5) THEN
Break
ENDIF
NEXT
IF Bullish AND EmaUP THEN
IF close CROSSES OVER ll THEN
DrawArrowUP(BarIndex,low - Offset) coloured(0,128,0,150)
ENDIF
ENDIF
IF Bearish AND EmaDN THEN
IF close CROSSES UNDER hh THEN
DrawArrowDOWN(BarIndex,high + Offset) coloured(255,0,0,255)
ENDIF
ENDIF
RETURN hh coloured(255,0,0,255) style(line,2) AS "SHORT entry",ll coloured(0,128,0,140) style(line,2) AS "LONG entry"