А если сказать все вышеуказанное человеческим языком, то как это будет?
Берется
Open начала интрвала (было "жестко забито" 10:00) отступается от него на величину
gi_144 (было "жестко забито" 20)
Если
Ask лежит в интервале между "
полученным уровнем" и
"полученный уровень" +
(Ask - Bid) / Point, то открываемся на Бай со стоплосом ниже
"полученного уровеня" на ... единственный оптимизируемый параметр
StopLoss.
Аналогично для Sell.
Ну и, естественно, открывемся только "от и до" ("жестко забыто" 10:00 и 20:00), после времени "до" закрываем все ордера. Также закрываем ордер по достижении некоего ... короче не TP, а когда цена достигает некоторого (опять же "жестко забито" 250.0!!!) уровня от цены открытия. (Зачем? , чтобы ДЦ не "срывало Тейки"
)
Трейлим ... "по Хаям/Ловам текущего бара".
/*
*/
#property copyright "Copyright © 2006-2008, winning-solution.Com "
#property link "https://winning-solution.com/"
extern string title = "WINNING SOLUTION 9.5 beta";
extern int HourFrom = 10;
extern int HourTo = 20;
extern int StopLoss = 40;
extern int gi_144 = 20;
extern int TrailingStop = 40;
extern int TrailingStep = 10;
extern int ProfiPoint = 250;
extern double Lots = 0.1;
extern bool EnableMoneyManagement= false;
extern double RiskProcentage = 0.2;
extern int MAGIC = 2008082801;
int gi_80 = D'02.09.2999 02:59';
string strTimeFrom;
string strTimeTo;
double gd_168 = 0.01;
double gd_176 = 1000.0;
double gd_184 = 0.0;
double gd_192 = 1.0;
bool gi_204 = FALSE;
void init()
{
strTimeFrom = DoubleToStr(HourFrom, 0) + ":00";
strTimeTo = DoubleToStr(HourTo, 0) + ":00";
}
void LifeTimeSecurityCode()
{
main();
return;
}
string TimeToString(int ai_0)
{
if (!gi_204)
return(TimeToStr(ai_0, TIME_MINUTES));
int li_4 = TimeHour(ai_0);
int l_minute_8 = TimeMinute(ai_0);
string ls_12 = " AM";
if (li_4 >= 12)
{
li_4 -= 12;
ls_12 = " PM";
}
if (li_4 == 0)
li_4 = 12;
string ls_ret_20 = DoubleToStr(li_4, 0) + ":";
if (l_minute_8 < 10)
ls_ret_20 = ls_ret_20 + "0";
ls_ret_20 = ls_ret_20 + DoubleToStr(l_minute_8, 0);
ls_ret_20 = ls_ret_20 + ls_12;
return (ls_ret_20);
}
void start()
{
LifeTimeSecurityCode();
}
void main()
{
string strCommentOrder;
int mTimeFrom, mTimeTo;
string strSignal;
string strTrend;
string strComment;
// if (IsTesting() == 0)
{ //Проверка на IsTesting
if (EnableMoneyManagement)
Lots = CalculateMMLot();
else
Lots = Lots;
strCommentOrder = "WSS9.5-" + Symbol();
mTimeFrom = StrToTime(strTimeFrom);
mTimeTo = StrToTime(strTimeTo);
if(
TimeCurrent() >= mTimeFrom
&& TimeCurrent() <= mTimeTo
)
{
//Выставляем ордера по времени
SetOrders(strCommentOrder, MAGIC);
}
strSignal = "----";
strTrend = "----";
for(int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++)
{ //Сопровождение ордеров
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderComment() == strCommentOrder)
{
if (TimeCurrent() > mTimeTo)
{
if (OrderType() == OP_BUY)
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
if (OrderType() == OP_SELL)
OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
Sleep(10000);
}
if (OrderType() == OP_BUY)
{
strSignal = "BUY " + Symbol() + " @" + DoubleToStr(OrderOpenPrice(), Digits);
strTrend = Symbol() + " going UP";
if (Bid >= OrderOpenPrice() + ProfiPoint * Point)
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
if(
High[0] - OrderOpenPrice() >= TrailingStop * Point
&& OrderStopLoss() < OrderOpenPrice()
)
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + TrailingStep * Point, OrderTakeProfit(), 0, Green);
Sleep(10000);
}
if (OrderType() == OP_SELL)
{
strSignal = "SELL " + Symbol() + " @" + DoubleToStr(OrderOpenPrice(), Digits);
strTrend = Symbol() + " going DOWN";
if (Ask <= OrderOpenPrice() - ProfiPoint * Point)
OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
if(
OrderOpenPrice() - Low[0] >= TrailingStop * Point
&& OrderStopLoss() > OrderOpenPrice()
)
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - TrailingStep * Point, OrderTakeProfit(), 0, Green);
Sleep(10000);
}
}
} //Сопровождение ордеров
if (IsTesting() == 0)
{
strComment = "\nWSS V9.5 Beta";
strComment = strComment + "\n--------------------------------------------------------------------";
strComment = strComment + "\n1. Currency : GBPUSD";
strComment = strComment + "\n2. Time Frame : 30M";
strComment = strComment + "\n3. Broker : FXDD (recommended)";
strComment = strComment + "\n4. Trading Hour (FXDD time) : " + strTimeFrom + "-" + strTimeTo;
strComment = strComment + "\n5. EA must online before trading hours until after end hour";
strComment = strComment + "\n6. WSS9.5 EA wont draw any graph like WSS 9.4.3 FV";
strComment = strComment + "\n--------------------------------------------------------------------";
strComment = strComment + "\nCurrent Time : " + TimeToString(TimeCurrent());
strComment = strComment + "\nCurrent Signal : " + strSignal;
strComment = strComment + "\nCurrent Trend : " + strTrend;
strComment = strComment + "\n--------------------------------------------------------------------";
strComment = strComment + "\nAny questions please contact us at \nsupport@winning-solution.com";
strComment = strComment + "\n--------------------------------------------------------------------";
Comment(strComment);
}
} //Проверка на IsTesting
}
void SetOrders(string vComment, int vMagic)
{
int iTicket;
int lTimeFrom = StrToTime(strTimeFrom);
int lTimeTo = StrToTime(strTimeTo);
int TimeOpenInterval = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + strTimeFrom);
double pOpenInterval = Open[iBarShift(NULL, 0, TimeOpenInterval)];
double LevelBuy = NormalizeDouble(pOpenInterval + gi_144 * Point, Digits);
double LevelSell = NormalizeDouble(pOpenInterval - gi_144 * Point, Digits);
double SLBuy = LevelBuy - StopLoss * Point;
double SLSell = LevelSell + StopLoss * Point;
int lSpred = (Ask - Bid) / Point;
if(
CountOrders(Symbol(), OP_BUY) == 0
&& CountHistory(Symbol(), OP_BUY) == 0
&& Ask >= LevelBuy
&& Ask <= LevelBuy + lSpred
&& TimeCurrent() > lTimeFrom
&& TimeCurrent() < lTimeTo
)
{
iTicket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, SLBuy, 0, vComment, vMagic, 0, Blue);
if (iTicket < 0)
{
Print(vComment + " Error open BUY");
return;
}
Alert("WSS95: BUY " + Symbol() + "@" + DoubleToStr(Ask, Digits));
return;
}
if(
CountOrders(Symbol(), OP_SELL) == 0
&& CountHistory(Symbol(), OP_SELL) == 0
&& Bid <= LevelSell
&& Bid >= LevelSell - lSpred
&& TimeCurrent() > lTimeFrom
&& TimeCurrent() < lTimeTo
)
{
iTicket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, SLSell, 0, vComment, vMagic, 0, Red);
if (iTicket < 0)
{
Print(vComment + " Error open SELL");
return;
}
Alert("WSS95: SELL GBPUSD@" + DoubleToStr(Bid, Digits));
}
}
double CalculateMMLot()
{
double ld_0 = gd_168;
double ld_8 = gd_176;
double lLotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
if(
ld_0 < 0.0
|| ld_8 <= 0.0
|| lLotStep <= 0.0
)
{
Print("CalculateMMLot: invalid MarketInfo() results [", ld_0, ",", ld_8, ",", lLotStep, "]");
return (0);
}
if (AccountLeverage() <= 0)
{
Print("CalculateMMLot: invalid AccountLeverage() [", AccountLeverage(), "]");
return (0);
}
double ld_ret_24 = NormalizeDouble((AccountBalance() - gd_184) / gd_192 * RiskProcentage / AccountLeverage() / 10.0, 2);
ld_ret_24 = NormalizeDouble(ld_ret_24 / lLotStep, 0) * lLotStep;
if (ld_ret_24 < ld_0)
ld_ret_24 = ld_0;
if (ld_ret_24 > ld_8)
ld_ret_24 = ld_8;
return (ld_ret_24);
}
int CountOrders(string lSymbol = "", int lType = -1)
{
int lCount = 0;
int l_ord_total_16 = OrdersTotal();
for (int l_pos_20 = 0; l_pos_20 < l_ord_total_16; l_pos_20++)
{
OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES);
if(
(lSymbol == "" || OrderSymbol() == lSymbol)
&& (lType == -1 || OrderType() == lType)
&& OrderMagicNumber() == MAGIC
)
lCount++;
}
return (lCount);
}
int CountHistory(string lSymbol = "", int lType = -1)
{
int lTimeFrom = StrToTime("01:00");
int lTimeTo = StrToTime("23:00");
int lCount = 0;
int l_hist_total_24 = OrdersHistoryTotal();
for (int l_pos_28 = 0; l_pos_28 < l_hist_total_24; l_pos_28++)
{
OrderSelect(l_pos_28, SELECT_BY_POS, MODE_HISTORY);
if(
(lSymbol == "" || OrderSymbol() == lSymbol)
&& (lType == -1 || OrderType() == lType)
&& OrderOpenTime() > lTimeFrom && OrderOpenTime() < lTimeTo
&& OrderMagicNumber() == MAGIC)
lCount++;
}
return (lCount);
}
ММ и функцию "перевода времени для комментрия не "декодировал".
Все что можно было вывел во внешние переменные и убрал запрет оптимизации/тестирования.
Никакие индюки не используются.
ЗЫ. Беттта она и есть beta.