OPEN-SOURCE SCRIPT

MPF EMA Cross Strategy (8~13~21) by Market Pip Factory

Updated
This script is for a complete strategy to win maximum profit on trades whilst keeping losses at a minimum, using sound risk management at no greater than 1.5%

The 3x EMA Strategy uses the following parameters for trade activation and closure.
1/ Daily Time Frame for trend confirmation
2/ 4 Hourly Time Frame for trend confirmation
3/ 1 Hourly Time Frame for trend confirmation AND trade execution
4/ 3x EMAs (Exponential Moving Averages)
* EMA#1 = 8 EMA (Red Color)
* EMA#2 = 13 EMA (Blue Color)
* EMA#3 = 21 EMA (Orange Color)
5/ Fanning of all 3x EMAs and CrossOver/CrossUnder for Trend Confirmation
6/ Price Action touching an 8 EMA for trade activation
7/ Price Action touching a 21 EMA for trade cancellation BEFORE activation
* For LONG trades: 8 EMA would be ABOVE 21 EMA
* For SHORT trades: 8 EMA would be BELOW 21 EMA
* For trade Cancellation, price action would touch the 21 EMA before trade is activated
* For trade Entry, price action would touch 8 EMA

Once trigger parameter is identified, entry is found by:
a) Price action touches 8 EMA (Candle must Close for confirmed Trade preparation)
b) Trade preparation can be cancelled before trade is activated if price action touches 21 EMA
c) Trailing Stop Loss can be used (optional) by counting back 5 candles from current candle

CLOSURE of a Trade is identified by:
e) 8 EMA crossing the 21 EMA, then close trade, no matter LONG or SHORT
f) Trail Stop Loss

IMPORTANT:
g) No more than ONE activated trade per EMA crossover
h) No more than ONE active trade per pair

NOTE: This strategy is to be used in conjunction with Cipher Twister (my other indicator) to reduce trades on
sideways price action and market trends for super high win ratio.

NOTE: Enabling of LONGs and SHORTs Via Cipher Twister is done by using the previous
green or red dot made. Additionally, when the trend changes, so do the dot's validity based
on being above or below the 0 centerline.

----------------------------
Strategy and Bot Logic
----------------------------

.....::: FOR SHORT TRADES ONLY :::.....
The Robot must use the following logic to enable and activate the SHORT trades:

Parameters:
$(crossunder)=8EMA,21EMA=Bearish $(crossover)=8EMA,21EMA=Bullish entry=SELL STOP ORDER (Short)
EMA#1 = 8 EMA (Red Color) EMA#2 = 13 EMA (Blue Color) EMA#3 = 21 EMA (Orange Color)

Strategy Logic:
1/ Check Daily Time Frame for trend confirmation if:
(look back up to 50 candles - find last cross of EMAs)
$(chart)=daily and trend=$(crossunder) then goto 2/ *Means: crossunder = ema21 > ema8
$(chart)=daily and trend=$(crossover) then stop (No trades) *Means: crossover = ema8 > ema21
NOTE: This function is switchable. 0=off and 1=on(active). Default = 1 (on)

2/ Check 4 Hourly Time Frame for trend confirmation if:
(look back up to 50 candles - find last cross of EMAs)
$(chart)=4H and trend=$(crossunder) then goto 3/ *Means: crossunder = ema21 > ema8
$(chart)=4H and trend=$(crossover) then stop (No trades) *Means: crossover = ema8 > ema21
NOTE: This function is switchable. 0=off and 1=on(active). Default = 1 (on)

3/ 1 Hourly Time Frame for trend confirmation AND trade execution if:
(look back up to 50 candles - find last cross of EMAs)
$(chart)=1H and trend=$(crossunder) then goto 4/ *Means: crossunder = ema21 > ema8
$(chart)=1H and trend=$(crossover) then stop (No trades) *Means: crossover = ema8 > ema21

4/ Trade preparation:
* if Next (subsequent) candle touches 8EMA, then set STOP LOSS and ENTRY
* stoploss=3 pips ABOVE current candle HIGH
* entry=3 pips BELOW current candle LOW

5/ Trade waiting (ONLY BEFORE entry is hit and trade activated):
* if price action touches 21 EMA then cancel trade and goto 1/
Note: Once trade is active this function does not apply !

6/ Trade Activation:
* if price activates/hits ENTRY price, then bot activates trade SHORTs market

