İş tamamlandı
İş Gereklilikleri
I need an EA for MT4 based on MACD cross and Moving Averages. Below is a detailed description of the proposed EA. There's also a BUY example attached for clarity. This EA should work for for all time frames and symbols.
Global Variables
MacDFast = Fast=12 //Fast EMA Period
MacDSlow = Slow=26 //Slow EMA Period
MacDSource = Close // Applied Price
MacDSignal = 9 //Signal Line Period
MacDRangeLong = -4.5,-45.0 //MacD Range for BUY signal when macd cross signal line
MacDRangeShort = 4.5, 45.0 //Range for SELL signal when macd cross signal line
EMA1 = 100 //100 Exponential Moving Average
EMA2 = 125 //125 Exponential Moving Average
EMA3 = 200 //200 Exponential Moving Average
LotSize = 0.01 //Default lot size
AlertOnly = 0 //When all conditions are met, trigger mt4 alert
TradeOnly = 0 //When all conditions are met, trigger mt4 trade
TakeProfit = 0 //Take Profit variable is set when conditions are met
StopLoss = 0 //Stop Loss variable is set when conditions are met
RiskReward = 1.5 //Default risk/reward ratio multiplier
Session = 0 //0=All Sessions, 1=New York, 2=London, 3=Tokyo, 4=Sydney (User can select multiple sessions)
MutipleOrders = 0 //0=Open Order when conditions are met 1=Only open one order at a time, additional order cannot be opened
ATR = 14 //Average true range used in stop loss calculation
Long: At Candle open
if (previous candle high and low > EMA1) && (previous candle high and low > EMA2) && (previous candle high and low > EMA3)
if (current candle open > EMA1) && (current candle open > EMA2) && (current candle open > EMA3)
if (macd and signal line cross between MacDRangeLong)
if(AlertOnly = 1 && TradeOnly = 0)
(
StopLoss = Distance from price to ema2
TakeProfit = (Distance from price to ema2) * RiskReward
Alert("Buy at " + CurrentPrice + "Stop Loss " StopLoss + "Take Profit" + TakeProfit )
)
if(AlertOnly = 0 && TradeOnly = 1)
(
Buy Market Order
LotSize = LotSize
StopLoss = Distance from price to ema2
TakeProfit = (Distance from price to ema2) * RiskReward
when ( price = 50% of TakeProfit )
StopLoss = break even + 5 pips
when ( price = TakeProfit )
Trailing Stop Loss = calculated by subtracting the current ATR value from the lowest-low of the given lookback period
)
Short: At Candle open
if (previous candle high and low < EMA1) && (previous candle high and low < EMA2) && (previous candle high and low < EMA3)
if (current candle open < EMA1) && (current candle open < EMA2) && (current candle open < EMA3)
if (macd and signal line cross between MacDRangeShort)
if(AlertOnly = 1 && TradeOnly = 0)
(
StopLoss = Distance from price to ema2
TakeProfit = (Distance from price to ema2) * RiskReward
Alert("Sell at " + CurrentPrice + "Stop Loss " StopLoss + "Take Profit" + TakeProfit )
)
if(AlertOnly = 0 && TradeOnly = 1)
(
Sell Market Order
LotSize = LotSize
StopLoss = Distance from price to ema2
TakeProfit = (Distance from price to ema2) * RiskReward
when ( price = 50% of TakeProfit )
StopLoss = break even + 5 pips
when ( price = TakeProfit )
Trailing Stop Loss = calculated by adding the current ATR value to the highest-high of the given lookback period
)