#property copyright "Copyright © 2015, AM2"
#property link "www.forexsystems.biz"
#property description "Simple expert advisor"
//--- Inputs
extern int Stavka = 5; // ставка в валюте
extern string Expiration = "BO exp:60"; // время истечения в секундах
extern int Magic = 111; // магик
extern double KLot = 2.8; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern double Win = 0.7; // прибыль со ставки
double pr=0,st=Stavka;
int UP=0,DN=0;
datetime t=0;
//+------------------------------------------------------------------+
//| 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;
//--- sell
if(High[1]<High[2] && High[3]<High[2])
{
res=OrderSend(Symbol(),OP_SELL,Stavka,Bid,3,0,0,Expiration,Magic,0,Red);
return;
}
//--- buy
if(Low[1]>Low[2] && Low[3]>Low[2])
{
res=OrderSend(Symbol(),OP_BUY,Stavka,Bid,3,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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Stavka;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
pr-=st;
st*=KLot;
}
if(OrderProfit()>0)
{
pr+=st*Win;
st=Stavka;
}
}
if(lot>MaxLot)lot=Stavka;
return(lot);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
}
//+------------------------------------------------------------------+
<code>//--- Inputs extern double Stavka = 5; // ставка в валюте extern string Expiration = "BO exp:60"; // время истечения в секундах extern int Magic = 111; // магик extern bool martingale = false;//////////----------- Мартингейл.Увеличение лота при убытке extern double multiplier = 2.8;//////////////----------- множитель лота при убытке double mlots=0,lastprofit,lastlot; //+------------------------------------------------------------------+ //| 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() { // Martingale *************************************************************************************************************** if(OrdersHistoryTotal()>0){ for(int i=0;i<OrdersHistoryTotal();i++){ if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)){ if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && (OrderType()==OP_BUY || OrderType()==OP_SELL)){ lastprofit=OrderProfit(); lastlot=OrderLots(); } } } } mlots=0; if(martingale && lastprofit<0)mlots=lastlot*multiplier;else mlots=Stavka; int res; //--- sell if(High[1]<High[2] && High[3]<High[2]) { res=OrderSend(Symbol(),OP_SELL,mlots,Bid,3,0,0,Expiration,Magic,0,Red); return; } //--- buy if(Low[1]>Low[2] && Low[3]>Low[2]) { res=OrderSend(Symbol(),OP_BUY,mlots,Bid,3,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(); } //+------------------------------------------------------------------+ </code>
//--- Inputs
extern double Stavka = 5; // ставка в валюте
extern string Expiration = "BO exp:60"; // время истечения в секундах
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;
//--- sell
if(High[1]<High[2] && High[3]<High[2])
{
res=OrderSend(Symbol(),OP_SELL,Stavka,Bid,3,0,0,Expiration,Magic,0,Red);
return;
}
//--- buy
if(Low[1]>Low[2] && Low[3]>Low[2])
{
res=OrderSend(Symbol(),OP_BUY,Stavka,Bid,3,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();
}
//+------------------------------------------------------------------+
maksGruv