
//+------------------------------------------------------------------+
//| MTFSupertrend Bar.mq4 |
//| Copyright 2014, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#define MAGICMA 20141020
//---- input parameters
extern int StopLoss = 500; // лось
extern int TakeProfit = 500; // язь
extern double Lot = 0.1; // лот
extern int Slip = 100; // реквот
extern int Delta=50;
extern int Width=1;
extern int Style=0;
/*
STYLE_SOLID 0 Сплошная линия
STYLE_DASH 1 Штриховая линия
STYLE_DOT 2 Пунктирная линия
STYLE_DASHDOT 3 Штрих-пунктирная линия
STYLE_DASHDOTDOT 4 Штрих-пунктирная линия с двойными точками
*/
extern int SymbolCodeBuy=233;
extern int SymbolCodeSell=234;
extern color Color1=Blue;
extern color Color2=Red;
//---- buffers
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---- indicators
SetIndexStyle(0,DRAW_ARROW,Style,Width,Color1);
SetIndexArrow(0,SymbolCodeBuy);
SetIndexBuffer(0,Buffer1);
//----
SetIndexStyle(1,DRAW_ARROW,Style,Width,Color2);
SetIndexArrow(1,SymbolCodeSell);
SetIndexBuffer(1,Buffer2);
//----
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double MTFUP4=iCustom(Symbol(),0,"MTFSuperTrendBar",0,1);
double MTFDN4=iCustom(Symbol(),0,"MTFSuperTrendBar",1,1);
double MTFUP3=iCustom(Symbol(),0,"MTFSuperTrendBar",2,1);
double MTFDN3=iCustom(Symbol(),0,"MTFSuperTrendBar",3,1);
double MTFUP2=iCustom(Symbol(),0,"MTFSuperTrendBar",4,1);
double MTFDN2=iCustom(Symbol(),0,"MTFSuperTrendBar",5,1);
double MTFUP1=iCustom(Symbol(),0,"MTFSuperTrendBar",6,1);
double MTFDN1=iCustom(Symbol(),0,"MTFSuperTrendBar",7,1);
if(MTFDN4==0 && MTFDN3==0 && MTFDN2==0 && MTFDN1==0 && OrdersTotal()<1)
{
int res=OrderSend(Symbol(),OP_SELL,Lot,Bid,Slip,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",MAGICMA,0,Red);
}
if(MTFUP4>0 && MTFUP3>0 && MTFUP2>0 && MTFUP1>0 && OrdersTotal()<1)
{
int res=OrderSend(Symbol(),OP_BUY,Lot,Ask,Slip,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA,0,Blue);
}
Comment(
"\nMTFUP4 ",MTFUP4,
"\nMTFDN4 ",MTFDN4,
"\nMTFUP3 ",MTFUP3,
"\nMTFDN3 ",MTFDN3,
"\nMTFUP2 ",MTFUP2,
"\nMTFDN2 ",MTFDN2,
"\nMTFUP1 ",MTFUP1,
"\nMTFDN1 ",MTFDN1
);
}
//+------------------------------------------------------------------+
AM2