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?
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"
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR.
For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com
If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.
Get Assistance
Assistance Type
Your Need
Proposed Solutions
Do you like cookies? 🍪 We use cookies to ensure you get the best experience on our website.
(Learn more)