7/ Optional Trailing stop:
* if active, then trailing stop 3 pips ABOVE previous HIGH of previous 5th candle
or * Move Stop Loss to Break Even after X number of pips
NOTE: This means count back and apply accordingly to the 5th previous candle from current candle.
NOTE: This function is switchable. 0=off and 1=on(active). Default = 0 (off)

8/ Trade Close ~ Take Profit:
* Only TP when
$(chart)=1H and trend=$(crossover) then close trade ~ Or obviously if Stop Loss is hit if 7/ is activated.
----------END FOR SHORT TRADES LOGIC----------


.....::: FOR LONG TRADES ONLY :::.....
The Robot must use the following logic to enable and activate the LONG trades:

Parameters:
$(crossunder)=8EMA,21EMA=Bearish $(crossover)=8EMA,21EMA=Bullish entry=BUY STOP ORDER (Long)
EMA#1 = 8 EMA (Red Color) EMA#2 = 13 EMA (Blue Color) EMA#3 = 21 EMA (Orange Color)

Strategy Logic:
1/ Check Daily Time Frame for trend confirmation if:
(look back up to 50 candles - find last cross of EMAs)
$(chart)=daily and trend=$(crossover) then goto 2/ *Means: crossover = ema8 > ema21
$(chart)=daily and trend=$(crossunder) then stop (No trades) *Means: crossunder = ema21 > ema8
NOTE: This function is switchable. 0=off and 1=on(active). Default = 1 (on)

2/ Check 4 Hourly Time Frame for trend confirmation if:
(look back up to 50 candles - find last cross of EMAs)
$(chart)=4H and trend=$(crossover) then goto 3/ *Means: crossover = ema8 > ema21
$(chart)=4H and trend=$(crossunder) then stop (No trades) *Means: crossunder = ema21 > ema8
NOTE: This function is switchable. 0=off and 1=on(active). Default = 1 (on)

3/ 1 Hourly Time Frame for trend confirmation AND trade execution if:
(look back up to 50 candles - find last cross of EMAs)
$(chart)=1H and trend=$(crossover) then goto 4/ *Means: crossover = ema8 > ema21
$(chart)=1H and trend=$(crossunder) then stop (No trades) *Means: crossunder = ema21 > ema8

4/ Trade preparation:
* if Next (subsequent) candle touches 8EMA, then set STOP LOSS and ENTRY
* stoploss=3 pips BELOW current candle LOW
* entry=3 pips ABOVE current candle HIGH

5/ Trade waiting (ONLY BEFORE entry is hit and trade activated):
* if price action touches 21 EMA then cancel trade and goto 1/
Note: Once trade is active this function does not apply !

6/ Trade Activation:
* if price activates/hits ENTRY price, then bot activates trade LONGs market

7/ Optional Trailing stop:
* if active, then trailing stop 3 pips BELOW previous LOW of previous 5th candle
or * Move Stop Loss to Break Even after X number of pips
NOTE: This means count back and apply accordingly to the 5th previous candle from current candle.
NOTE: This function is switchable. 0=off and 1=on(active). Default = 0 (off)

8/ Trade Close ~ Take Profit:
* Only TP when
$(chart)=1H and trend=$(crossunder) then close trade ~ Or obviously if Stop Loss is hit if 7/ is activated.
----------END FOR LONG TRADES LOGIC----------


IMPORTANT:
* If an existing trade is already open for that same pair, & price action touches 8EMA, do NOT open a new trade..
* bot must continuously check if a trade is currently open on the pair that triggers
* New trades are to be only opened if there is no active trade opened on current pair.
* Only 1 trade per pair rule !
* 5 simultaneous open trades (not same pairs) default = 5 but value can be changed accordingly.
* Maximum risk management must not exceed 1.5% on lot size

*** Some features are not yet available autoated, they will be added in due course in subsequent version updates ***
Release Notes
Added 3x Timeframe data in cells
Added cells for 3x Charts (Daily, 4Hourly and 1Hourly)
Added Confirmation of trend (within 3x matching trends/timeframes)
Added some math calc and parameters
Still work in progress
Release Notes
Added Trend Confirmation Alerts
Modified drawings on chart
automatedbuyLONGMoving Averagesmulti-timeframemultitimeframePine utilitiesSELLshortstrategytrendconfirmation

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer