
//+------------------------------------------------------------------+
//| Opener.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double PlusLot = 0.01; //
extern int StopLoss = 500; // лось
extern int TakeProfit = 500; // язь
extern int MaxSell = 10; //
extern int MaxBuy = 10; //
extern int Step = 100; //
extern int BuySell = 0; // 1-buy 2-sell 0-off
extern int Slip = 30; // реквот
extern int Magic = 0; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| 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;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
}
r=OrderSend(NULL,type,Lot()+PlusLot,NormalizeDouble(price,Digits),Slip,0,0,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double FindLastBuyPrice()
{
int oticket,ticketNumber=0;
double oprice=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
oprice=OrderOpenPrice();
}
}
}
}
return(oprice);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double FindLastSellPrice()
{
int oticket,ticketNumber=0;
double oprice=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
oprice=OrderOpenPrice();
}
}
}
}
return(oprice);
}
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
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()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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()<2) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Type()
{
int type=0;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
type=OrderType();
}
}
return(type);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=0;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
lot=OrderLots();
}
}
return(lot);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(IsTesting())
{
if(CountTrades()<1 && BuySell==1) PutOrder(0,Ask);
if(CountTrades()<1 && BuySell==2) PutOrder(1,Bid);
}
if(CountTrades()>0 && t!=Time[0])
{
if(Type()==0 && CountOrders(0)<MaxBuy && (FindLastBuyPrice()-Ask)/Point>=Step)PutOrder(0,Ask);
if(Type()==1 && CountOrders(1)<MaxBuy && (Bid-FindLastSellPrice())/Point>=Step)PutOrder(1,Bid);
t=Time[0];
}
}
//+------------------------------------------------------------------+
Только лишь ради справедливости — полтора часа)))
Уже запилено))) Осталось погонять и принять)))
//+------------------------------------------------------------------+
//| BuySell.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color1 Lime
#property indicator_color2 Red
input int MAPeriod = 20;
input int RSIPeriod = 4;
input int RSILevel = 44;
//--- buffers
double UP[];
double DN[];
bool b=true,s=true;
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,UP);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,DN);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
for(int i=1; i<rates_total-prev_calculated; i++)
{
double ma1 = iMA(NULL,0,MAPeriod,0,0,0,i);
double ma2 = iMA(NULL,0,MAPeriod,0,0,0,i+1);
double rsi = iRSI(NULL,0,RSIPeriod,0,i);
double sar = iSAR(NULL,0,0.02,0.2,i);
if(ma1>ma2 && rsi>100-RSILevel && sar<Bid && b)
{
UP[i]=low[i];
b=false;
s=true;
}
if(ma1<ma2 && rsi<RSILevel && sar>Bid && s)
{
DN[i]=high[i];
s=false;
b=true;
}
}
if(t!=Time[0])
{
if(UP[1]<1000) Alert(Symbol()+" UP Signal!");
if(DN[1]<1000) Alert(Symbol()+" DN Signal!");
t=Time[0];
}
Comment("\n UP:",UP[1],
"\n DN:",DN[1]);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
strategy4you.ru/strategii-foreks-na-osnove-skolzyashhix-srednix/strategy-*spam*.html
www.youtube.com/watch?feature=player_embedded&v=YJmTWS89kzE
AM2