Hi all, I am sure some of you might heard of the folks from BK Forex Kathy Lien. In her book “High Probability Trading Setups for the Currency Market” there is this interesting short-term momentum strategy which is as follow:
Rules for Five-Minute momentum Trade (using EMA20 and MACD(12,26,9)
Long Trade
1) Look for currency pair to be trading below the 20-period EMA and MACD to be negative
2) Wait for price to cross above the 20-period EMA, make sure that MACD is either in the process of crossing from negative to positive or have crossed into positive territory no longer than 5 bars ago
3) Go long 10 pips above the 20-period EMA
4) Place stop 20 pips below 20-period EMA
5) Sell half of position at entry plus amount risked, move stop on second half to breakeven
6) Trail stop by higher of breakeven or 20-period EMA minus 15 pips
It looks simple but I got lost on step 3 as the strategy requires long entry as soon as the price cross above the EMA by 10 pips without waiting for the candle to finish forming. If anyone able to code this, will appreciate if you can share the codes here. Thank you and have a great day ahead.
You have to resort to a very low TF (even 1 sec) to check the crossing and use the setup TF with default, instead of UpdateOnClose.
EricParticipant
Master
x1 = ExponentialAverage[20](close)+10*pipsize
BUY 1 CONTRACT AT x1 STOP
Hi PRT Community,
Can anyone share the codes of this strategy please? Thank you all.
Hi sorry I did not manage to code this. Its a bit too challenging for me for now. Maybe the expert member of the community can give a helping hand? Thank you and good luck.
Hello Roberto / Nicolas,
If you can help to code this strategy I will be very grateful. Thank you and looking forward to hearing from you soon.
What does “Sell half of position at entry plus amount risked” mean?
How can half position be sold at entry?
What risk are you talking about?
Hi Roberto,
For example you buy a stock, 10 shares at $100, and have committed $20 amount to risk. Thus your initial SL at entry is $80. When you the price is in the money and gone up from $100 to $120, you sell 5 shares, locking in some profit X amount. After that you move your SL at $80 (which is for 10 shares initially) to new SL leve at $100 for the balance 5 shares. Effectively moving your stop loss to your entry price. Thus, if prices moves beyond $120, you gained more. If price move back down to $100 again you are out at your entry price , and overall you are flat.
5) Sell half of position at (entry + amount risked), move stop on second half to breakeven. Apologies I did not make it clear in the beginning.
There you go:
DEFPARAM CumulateOrders = False
Offset = 10 * PipSize
Distance = 6 * PipSize
MySL = 20 * PipSize
LotSize = 10
SellHalf = 20 * PipSize
Ema20 = average[20,1](close)
MyMACD = Macd[12,26,9](close)
L1 = close CROSSES OVER Ema20
L2 = summation[5](MyMacd CROSSES OVER 0)
Lcond = L1 AND L2 AND Not OnMarket
IF Lcond THEN
Entry = Ema20 + Offset
IF close > (Entry + Distance) THEN
BUY LotSize Contract AT Entry LIMIT
ELSIF close < (Entry - Distance) THEN
BUY LotSize Contract AT Entry STOP
ELSE
BUY LotSize Contract AT Market //comment out this line to not enter AT MARKET
ENDIF
SET STOP LOSS MySL
SET TARGET PROFIT MySL * 3 //comment out this line not to set a TP
ENDIF
//
Gain = PositionPerf * PositionPrice / PipSize
IF LongOnMarket AND abs(CountOfPosition) = LotSize THEN
IF Gain >= SellHalf THEN
StopLevel = PositionPrice
SELL (LotSize / 2) Contract AT Market
ENDIF
ENDIF
//
IF Not OnMarket THEN
StopLevel = 0
ELSIF StopLevel > 0 THEN
SELL AT StopLevel STOP
ENDIF
graph Gain coloured(0,0,255,255)
graph abs(CountOfPosition)
graphonprice StopLevel coloured(255,0,0,255) AS "BreakEven"
graphonprice PositionPrice coloured(0,128,0,255) AS "Entry Price"
graphonprice PositionPrice - MySL coloured(0,0,255,255) AS "SL"
graphonprice PositionPrice + SellHalf AS "SellHALF"
I added:
- Distance to comply with the broker’s requirements (set it to 0 to disable it)
- TP (comment out that line to disable it)
You can comment out the line to enter at MARKET when there’s not enough distance to place a pending order. In such a case you will get fewer trades, only those within the pending order limits.
Thank you so much, Roberto. I really appreciate it.
Hi Roberto, can you pls explain what summation[5](MyMacd CROSSES OVER 0) mean? Does it mean:
(MyMacd[0] CROSSES Over 0) OR (MyMacd[1] CROSSES Over 0) OR (MyMacd[2] CROSSES Over 0) OR (MyMacd[4] CROSSES Over 0) OR (MyMacd[5] CROSSES Over 0) ?
Thank you in advance.
Yes, it’s (MyMacd[0] CROSSES Over 0) OR (MyMacd[1] CROSSES Over 0) OR (MyMacd[2] CROSSES Over 0) OR (MyMacd[3] CROSSES Over 0) OR (MyMacd[4] CROSSES Over 0).
It makes a sum of the number of times a MACD crossover occurs in the last 5 bars (0 to 4). The returned value is true whenever it’s different from 0.
Or does it mean:
(myMaCD crosses over 0) OR ((myMACD[1] crosses over 0) AND myMACD>0) OR ((myMACD[2] crosses over 0) AND myMACD[1]>0 AND myMACD>0) OR ((myMACD[3] crosses over 0) AND myMACD[2]>0 AND myMACD[1]>0 AND myMACD>0) OR ((myMACD[4] crosses over 0) AND myMACD[3]>0 AND myMACD[2]>0 AND myMACD[1]>0 AND myMACD>0) OR ((myMACD[5] crosses over 0) AND myMACD[4]>0 AND myMACD[3]>0 AND myMACD[2]>0 AND myMACD[1]>0 AND myMACD>0)