if(OrderSelect(1,SELECT_BY_POS,MODE_TRADES))
if(OrderSelect(1,SELECT_BY_POS,MODE_TRADES))
input double Lots=0.01;
void CloseOrder(double lot)
{
//...
}
if(CountTrades()>2) CloseOrder(Lots);
//+------------------------------------------------------------------+
//| DateLot.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
input int Days=15;
input double Lot=0.1;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double DaysProfit(datetime date=0)
{
double profit=0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderType()<2)
{
if(date<OrderCloseTime()) profit+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
return(profit);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double dprofit=DaysProfit(TimeCurrent()-3600*24*Days);
double pr=NormalizeDouble(dprofit*100/AccountBalance(),2);
double lot=Lot+(pr*Lot)/100;
Comment("\n Profit: ",dprofit,
"\n Procent Profit: ",pr,
"\n Lot: ",Lot,
"\n New Lot: ",lot);
}
//+------------------------------------------------------------------+
С этим лотом советник торгует день (неделю, месяц выбирается пользователем)
//+------------------------------------------------------------------+
//| DateLot.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
input string Date="12.01.2016";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double GetProfitFromDate(datetime date=0)
{
double profit=0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderType()<2)
{
if(date<OrderCloseTime()) profit+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
return(profit);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
Comment("\n Profit: ",GetProfitFromDate(StringToTime(Date)));
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| DeleteLine.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
input double Price=1.06282;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double pr=0;
for(int i=ObjectsTotal()-1;i>=0;i--)
{
pr=NormalizeDouble(ObjectGetDouble(0,ObjectName(i),OBJPROP_PRICE),Digits);
if(pr!=Price) ObjectDelete(0,ObjectName(i));
}
Comment(NormalizeDouble(ObjectGetDouble(0,ObjectName(0),OBJPROP_PRICE),Digits));
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| DeltaOrder.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
input int Delta=200;
input double KLot=2;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
struct OrdersInfo
{
int tick; // тикет
string symb; // символ
int cmd; // торговая операция
double oop; // цена открытия
double lot; // количество лотов
bool otl; // есть отложка
};
OrdersInfo ord[1];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()<2)
{
ord[i].tick=OrderTicket();
ord[i].symb=OrderSymbol();
ord[i].cmd=OrderType();
ord[i].oop=OrderOpenPrice();
ord[i].lot=OrderLots();
ord[0].otl=false;
}
}
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
int r=0;
ArrayResize(ord,OrdersTotal(),1);
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()<2)
{
if(!ord[i].otl)
{
if(OrderType()==0) r=OrderSend(NULL,5,OrderLots()*KLot,ord[0].oop-Delta*Point,3,0,0,"",0,0,Green);
if(OrderType()==1) r=OrderSend(NULL,4,OrderLots()*KLot,ord[0].oop+Delta*Point,3,0,0,"",0,0,Green);
ord[i].otl=true;
}
}
}
}
Comment("\n OOP: ",ord[0].oop,
"\n Array Size: ",ArraySize(ord),
"\n ORD: ",ord[0].otl);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| DeltaOrder.mq4 |
//| Copyright 2017, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
input int Delta=200;
input double KLot=2;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
struct OrdersInfo
{
int tick; // тикет
string symb; // символ
int cmd; // торговая операция
double oop; // цена открытия
double lot; // количество лотов
bool otl; // есть отложка
};
OrdersInfo ord[1];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
if(type==1 || type==3 || type==5)
{
clr=Red;
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
}
r=OrderSend(NULL,type,0.2,NormalizeDouble(price,Digits),0,0,0,"",0,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DelOrder()
{
bool del;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()>1) del=OrderDelete(OrderTicket());
}
}
}
return;
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
ArrayResize(ord,OrdersTotal(),1);
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()<2)
{
ord[i].tick=OrderTicket();
ord[i].symb=OrderSymbol();
ord[i].cmd=OrderType();
ord[i].oop=OrderOpenPrice();
ord[i].lot=OrderLots();
ord[i].otl=false;
if(!ord[i].otl)
{
//int r=OrderSend(NULL,OP_BUYSTOP,0.2,ord[0].oop+Delta*Point,3,0,0,"",0,0,Green);
ord[0].otl=true;
}
}
}
}
DelOrder();
Comment("\n OOP: ",ord[0].oop,
"\n Array Size: ",ArraySize(ord),
"\n ORD: ",ord[0].otl);
}
//+------------------------------------------------------------------+
AM2