Wall Street Robot
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «wallstreet.mq4» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Wall Street Robot — это торговый советник для MetaTrader 4, написанный на языке MQL4. Советник предназначен для автоматической торговли на таймфрейме M15 и использует набор технических индикаторов для анализа ценовых данных и принятия решений об открытии и закрытии позиций.
Программа поддерживает фильтрацию по спреду, автоматическое управление размером лота (AutoMM) и режим восстановления позиций (Recovery Mode). Все ордера маркируются магическим числом для удобной идентификации и управления.
Советник ведёт журналирование операций, выводит информацию о текущих параметрах торговли на график, а также включает защиту от недостатка средств на счёте и обработку повторных котировок (requote) при открытии и закрытии позиций.
Настройки программы
| Настройка | Описание |
|---|---|
| MAGIC | Магическое число для идентификации ордеров, открытых советником. |
| Stime | Количество попыток выполнения торговой операции при обработке повторных котировок. |
| Sat | Параметр, определяющий смещение в пунктах для модификации стоп-лосса при достижении защищённой прибыли. |
| MaxLots | Максимально допустимый размер лота для торговых операций. |
| MaxSpread | Максимально допустимый спред в пунктах. При превышении этого значения советник не открывает новые позиции. |
| Risk | Параметр риска, используемый при расчёте размера лота в режиме восстановления позиций. |
Поиск по коду файла
extern int MAGIC = 31;
extern int Stime = 3;
extern int Sat = 1;
extern double MaxLots = 1.0;
extern int MaxSpread = 4;
extern double Risk = 100.0;
string Symbol_Op = "EURUSD m15";
datetime Date = D'12.05.2011'; //--- ������ ����� ��� ����, ����� ������ �� ����� ���� ����������� (���� ���������� �������)
int TakeProfit = 26; //--- (10 2 60)
int StopLoss = 120; //--- (100 10 200)
bool UseStopLevels = TRUE; //--- ��������� �������� �������. ���� ���������, �� �������� ������ ����������� ����� � �����.
bool IsMarketExecution = FALSE; //--- ��������� ��������� ���������� �������� ������� (������� ���������, ����� ������������)
int SecureProfitTriger = 10; //--- (10 2 30)
int MaxLossPoints = -65; //--- (-200 5 -20) ������������ �������� ��� �������� ������� Buy � Sell ��� ��������� ������� (��� �������� ������ �� - MaxLossPoints ��� ������ (�������� ������� 0), ����� ���������)
string _MM = "��������� MM";
bool RecoveryMode = FALSE; //--- ��������� ������ �������������� �������� (���������� ���� ���� �������� ����-����)
double FixedLot = 0.1; //--- ������������� ����� ����
double AutoMM = 0.2; //--- �� ���������� ���� AutoMM > 0. ������� �����. ��� RecoveryMode = FALSE, ������ ����� ������ ��� ��������.
int MaxAnalizCount = 50; //--- ����� �������� ����� ������� ��� �������(������������ ��� RecoveryMode = True)
double MultiLotPercent = 1.1; //--- ����������� ��������� ���� (������������ ��� RecoveryMode = True)
string _Periods = "������� �����������";
int iMA_Period = 75; //--- (60 5 100)
int iCCI_Period = 18; //--- (10 2 30)
int iATR_Period = 14; //--- (10 2 30) (!) ����� �� ������
int iWPR_Period = 11; //--- (10 1 20)
string _Add_Op = "����������� ��������� �����������";
string _AddOpenFilters = "---";
int FilterATR = 6; //--- (0 1 10) �������� �� ���� �� ATR ��� Buy � Sell (if (iATR_Signal <= FilterATR * pp) return (0);) (!) ����� �� ������
double iCCI_OpenFilter = 150; //--- (100 10 400) ������ �� iCCI ��� Buy � Sell. ��� ����������� ��� JPY ������������ ������ �� ������� (100 50 4000)
string _OpenOrderFilters = "---";
int iMA_Filter_Open_a = 15; //--- (4 2 20) ������ �� ��� �������� Buy � Sell (�����)
int iMA_Filter_Open_b = 39; //--- (14 2 50) ������ �� ��� �������� Buy � Sell (�����)
int iWPR_Filter_Open_a = -99; //--- (-100 1 0) ������ WPR ��� �������� Buy � Sell
int iWPR_Filter_Open_b = -95; //--- (-100 1 0) ������ WPR ��� �������� Buy � Sell
string _CloseOrderFilters = "---";
int Price_Filter_Close = 14; //--- (10 2 20) ������ ���� �������� ��� �������� Buy � Sell (�����)
int iWPR_Filter_Close = -19; //--- (0 1 -100) ������ WPR ��� �������� Buy � Sell
string _Add = "����������� ���������";
bool LongTrade = TRUE; //--- ����������� ������� �������
bool ShortTrade = TRUE; //--- ����������� �������� �������
double Slippage = 2;
bool WriteLog = TRUE; //--- //--- ��������� ����������� ���� � ���������.
bool WriteDebugLog = TRUE; //--- ��������� ����������� ���� �� ������� � ���������.
bool PrintLogOnChart = TRUE; //--- ��������� ������������ �� ������� (��� ������������ ����������� �������������)
double pp;
int pd;
double cf;
string EASymbol; //--- ������� ������
double CloseSlippage = 3; //--- ��������������� ��� �������� ������
int SP;
int CloseSP;
int MaximumTrades = 1;
double NDMaxSpread; //--- ������������ ����� ����� �������
bool CheckSpreadRule; //--- ������� ��� �������� ������ ����� ��������� (������������� ������������ ��������� � ����������� ������)
string OpenOrderComment = "WSFR v3.8.4 FINAL";
int RandomOpenTimePercent = 0; //--- ������������ ��� ������� ������ ������� ���������, ����������� ��������� �����. ���������� � ��������.
double MinLot = 0.01;
double MaxLot = 0.01;
double LotStep = 0.01;
int LotValue = 100000;
double FreeMargin = 1000.0;
double LotPrice = 1;
double LotSize;
int iWPR_Filter_OpenLong_a;
int iWPR_Filter_OpenLong_b;
int iWPR_Filter_OpenShort_a;
int iWPR_Filter_OpenShort_b;
int iWPR_Filter_CloseLong;
int iWPR_Filter_CloseShort;
color OpenBuyColor = Blue;
color OpenSellColor = Red;
color CloseBuyColor = DodgerBlue;
color CloseSellColor = DeepPink;
void init() {
// код доступен только после оплаты
}
int deinit() {
if (ObjectFind("BKGR") >= 0) ObjectDelete("BKGR");
if (ObjectFind("BKGR2") >= 0) ObjectDelete("BKGR2");
if (ObjectFind("BKGR3") >= 0) ObjectDelete("BKGR3");
if (ObjectFind("BKGR4") >= 0) ObjectDelete("BKGR4");
if (ObjectFind("LV") >= 0) ObjectDelete("LV");
return (0);
}
int start() {
// код доступен только после оплаты
}
void Scalper() {
if (MaxSpreadFilter()) {
if (!CheckSpreadRule && WriteDebugLog) {
Print("�������� ������ �������� ��-�� �������� ������.");
Print("������� ����� = ", DoubleToStr((Ask - Bid) / pp, 1), ", MaxSpread = ", DoubleToStr(MaxSpread, 1));
Print("������� ����� ��������� �����, ����� ����� ������ ����������.");
}
CheckSpreadRule = TRUE;
} else {
CheckSpreadRule = FALSE;
if (OpenLongSignal() && OpenTradeCount() && LongTrade) OpenPosition(OP_BUY);
if (OpenShortSignal() && OpenTradeCount() && ShortTrade) OpenPosition(OP_SELL);
} //--- �������� if (MaxSpreadFilter)
}
int OpenPosition(int OpType) {
int RandomOpenTime; //--- �������� �� ������� �� ��������
color OpenColor; //--- ���� �������� �������. ���� Buy �� �������, ���� Sell �� �������
int OpenOrder = 0; //--- �������� �������
int OpenOrderError; //--- ������ ��������
string OpTypeString; //--- �������������� ���� ������� � ��������� ��������
double OpenPrice; //--- ���� ��������
int maxtry = Stime;
int lasterror = 0;
double price = OpenPrice;
double TP, SL;
double OrderTP = NormalizeDouble (TakeProfit * pp , pd); //--- ����������� ����-������ � ��� Points
double OrderSL = NormalizeDouble (StopLoss * pp , pd); //--- ����������� ����-���� � ��� Points
if (RandomOpenTimePercent > 0) {
MathSrand(TimeLocal());
RandomOpenTime = MathRand() % RandomOpenTimePercent;
if (WriteLog) {
Print("DelayRandomiser: �������� ", RandomOpenTime, " ������.");
}
Sleep(1000 * RandomOpenTime);
} //--- �������� if (RandomOpenTimePerc
double OpenLotSize = LotSize; //--- ������ ������ �������
if (AccountFreeMarginCheck(EASymbol, OpType, OpenLotSize) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */) {
if (WriteDebugLog) {
Print("��� �������� ������ ������������ ��������� �����.");
Comment("��� �������� ������ ������������ ��������� �����.");
}
return (-1);
} //--- �������� if (AccountFreeMarginCheck
RefreshRates();
if (OpType == OP_BUY) {
OpenPrice = NormalizeDouble(Ask, Digits);
OpenColor = OpenBuyColor;
if (UseStopLevels) { //--- ���� �������� ����-������ (����-���� � ����-������)
TP = NormalizeDouble(OpenPrice + OrderTP, Digits); //--- �� ����������� ����-������
SL = NormalizeDouble(OpenPrice - OrderSL, Digits); //--- � ����-����
} else {TP = 0; SL = 0;}
} else {
OpenPrice = NormalizeDouble(Bid, Digits);
OpenColor = OpenSellColor;
if (UseStopLevels) {
TP = NormalizeDouble(OpenPrice - OrderTP, Digits);
SL = NormalizeDouble(OpenPrice + OrderSL, Digits);
}
else {TP = 0; SL = 0;}
}
if (IsMarketExecution && UseStopLevels)
{
OpenOrder = OrderSend(EASymbol, OpType, OpenLotSize, OpenPrice, SP, 0, 0, OpenOrderComment, MAGIC, 0, OpenColor);
if (OpenOrder > 0)
{
OrderModify(OpenOrder,OrderOpenPrice(),SL,TP,0);
return(OpenOrder);
}
}
else
{
OpenOrder = OrderSend(EASymbol, OpType, OpenLotSize, OpenPrice, SP, SL, TP, OpenOrderComment, MAGIC, 0, OpenColor);
if (OpenOrder > 0) return(OpenOrder);
}
if ((OpType != OP_BUY) && (OpType != OP_SELL)) return(OpenOrder);
if (OpenOrder < 0) { //--- ���� ����� �� ��������, ��
OpenOrderError = GetLastError(); //--- ���������� ������
if (WriteDebugLog) {
if (OpType == OP_BUY) OpTypeString = "OP_BUY";
else OpTypeString = "OP_SELL";
Print("��������: OrderSend(", OpTypeString, ") ������ = ", ErrorDescription(OpenOrderError)); //--- ��� ������ �� �������
} //--- �������� if (WriteDebugLog)
}
lasterror = GetLastError();
if ((OpenOrder < 0) && ((lasterror == 135) || (lasterror == 138) || (lasterror == 146)))
{
Print("Requote. Error" + lasterror + ". Ticket: " + OpenOrder);
}
else
{
return(OpenOrder);
}
for (int attempt = 1; attempt <= maxtry; attempt++)
{
RefreshRates();
if (OpType == OP_BUY)
{
if (Ask <= price)
{
if (IsMarketExecution && UseStopLevels)
{
OpenOrder = OrderSend(EASymbol, OpType, OpenLotSize, NormalizeDouble(Ask,Digits), SP, 0, 0, OpenOrderComment, MAGIC, 0, OpenColor);
if (OpenOrder > 0)
{
OrderModify(OpenOrder,OrderOpenPrice(),SL,TP,0);
return(OpenOrder);
}
}
else
{
OpenOrder = OrderSend(EASymbol, OpType, OpenLotSize, NormalizeDouble(Ask,Digits), SP, SL, TP, OpenOrderComment, MAGIC, 0, OpenColor);
if (OpenOrder > 0) return(OpenOrder);
}
if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(OpenOrder);
Print("Requote. " + "Attempt " + (attempt + 1));
continue;
}
}
if (OpType == OP_SELL)
{
if (Bid >= price)
{
if (IsMarketExecution && UseStopLevels)
{
OpenOrder = OrderSend(EASymbol, OpType, OpenLotSize, NormalizeDouble(Bid,Digits), SP, 0, 0, OpenOrderComment, MAGIC, 0, OpenColor);
if (OpenOrder > 0)
{
OrderModify(OpenOrder,OrderOpenPrice(),SL,TP,0);
return(OpenOrder);
}
}
else
{
OpenOrder = OrderSend(EASymbol, OpType, OpenLotSize, NormalizeDouble(Bid,Digits), SP, SL, TP, OpenOrderComment, MAGIC, 0, OpenColor);
if (OpenOrder > 0) return(OpenOrder);
}
if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(OpenOrder);
Print("Requote. " + "Attempt " + (OpenOrder + 1));
}
}
}
return(-1);
}
void ModifyOrders() {
bool TicketModify; //--- �������� ������
int total = OrdersTotal() - 1;
int ModifyError = GetLastError();
int ModifyTicketID = OrderTicket();
string ModifyOrderType = OrderType();
for (int i = total; i >= 0; i--) { //--- ������� �������� �������
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (WriteDebugLog) Print("��������� ������ �� ����� ������� ������. �������: ", ErrorDescription(ModifyError));
} else {
if (OrderType() == OP_BUY) {
if (OrderMagicNumber() == MAGIC && OrderSymbol() == EASymbol) {
if (Bid - OrderOpenPrice() > SecureProfitTriger * pp && MathAbs(OrderOpenPrice() + Sat * pp - OrderStopLoss()) >= Point) {
TicketModify = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() + Sat * pp, Digits), OrderTakeProfit(), 0, Blue);
if (TicketModify < 0)
if (WriteDebugLog) Print("��������� ������ �� ����� ����������� ������ (", ModifyOrderType, ",", ModifyTicketID, "). �������: ", ErrorDescription(ModifyError));
}
}
} //--- �������� if (OrderType() == OP_BUY)
if (OrderType() == OP_SELL) {
if (OrderMagicNumber() == MAGIC && OrderSymbol() == EASymbol) {
if (OrderOpenPrice() - Ask > SecureProfitTriger * pp && MathAbs(OrderOpenPrice() - Sat * pp - OrderStopLoss()) >= Point) {
TicketModify = OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() - Sat * pp, Digits), OrderTakeProfit(), 0, Red);
if (TicketModify < 0)
if (WriteDebugLog) Print("��������� ������ �� ����� ����������� ������ (", ModifyOrderType, ",", ModifyTicketID, "). �������: ", ErrorDescription(ModifyError));
}
}
} //--- �������� if (OrderType() == OP_SELL)
}
} //--- �������� for (int i = total - 1; i >= 0; i--)
}
void CloseOrders() {
int total = OrdersTotal() - 1;
int SelectCloseError = GetLastError();
for (int i = total; i >= 0; i--) { //--- ������� �������� �������
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (WriteDebugLog) Print("��������� ������ �� ����� ������� ������. �������: ", ErrorDescription(SelectCloseError));
} else {
if (OrderType() == OP_BUY) {
if (OrderMagicNumber() == MAGIC && OrderSymbol() == EASymbol) {
if (Bid >= OrderOpenPrice() + TakeProfit * pp || Bid <= OrderOpenPrice() - StopLoss * pp || CloseLongSignal(OrderOpenPrice(), ExistPosition())) {
CloseOrder(OrderTicket(),Bid);
}
}
} //--- �������� if (OrderType() == OP_BUY)
if (OrderType() == OP_SELL) {
if (OrderMagicNumber() == MAGIC && OrderSymbol() == EASymbol) {
if (Ask <= OrderOpenPrice() - TakeProfit * pp || Ask >= OrderOpenPrice() + StopLoss * pp || CloseShortSignal(OrderOpenPrice(), ExistPosition())) {
CloseOrder(OrderTicket(),Ask);
}
}
} //--- �������� if (OrderType() == OP_SELL)
}
} //--- �������� for (int i = total - 1; i >= 0; i--) {
}
int CloseOrder(int ticket, double prce) {
double price;
int slippage;
double p = prce;
int maxtry = Stime;
color CloseColor;
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
int ordtype = OrderType();
if (ordtype == OP_BUY) {price = NormalizeDouble(Bid,Digits); CloseColor = CloseBuyColor;}
if (ordtype == OP_SELL) {price = NormalizeDouble(Ask,Digits); CloseColor = CloseSellColor;}
if (MathAbs(OrderTakeProfit() - price) <= MarketInfo(Symbol(),MODE_FREEZELEVEL) * Point) return(0); //--- �������� ������� ��������� ����-�������
if (MathAbs(OrderStopLoss() - price) <= MarketInfo(Symbol(),MODE_FREEZELEVEL) * Point) return(0); //--- �������� ������� ��������� ����-�����
if (OrderClose(ticket,OrderLots(),price,CloseSlippage,CloseColor)) return(1); //--- ���� ����� ������ �������, �� ���������� 1)
if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(0); //--- ���� ��� �� 0
Print("Requote");
for (int attempt = 1; attempt <= maxtry; attempt++)
{
RefreshRates();
if (ordtype == OP_BUY)
{
slippage = MathRound((Bid - p) / pp);
if (Bid >= p)
{
Print("Closing order. Attempt " + (attempt + 1));
if (OrderClose(ticket,OrderLots(),NormalizeDouble(Bid,Digits),slippage,CloseColor)) return(1);
if (!((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146))) continue;
return(0);
}
}
if (ordtype == OP_SELL)
{
slippage = MathRound((p - Ask) / pp);
if (p >= Ask)
{
Print("Closing order. Attempt " + (attempt + 1));
if (OrderClose(ticket,OrderLots(),NormalizeDouble(Ask,Digits),slippage,CloseColor)) return(1);
if ((GetLastError() != 135) && (GetLastError() != 138) && (GetLastError() != 146)) return(0);
}
}
}
}
bool OpenLongSignal() {
bool result = false;
bool result1 = false;
bool result2 = false;
bool result3 = false;
double iClose_Signal = iClose(NULL, PERIOD_M15, 1);
double iMA_Signal = iMA(NULL, PERIOD_M15, iMA_Period, 0, MODE_SMMA, PRICE_CLOSE, 1);
double iWPR_Signal = iWPR(NULL, PERIOD_M15, iWPR_Period, 1);
double iATR_Signal = iATR(NULL, PERIOD_M15, iATR_Period, 1);
double iCCI_Signal = iCCI(NULL, PERIOD_M15, iCCI_Period, PRICE_TYPICAL, 1);
double iMA_Filter_a = NormalizeDouble(iMA_Filter_Open_a*pp,pd);
double iMA_Filter_b = NormalizeDouble(iMA_Filter_Open_b*pp,pd);
double BidPrice = Bid; //--- (iClose_Signal >= BidPrice) ��������� ���� ������ � Bid (� �� � Ask, ��� ������ ����), ��� ��� ���� �������� ����� iClose_Signal ����������� �� ��������� �������� Bid
if (iATR_Signal <= FilterATR * pp) return (0);
if (iClose_Signal - iMA_Signal > iMA_Filter_a && iClose_Signal - BidPrice >= - cf && iWPR_Filter_OpenLong_a > iWPR_Signal) result1 = true;
else result1 = false;
if (iClose_Signal - iMA_Signal > iMA_Filter_b && iClose_Signal - BidPrice >= - cf && - iCCI_OpenFilter > iCCI_Signal) result2 = true;
elsПоказано первые 50% кода (символов: 28702)
Открыть по тарифу
Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.
Разовая покупка файла
На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.
Зачем нужен email? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.