//+------------------------------------------------------------------+
//| CloseCandle.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
PutLabel("TimeLabel","Выключи меня!",150,20,Red);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Comment("");
ObjectsDeleteAll(0,OBJ_LABEL);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutLabel(string name,string text,int x,int y,color clr)
{
//--- создадим текстовую метку
ObjectCreate(0,name,OBJ_LABEL,0,0,0);
//--- установим координаты метки
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
//--- установим текст
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,15);
//--- установим цвет
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
while(ObjectFind(0,"TimeLabel")!=-1)
{
Comment("\n Время до закрытия свечи: ",TimeToString(Time[0]+Period()*60-TimeCurrent(),TIME_SECONDS),
"\n Время закрытия свечи: ",TimeToString(Time[0]+Period()*60,TIME_SECONDS),
"\n Текущее Время: ",TimeToString(TimeCurrent(),TIME_SECONDS));
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Option.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
//--- Inputs
extern double Stavka = 5; // ставка в валюте
extern string Expiration = "5"; // время истечения в минутах
extern int Magic = 111; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void OpenPos()
{
int res;
double bid=MarketInfo(OrderSymbol(),MODE_BID);
double ask=MarketInfo(OrderSymbol(),MODE_ASK);
//--- sell
if(High[1]<High[2] && High[3]<High[2])
{
res=OrderSend(Symbol(),OP_SELL,Stavka,bid,0,0,0,Expiration,Magic,0,Red);
return;
}
//--- buy
if(Low[1]>Low[2] && Low[3]>Low[2])
{
res=OrderSend(Symbol(),OP_BUY,Stavka,ask,0,0,0,Expiration,Magic,0,Blue);
return;
}
//---
}
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1) OpenPos();
Comment("\n ");
//---
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| LorikSema.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
//--- Inputs
extern int Procent = 75; // процент прибыли от ставки
extern double Stavka = 5; // ставка в валюте
extern string Expiration = "5"; // время истечения в минутах
extern int Magic = 111; // магик
int LastBars;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void OpenPos()
{
int res;
double BrownUP=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",1,1);
double BrownDN=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",0,1);
double RedUP=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",3,1);
double RedDN=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",2,1);
double YelUP=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",5,1);
double YelDN=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",4,1);
double bid=MarketInfo(OrderSymbol(),MODE_BID);
double ask=MarketInfo(OrderSymbol(),MODE_ASK);
//--- sell
if(YelUP>0 || RedUP>0)
{
res=OrderSend(Symbol(),OP_SELL,Stavka,bid,0,0,0,Expiration,Magic,0,Red);
return;
}
//--- buy
if(YelDN>0 || RedDN>0)
{
res=OrderSend(Symbol(),OP_BUY,Stavka,ask,0,0,0,Expiration,Magic,0,Blue);
return;
}
//---
}
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
void CloseAll()
{
int err;
bool cl=true;
double bid,ask;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
bid=MarketInfo(OrderSymbol(),MODE_BID);
ask=MarketInfo(OrderSymbol(),MODE_ASK);
if(OrderType()==OP_BUY) cl=OrderClose(OrderTicket(),OrderLots(),bid,0,Blue);
if(OrderType()==OP_SELL) cl=OrderClose(OrderTicket(),OrderLots(),ask,0,Red);
if(cl==false)
{
err=GetLastError();
Print("ОШИБКА УДАЛЕНИЯ ОРДЕРОВ: ",err);
} else {
RefreshRates();
}
}
}
Sleep(1000);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Profit()
{
int orders=OrdersHistoryTotal();
double profit=0;
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("Error in history!");
break;
}
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
continue;
double lot=OrderLots();
if(OrderProfit()>0) profit=profit+(lot*Procent/100);
if(OrderProfit()<0) profit=profit-lot;
}
return(profit);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Losses()
{
int orders=OrdersHistoryTotal();
int losses=0;
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("Error in history!");
break;
}
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
continue;
//---
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
return(losses);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
double BrownUP=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",1,1);
double BrownDN=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",0,1);
double RedUP=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",3,1);
double RedDN=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",2,1);
double YelUP=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",5,1);
double YelDN=iCustom(Symbol(),PERIOD_M5,"3_Level_ZZ_Semafor",4,1);
if(CountTrades()<1)
{
OpenPos();
LastBars=Bars(NULL,0);
}
if(Bars(NULL,0)>LastBars)
{
CloseAll();
}
Comment("\n BrownUP ",BrownUP,
"\n BrownDN ",BrownDN,
"\n RedUP ",RedUP,
"\n RedDN ",RedDN,
"\n YelUP ",YelUP,
"\n YelDN ",YelDN,
"\n Loss ",Losses(),
"\n Profit ",Profit());
//---
}
//+------------------------------------------------------------------+
Мне будет намного проще работать со своим кодом.
AM2