Hi Guys,
I was thinking to build a strategy, but indeed I do not have knowledge with programming language. Could someone helps me in creating a strategy by using this indicator:
RAGHEE HORNER GRAB CANDLES
I think it’s better than the Heikin-Ashi bars, which may not provide a clear indication of a sideways market.
The strategy is as follows:
- Trend identification: The colour of the bars helps to identify the current trend. Green bars suggest an uptrend, red bars suggest a downtrend, and blue bars suggest a sideways market.
- Entry signal: For long trades, wait for the first green bar after a series of red bars to confirm the start of an uptrend. For short trades, wait for the first red bar after a series of green bars to confirm the start of a downtrend. No trades are taken when the bars are blue as it suggests a sideways market with no clear direction. Maybe it could be added a further variable: the ADX values should be above 20 or better 25 indicating a strong trend.
- Stop-loss placement and Take-profit target: Use a trailing stop-loss to ride the trend until it shows signs of reversal.
Many thanks and sorry if I asked a trivial or already discussed question.
ciao
Edo
JSParticipant
Senior
Hi @Edo,
Maybe a starting point…
DefParam CumulateOrders = False
Once EMAPeriod = 26
Once ADXPeriod = 6
Once TStart = 20 //Trailing Start
Once TStep = 2 //Trailing Step
a=exponentialaverage [EMAPeriod] (high) //Upper Grab
b=exponentialaverage [EMAPeriod] (low) //Lower Grab
c=ADX[ADXPeriod] //Average Directional Index
If Close > a and Close[1] < a and c > 25 then //Start UpTrend and ADX>25
Buy 1 contract at Market
EndIf
if Close < b and Close[1] > b and c > 25 then //Start DownTrend and ADX>25
SellShort 1 contract at Market
EndIf
//************************************************************************
//trailing stop function
trailingstart = TStart //trailing will start @trailinstart points profit
trailingstep = TStep //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
Thank you very much JS! You were as fast as lightning! I will test it, it looks promising 🙂