0bps

Strategy vault / Trend following

EMA Crossover Intraday Trading Strategy Based on AO Oscillator

This is an intraday trading strategy that utilizes the AO oscillator and EMA crossovers to generate trading signals. The main idea is to enter trades when the AO crosses its zero line concurrently with the fast EMA…

Author
ChaoZhang
Complexity
Starter · 45 lines
Parameters
5
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This is an intraday trading strategy that utilizes the AO oscillator and EMA crossovers to generate trading signals. The main idea is to enter trades when the AO crosses its zero line concurrently with the fast EMA crossing over the medium-term EMA line.

Strategy Logic

The strategy mainly relies on two indicators for entries and exits:

  1. AO Oscillator: It measures the difference between 5-period and 34-period HL2 averages to gauge current trend direction. Positive AO represents an upward trend while negative AO signals a downward trend.

  2. EMA Crossover: The strategy uses a 3-period EMA for short-term trend and a 20-period EMA for medium-term trend direction. A golden cross with the 3EMA moving up through the 20EMA generates buy signals while a death cross with the 3EMA crossing down through the 20EMA produces sell signals.

Trades are entered only when the AO crosses its zero line concurrently with an EMA crossover. This avoids wrong signals when the AO is oscillating. Exits happen after the London session closes by flattening all positions.

Advantage Analysis

The main advantages of this strategy are:

  1. AO oscillator ensures accurate trend direction for reliable signals;
  2. Dual-indicator combo filters out noise for high-confidence signals;
  3. Trading only during major sessions avoids overnight risks;
  4. Simple and clear logic makes it easy to understand and implement;
  5. No optimization or curve-fitting needed with stable parameters.

Risk Analysis

Some risks to note include:

  1. Risk of extended losses without timely stop-loss in black swan events;
  2. Whipsaws from false EMA crossovers in ranging markets;
  3. Lack of adaptiveness from fixed parameters across changing market cycles.

Risks can be mitigated via stop losses, adaptive parameters tuned to varying cycles etc.

Optimization Directions

Main optimization directions are around parameter tuning:

  1. Adjust EMA periods to test shorter-term combos or additional EMAs in signal generation;
  2. Tune AO parameters to assess impact on the oscillator;
  3. Add supplementary indicators like RSIbord to avoid overbought/oversold conditions;
  4. Adjust trading session timings to test different regions or longer durations.

Parameter tweaks and additional filters can enhance the strategy's robustness and efficiency.

Conclusion

In summary, this intraday trading tactic combines the AO trend gauge with EMA crossovers to craft a simple yet practical approach. It has clear signals that are easy to implement but lacks adaptive parameters. Further testing and refinements can improve its stability and alignment with varying market landscapes. Overall it presents retail intraday traders with an excellent choice.

Parameters

NameDefaultWhat it controls
v_input_13Length
v_input_2_close0Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_320Length
v_input_4_close0Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_5falseReverse position ?

Source Pine Script

/*backtest
start: 2022-12-18 00:00:00
end: 2023-12-24 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//@author SoftKill21

strategy(title="MA cross + AO", shorttitle="MA_AO")
ao = sma(hl2,5) - sma(hl2,34)

len = input(3, minval=1, title="Length")
src = input(close, title="Source")
out = ema(src, len)

len1 = input(20, minval=1, title="Length")
src1 = input(close, title="Source")
out1 = sma(src1, len1)

timeinrange(res, sess) => time(res, sess) != 0
londopen = timeinrange(timeframe.period, "0300-1100") 
nyopen = timeinrange(timeframe.period, "0800-1600") 

longC = crossover(out,out1) and ao>0 and londopen
shortC = crossunder(out,out1) and ao<0 and londopen

invert = input(title="Reverse position ?", type=input.bool, defval=false)

if(invert==false)
    strategy.entry("LONG",1,when=longC)
    strategy.entry("SHORT",0,when=shortC)



if(invert==true)
    strategy.entry("short",0,when=longC)
    strategy.entry("long",1,when=shortC)
    
strategy.close_all(when= not (londopen))


Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-25. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/EMA-Crossover-Intraday-Trading-Strategy-Based-on-AO-Oscillator.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open