//+------------------------------------------------------------------+
//| Razgon.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lot1 = 0.1; // лот 1
extern double Lot2 = 0.4; // лот 2
extern int StopLoss = 200; // лось
extern int TakeProfit = 700; // язь
extern int Slip = 30; // реквот
extern int Shift = 0; // на каком баре сигнал индикатора
extern int Magic = 123; // магик
extern string IndName="TMA with Distances";
extern string TimeFrame = "current time frame";
extern int HalfLength = 56;
extern int Price = PRICE_CLOSE;
extern double ATRMultiplier = 1.0;
extern int ATRPeriod = 100;
extern bool Interpolate = true;
datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price,double loss,double take,double lot)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(loss>0)
sl=NormalizeDouble(price+loss*_Point,_Digits);
if(take>0)
tp=NormalizeDouble(price-take*_Point,_Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(loss>0)
sl=NormalizeDouble(price-loss*_Point,_Digits);
if(take>0)
tp=NormalizeDouble(price+take*_Point,_Digits);
}
r=OrderSend(NULL,type,lot,NormalizeDouble(price,_Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades(int type=-1)
{
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 || type==-1)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double up = iCustom(NULL,0,IndName,TimeFrame,HalfLength,Price,ATRMultiplier,ATRPeriod,Interpolate,1,Shift);
double dn = iCustom(NULL,0,IndName,TimeFrame,HalfLength,Price,ATRMultiplier,ATRPeriod,Interpolate,2,Shift);
if(CountTrades(0)<1 && CountTrades(1)>0 && Ask<dn)
{
PutOrder(0,Ask,StopLoss,TakeProfit,Lot2);
}
if(CountTrades(1)<1 && CountTrades(0)>0 && Bid>up)
{
PutOrder(1,Bid,StopLoss,TakeProfit,Lot2);
}
if(t!=Time[0])
{
if(Ask<dn && MathAbs(Open[1]-Close[1])>0 && (Close[1]-Low[1])/MathAbs(Open[1]-Close[1])>3)
{
if(CountTrades(0)<1)
{
PutOrder(0,Ask,StopLoss,StopLoss,Lot1);
PutOrder(0,Ask,StopLoss,TakeProfit,Lot1);
}
}
if(Bid>up && MathAbs(Open[1]-Close[1])>0 && (High[1]-Open[1])/MathAbs(Open[1]-Close[1])>3)
{
if(CountTrades(1)<1)
{
PutOrder(1,Bid,StopLoss,StopLoss,Lot1);
PutOrder(1,Bid,StopLoss,TakeProfit,Lot1);
}
}
t=Time[0];
}
Comment("\n UP: ",NormalizeDouble(up,_Digits),
"\n DN: ",NormalizeDouble(dn,_Digits));
}
//+------------------------------------------------------------------+
Стратегия вроде верная
//+------------------------------------------------------------------+
//| Binarik5.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double KLot = 2; // увеличение лота
extern double MaxLot = 5; // максимальный лот
extern int Slip = 30; // реквот
extern int Shift = 0; // на каком баре сигнал индикатора
extern int Magic = 123; // магик
extern string Expiration = "15";
extern string IndName = "SetUp&Down_v3";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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,Lot(),NormalizeDouble(price,Digits),Slip,0,0,Expiration,Magic,0,clr);
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()<2)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Loss()
{
int loss=0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==0)
{
if(OrderClosePrice()-OrderOpenPrice()<0)
loss++;
if(OrderClosePrice()-OrderOpenPrice()>0)
break;
}
if(OrderType()==1)
{
if(OrderClosePrice()-OrderOpenPrice()>0)
loss++;
if(OrderClosePrice()-OrderOpenPrice()<0)
break;
}
}
}
}
return(loss);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=NormalizeDouble(Lots*MathPow(KLot,Loss()),2);
if(lot>MaxLot)
lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double blu=iCustom(NULL,0,IndName,0,1);
double red=iCustom(NULL,0,IndName,1,1);
if(CountTrades()<1)
{
if(blu<1111)
PutOrder(0,Ask);
if(red<1111)
PutOrder(1,Bid);
}
Comment("\n Losses: ",Loss(),
"\n Blu: ",blu,
"\n Red: ",red);
}
//+------------------------------------------------------------------+
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#property link "http://forexbig.ru"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//+------------------------------------------------------------------+
//| McGinley Dynamic indicator |
//+------------------------------------------------------------------+
#property copyright "none"
#property link "none"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Teal
#property indicator_color2 Teal
#property indicator_color3 Teal
extern int Length = 35;
extern int Delta = 333;
extern ENUM_APPLIED_PRICE Price = PRICE_MEDIAN;
extern int Power = 1;
double buff[];
double up[];
double dn[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,buff);
SetIndexBuffer(1,up);
SetIndexBuffer(2,dn);
string PriceType;
switch(Price)
{
case PRICE_CLOSE:
PriceType = "Close";
break; // 0
case PRICE_OPEN:
PriceType = "Open";
break; // 1
case PRICE_HIGH:
PriceType = "High";
break; // 2
case PRICE_LOW:
PriceType = "Low";
break; // 3
case PRICE_MEDIAN:
PriceType = "Median";
break; // 4
case PRICE_TYPICAL:
PriceType = "Typical";
break; // 5
case PRICE_WEIGHTED:
PriceType = "Weighted";
break; // 6
}
Length = MathMax(Length,1);
IndicatorShortName(" McGinley Dynamic ("+Length+","+PriceType+")");
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
if(counted_bars<0)
return(-1);
if(counted_bars>0)
counted_bars--;
limit = MathMin(Bars-counted_bars,Bars-1);
for(i=limit; i >= 0; i--)
{
double price = iMA(NULL,0,1,0,MODE_SMA,Price,i);
if(i>(Bars-2))
{
buff[i] = price;
continue;
}
double denom = Length*MathPow(price/buff[i+1],Power);
if(denom != 0)
buff[i] = buff[i+1]+(price-buff[i+1])/denom;
else
buff[i] = buff[i+1];
up[i]=buff[i]+Delta*_Point;
dn[i]=buff[i]-Delta*_Point;
}
return(0);
}
//+------------------------------------------------------------------+
AM2