//+------------------------------------------------------------------+
//| Renko.mq4 |
//| Copyright © 2014, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2014, AM2"
#property link "http://www.forexsystems.biz"
#property description "indalekseifx Directional Line expert advisor"
//--- Inputs
extern double StopLoss = 2000; // стоп лосс ордера
extern double TakeProfit = 2000; // тейк профит ордера
extern double Lots = 0.1; // объем позиции
//----
extern int Amplitude = 2; // период средней indalekseifx Directional Line
extern int shift = 2; // смещение средней
//----
extern int FastPeriod = 12; // период быстрого макди
extern int SlowPeriod = 26; // период медленного макди
extern int SignalPeriod = 9; // период сигнального макди
//----
extern int DistancePoints = 1; // дистанция трала
extern int Trail = 1; // 0-трал выключен, 1- включен
extern int MACDAC = 0; // включение макди(1-включен,0-отключен)
extern int MAGIC = 2014; // магик
extern bool AllowLoss = FALSE;
int AccuracyPoints = 1;
double SARstep = 0.02;
double SARmaximum = 0.2;
int DealResult;
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
int res,pos;
//--- get Moving Average
double indalekseifxDeepSkyBlue=iCustom(Symbol(),0,"indalekseifx",Amplitude,1,1);
double indalekseifxTomato=iCustom(Symbol(),0,"indalekseifx",Amplitude,0,1);
double MACDGreen=iCustom(Symbol(),0,"MACDTraditional",FastPeriod,SlowPeriod,SignalPeriod,1,1);
double MACDRed=iCustom(Symbol(),0,"MACDTraditional",FastPeriod,SlowPeriod,SignalPeriod,0,1);
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
{
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
{
if(OrderType()==OP_BUY) pos++;
if(OrderType()==OP_SELL) pos++;
}
}
}
//--- sell conditions
if(MACDAC==1)
{
if(indalekseifxDeepSkyBlue>indalekseifxTomato && MACDGreen<MACDRed && pos<1 && (LastDealResult()==0 || LastDealResult()==1))
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,fND(Bid+StopLoss*Point),fND(Bid-TakeProfit*Point),"",MAGIC,0,Tomato);
if(res<0)
{
Print("Order Sell error: ",GetLastError());
}
else
Print("OK Order Sell");
return;
}
//--- buy conditions
if(indalekseifxTomato>indalekseifxDeepSkyBlue && MACDGreen>MACDRed && pos<1 && (LastDealResult()==0 || LastDealResult()==2))
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,fND(Ask-StopLoss*Point),fND(Ask+TakeProfit*Point),"",MAGIC,0,DeepSkyBlue);
if(res<0)
{
Print("Order Buy error: ",GetLastError());
}
else
Print("OK Order Buy");
return;
}
}
else
{
if(indalekseifxDeepSkyBlue>indalekseifxTomato && pos<1 && (LastDealResult()==0 || LastDealResult()==1))
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MAGIC,0,Tomato);
if(res<0)
{
Print("Order Sell error: ",GetLastError());
}
else
Print("OK Order Sell");
return;
}
//--- buy conditions
if(indalekseifxTomato>indalekseifxDeepSkyBlue && pos<1 && (LastDealResult()==0 || LastDealResult()==2))
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,fND(Ask-StopLoss*Point),fND(Ask+TakeProfit*Point),"",MAGIC,0,DeepSkyBlue);
if(res<0)
{
Print("Order Buy error: ",GetLastError());
}
else
Print("OK Order Buy");
return;
}
}
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
//--- get Moving Average
double indalekseifxDeepSkyBlue=iCustom(Symbol(),0,"indalekseifx",Amplitude,1,shift);
double indalekseifxTomato=iCustom(Symbol(),0,"indalekseifx",Amplitude,0,shift);
//---
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
//--- check order type
if(OrderType()==OP_BUY)
{
if(indalekseifxDeepSkyBlue>indalekseifxTomato)
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
if(OrderType()==OP_SELL)
{
if(indalekseifxTomato>indalekseifxDeepSkyBlue)
{
if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
}
//---
}
//+------------------------------------------------------------------+
bool NewBar()
{
static datetime lastbar = 0;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return (true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
int LastDealResult()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
//--- check order type
if(OrderType()==OP_BUY)
{
DealResult=1;
break;
}
if(OrderType()==OP_SELL)
{
DealResult=2;
break;
}
Print("Result of last deal: ",DealResult);
}
return(DealResult);
}
//+------------------------------------------------------------------+
double fND(double d, int n=-1)
{
if (n<0) return(NormalizeDouble(d, Digits));
return(NormalizeDouble(d, n));
}
//+------------------------------------------------------------------+
void trail()
{
double Distance = DistancePoints*Point;
double Accuracy = AccuracyPoints*Point;
double StopCurrent = 0;
double StopRequired = 0;
double StopAllowed = 0;
double StopSet = 0;
double Spread = MarketInfo(Symbol(),MODE_SPREAD)*Point;
double Minimum_Distance = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;
bool mod;
for(int i=0;i<OrdersTotal();i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==FALSE) break;
if (OrderSymbol()==Symbol())
{
StopCurrent=OrderStopLoss();
if ((OrderType()==OP_BUY) && (Close[0]>iSAR(NULL,0,SARstep,SARmaximum,0)))
{
StopRequired=iSAR(NULL,0,SARstep,SARmaximum,0)-Distance;
StopAllowed=Close[0]-Minimum_Distance;
StopSet=MathMin(StopAllowed, StopRequired);
if ((StopSet > StopCurrent+Accuracy) && (StopRequired >= OrderOpenPrice()||AllowLoss))
mod=OrderModify(OrderTicket(),OrderOpenPrice(),StopSet,OrderTakeProfit(),0);
}
if ((OrderType()==OP_SELL) && (Close[0]<iSAR(NULL,0,SARstep,SARmaximum,0)))
{
StopRequired=iSAR(NULL,0,SARstep,SARmaximum,0)+Spread+Distance;
StopAllowed=Close[0]+Spread+Minimum_Distance;
StopSet=MathMax(StopAllowed, StopRequired);
if (((StopSet < StopCurrent-Accuracy) || (StopCurrent == 0)) && (StopRequired <= OrderOpenPrice() || AllowLoss))
mod=OrderModify(OrderTicket(),OrderOpenPrice(),StopSet,OrderTakeProfit(),0);
}
}
}
return;
}
//+------------------------------------------------------------------+
void OnTick()
{
Comment("\nResult of last deal: ", LastDealResult());
//--- check for history and trading
if(Bars<100 || IsTradeAllowed()==false)
return;
//--- go trading only for first tiks of new bar
if(NewBar()==true)
{
Print("New Bar");
CheckForOpen();
CheckForClose();
}
if(Trail>0) trail();
//---
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Renko.mq4 |
//| Copyright © 2014, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2014, AM2"
#property link "http://www.forexsystems.biz"
#property description "indalekseifx Directional Line expert advisor"
//--- Inputs
extern double StopLoss = 2000; // стоп лосс ордера
extern double TakeProfit = 2000; // тейк профит ордера
extern double Lots = 0.1; // объем позиции
//----
extern int Amplitude = 2; // период средней indalekseifx Directional Line
extern int shift = 2; // смещение средней
//----
extern int FastPeriod = 12; // период быстрого макди
extern int SlowPeriod = 26; // период медленного макди
extern int SignalPeriod = 9; // период сигнального макди
//----
extern int MACDAC = 0; // включение макди(1-включен,0-отключен)
extern int MAGIC = 2014; // магик
int DealResult;
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
int res,pos;
//--- get Moving Average
double indalekseifxDeepSkyBlue=iCustom(Symbol(),0,"indalekseifx",Amplitude,1,1);
double indalekseifxTomato=iCustom(Symbol(),0,"indalekseifx",Amplitude,0,1);
double MACDGreen=iCustom(Symbol(),0,"MACDTraditional",FastPeriod,SlowPeriod,SignalPeriod,1,1);
double MACDRed=iCustom(Symbol(),0,"MACDTraditional",FastPeriod,SlowPeriod,SignalPeriod,0,1);
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
{
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
{
if(OrderType()==OP_BUY) pos++;
if(OrderType()==OP_SELL) pos++;
}
}
}
//--- sell conditions
if(MACDAC==1)
{
if(indalekseifxDeepSkyBlue>indalekseifxTomato && MACDGreen<MACDRed && pos<1 && (LastDealResult()==0 || LastDealResult()==1))
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,fND(Bid+StopLoss*Point),fND(Bid-TakeProfit*Point),"",MAGIC,0,Tomato);
if(res<0)
{
Print("Order Sell error: ",GetLastError());
}
else
Print("OK Order Sell");
return;
}
//--- buy conditions
if(indalekseifxTomato>indalekseifxDeepSkyBlue && MACDGreen>MACDRed && pos<1 && (LastDealResult()==0 || LastDealResult()==2))
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,fND(Ask-StopLoss*Point),fND(Ask+TakeProfit*Point),"",MAGIC,0,DeepSkyBlue);
if(res<0)
{
Print("Order Buy error: ",GetLastError());
}
else
Print("OK Order Buy");
return;
}
}
else
{
if(indalekseifxDeepSkyBlue>indalekseifxTomato && pos<1 && (LastDealResult()==0 || LastDealResult()==1))
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MAGIC,0,Tomato);
if(res<0)
{
Print("Order Sell error: ",GetLastError());
}
else
Print("OK Order Sell");
return;
}
//--- buy conditions
if(indalekseifxTomato>indalekseifxDeepSkyBlue && pos<1 && (LastDealResult()==0 || LastDealResult()==2))
{
res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,fND(Ask-StopLoss*Point),fND(Ask+TakeProfit*Point),"",MAGIC,0,DeepSkyBlue);
if(res<0)
{
Print("Order Buy error: ",GetLastError());
}
else
Print("OK Order Buy");
return;
}
}
}
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
//--- get Moving Average
double indalekseifxDeepSkyBlue=iCustom(Symbol(),0,"indalekseifx",Amplitude,1,shift);
double indalekseifxTomato=iCustom(Symbol(),0,"indalekseifx",Amplitude,0,shift);
//---
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
//--- check order type
if(OrderType()==OP_BUY)
{
if(indalekseifxDeepSkyBlue>indalekseifxTomato)
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
if(OrderType()==OP_SELL)
{
if(indalekseifxTomato>indalekseifxDeepSkyBlue)
{
if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
}
//---
}
//+------------------------------------------------------------------+
bool NewBar()
{
static datetime lastbar = 0;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return (true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
int LastDealResult()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
//--- check order type
if(OrderType()==OP_BUY)
{
DealResult=1;
break;
}
if(OrderType()==OP_SELL)
{
DealResult=2;
break;
}
Print("Result of last deal: ",DealResult);
}
return(DealResult);
}
//+------------------------------------------------------------------+
double fND(double d, int n=-1)
{
if (n<0) return(NormalizeDouble(d, Digits));
return(NormalizeDouble(d, n));
}
//+------------------------------------------------------------------+
void OnTick()
{
Comment("\nResult of last deal: ", LastDealResult());
//--- check for history and trading
if(Bars<100 || IsTradeAllowed()==false)
return;
//--- go trading only for first tiks of new bar
if(NewBar()==true)
{
Print("New Bar");
CheckForOpen();
CheckForClose();
}
//---
}
//+------------------------------------------------------------------+
Как утверждает автор, стратегия дает 400 пунктов в месяц. То есть те заветные 20 пунктов в день, о которых мечтают многие трейдеры.маловероятно. сейчас напишу
//+------------------------------------------------------------------+
//| Oxy.mq4 |
//| Copyright © 2014, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2014, AM2"
#property link "http://www.forexsystems.biz"
#property description "Slope Directional Line expert advisor"
//--- Inputs
extern int StopLoss = 500; // стоп лосс ордера
extern int TakeProfit = 500; // тейк профит ордера
extern int CountCandle = 7; // тейк профит ордера
extern int Delta = 100; // расстояние AB
extern double Lots = 0.1; // объем позиции
//----
extern int period = 90; // период средней Slope Directional Line
extern int method = 2; // метод средней(SMA=0,EMA=1,SMMA=2,LWMA=3)
extern int price = 0; // цена по которой строится средняя
//----
extern int MAGIC = 333; // магик
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void OpenPos()
{
int res,pos;
//--- get Moving Average
double SlopeBlue=iCustom(Symbol(),0,"Slope",period,method,price,1,1);
double SlopeRed=iCustom(Symbol(),0,"Slope",period,method,price,0,1);
double SlopeBlueShift=iCustom(Symbol(),0,"Slope",period,method,price,1,CountCandle);
double SlopeRedShift=iCustom(Symbol(),0,"Slope",period,method,price,0,CountCandle);
double up=iHigh(Symbol(),0,iHighest(NULL,0,MODE_HIGH,CountCandle,1));
double dn=iLow(Symbol(),0,iLowest(NULL,0,MODE_LOW,CountCandle,1));
Comment("\nSlope Blue ",SlopeBlue,"\nSlope Red ",SlopeRed);
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
{
if(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) continue;
{
if(OrderType()==OP_BUY) pos++;
if(OrderType()==OP_SELL)pos++;
}
}
}
//--- sell conditions
if(SlopeBlueShift==SlopeRedShift) //линия синяя CountCandle свечей назад
if(Close[0]<SlopeBlueShift) //цена ниже синей линии CountCandle свечей назад
if(Close[CountCandle]>SlopeBlueShift) //цена CountCandle свечей назад была выше синей линии
if(Bid-dn>=Delta*Point //цена касается линии
&& OrdersTotal()<1)
{
res=OrderSend(Symbol(),OP_SELLSTOP,Lots,dn,3,dn+StopLoss*Point,dn-TakeProfit*Point,"",MAGIC,0,Red);
return;
}
//--- buy conditions
if(SlopeBlueShift!=SlopeRedShift) //линия красная CountCandle свечей назад
if(Close[0]>SlopeRedShift) //цена выше красной линии CountCandle свечей назад
if(Close[CountCandle]<SlopeRedShift) //цена CountCandle свечей назад была ниже красной линии
if(up-Ask>=Delta*Point //цена касается линии
&& OrdersTotal()<1)
{
res=OrderSend(Symbol(),OP_BUYSTOP,Lots,up,3,up-StopLoss*Point,up+TakeProfit*Point,"",MAGIC,0,Blue);
return;
}
}
//+------------------------------------------------------------------+
void DelOrder()
{
bool del;
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if (OrderType()==OP_BUYSTOP) del=OrderDelete(OrderTicket());
if (OrderType()==OP_SELLSTOP) del=OrderDelete(OrderTicket());
}
}
//+------------------------------------------------------------------+
bool NewBar()
{
static datetime lastbar = 0;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return (true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
double SlopeBlue=iCustom(Symbol(),0,"Slope",period,method,price,1,1);
double SlopeRed=iCustom(Symbol(),0,"Slope",period,method,price,0,1);
//--- check for history and trading
if(Bars<100 || IsTradeAllowed()==false)
return;
if(NewBar()==true)
{
if(Close[1]<SlopeBlue)DelOrder();
OpenPos();
}
//---
}
//+------------------------------------------------------------------+
AM2