|
Need help on writing code for EA strategy
Rules for a Long Trade
1. Look for currency pair trading below the 20-period EMA and MACD to be negative.
2. Wait for price to cross above the 20-period EMA, then make sure that MACD is either in the process of crossing from negative to positive or has crossed into positive territory no longer than five bars ago.
3. Go long 10 pips above the 20-period EMA.
4. For an aggressive trade, place a stop at the swing low on the five-minute chart. For a conservative trade, place a stop 20 pips below the 20-period EMA.
5. Sell half of the position at entry plus the amount risked; move the stop on the second half to breakeven.
6. Trail the stop by breakeven or the 20-period EMA minus 15 pips, whichever is higher.
Rules for a Short Trade
1. Look for the currency pair to be trading above the 20-period EMA and MACD to be positive.
2. Wait for the price to cross below the 20-period EMA; make sure that MACD is either in the process of crossing from positive to negative or crossed into negative territory no longer than five bars ago.
3. Go short 10 pips below the 20-period EMA.
4. For an aggressive trade, place stop at the swing high on a five-minute chart. For a conservative trade, place the stop 20 pips above 20-period EMA
5. Buy back half of the position at entry minus the amount risked and move the stop on the second half to breakeven.
6. Trail stop by lower of breakeven or 20-period EMA plus 15 pips
MACD histogram is the default, which is first EMA = 12, second EMA = 26, signal EMA = 9, all using the close price.
|