Работа завершена
Техническое задание
I have writtern this EA for MQL4 but I'm having a difficult time with MQL5. I need someone's help.
Inputs
TakeProfit, StopLoss (in pips)
TradingTimeFrame - the chart's period
IndicatorBuffer - using the chart's timeframe, IndicatorParam1,IndicatorParam2,IndicatorParam3, I can add params if needed later
Example: iMACD(NULL,TradingTimeFrame,IndicatorParam1,IndicatorParam2,IndicatorParam3,PRICE_CLOSE,MODE_MAIN)
OtherTimeFrame - some other timeframe,
OtherIndicatorBuffer - using the OtherPeriod's timeframe + OtherIndicatorParam1, OtherIndicatorParam2, OtherIndicatorParam3
MaxSpread (in pips) - if current spread is bigger, stop trading until spread is back to normal
Leverage - multiplier of Balance to get lots, example: Leverage 10, Balance 1000, should trade 10,000 or 0.1 lots
MaxSingleDayLossCount, example if set to 2, after 2 losing trades in the same day, trading should stop until next day
WaitInMinutes - after a trade has reached SL or TP, wait before placing another trade based on new signal, also wait for next order if trading multiple based on new signal
MultipleTrades - bool, true or false. If true, will add to position in the same direction but must use WaitInMinutes and new Signal
StartHour - start of trading for the week, Sunday at 17:00PST
StopHour - stop trading, close all open positions, Friday at 12:00PST (implicit, no trading on Saturday)
AllowClose - bool. If true will close open positions based on opposite signals
OnInit
Write all parameters above to file, Symbols()+params.csv if not present
Read all parameters above to file, Symbols()+params.csv (useful because a recompile sets all params back to default)
If Optimizing or Testing, do not read nor write params files
Set MagicNumber by converting Symbol() to number.
for(int i=0;i<6;i++){
MagicNumber += MathAbs(StringGetChar(Symbol(),i));
}
OnTick
Alert if TradingTimeFrame != Period() and stop EA or just return(0)
Check dayofweek and hour of day use TimeLocal()
if Sat = no trading
if Sun and 17:00, start trading
if Fri and 12:00, stop trading and close all open positions
Signals:
bool TrendUp = OtherIndicator[0]>OtherIndicator[1]
bool SignalUp = Indicator[0]>Indicator[1]
bool TriggerUp = Ask>Previous bars high, TradingTimeFrame or chart's Period()
OpenBuy = TrendUp && SignalUp && TriggerUp
OpenSell = TrendDn && SignalDn && TriggerDn (need 3 more bools opposite of Up bools)
CloseBuy = OpenSell && AllowClose
CloseSell = OpenBuy && AllowClose
GetLots = Leverage * Balance (converted to lots)
GetLastClosedTradeTime - used with WaitInMInutes, I think this must be TimeCurrent()
GetLastOpenTradeTime - used with WaitInMinutes and Multiple, also TimeCurrent()
Trading:
GetSignal
check loss count (from history)
check lots
check wait and direction of open position if trading Multiple (GetLastOpenTradeTime)
check wait with GetLastClosedTradeTime
SendOrders - market orders only, then modify to add SL and TP
Symbol().Refresh after successfull send order.
That's it for now, I think I got all my requirements in. Let me know if you're interested and an estimate of cost. I can give you snippets of my MQL4 code if you are chosen.