Добавьте пожалуйста в индикатор фильтр боллинджер со стандартными настройками , чтобы стрелку выставлял только тогда когда касается линии ББ вот скрин примера: http://gyazo.com/15f7961ab212f019a72a666880314840
//+------------------------------------------------------------------+
//| AAAA.mq4 |
//| AAAA|
//| |
//+------------------------------------------------------------------+
#property copyright "AAAA"
#property link "AAAA"
#property indicator_chart_window
// The number of buffers for calculation, up to 8
#property indicator_buffers 2
// The color for displaying arrows
#property indicator_color1 MidnightBlue // Long signal
#property indicator_color2 Maroon // Short signal
// Width of the arrows
#property indicator_width1 1 // Long signal arrow
#property indicator_width2 1 // Short signal arrow
extern int ArrowDistance = 10;
extern bool WaitForCandleClose = false;
extern bool ArrowOnTriggerBar = true;
extern bool PlatformAlert=true;
extern bool EmailAlert=false;
// Buffers for the calculations
double Up_Arrow_Buffer[]; // Long buffer for display
double Down_Arrow_Buffer[]; // Short buffer for display
int SignalIndex = 0;
int ArrowOffset = 0;
int pTime=0;
bool Alerted =false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if (WaitForCandleClose)
{
SignalIndex = 1;
}
else
{
SignalIndex = 0;
}
if (ArrowOnTriggerBar)
{
ArrowOffset = 1;
}
else
{
ArrowOffset = 0;
}
// SetIndexStyle - sets the new type, style, width and color for a given indicator line
// SetIndexBuffer - binds the array variable declared at a global level to the custom indicator pre-defined buffer
// SetIndexArrow - sets an arrow symbol for indicators line of the DRAW_ARROW type.
SetIndexStyle(0, DRAW_ARROW);
SetIndexBuffer(0, Up_Arrow_Buffer);
SetIndexArrow(0, 233); // Up arrow
SetIndexStyle(1, DRAW_ARROW);
SetIndexBuffer(1, Down_Arrow_Buffer);
SetIndexArrow(1, 234); // Down arrow
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i; // Bar index
int Counted_bars; // Number of counted bars
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted(); // Number of counted bars
i=Bars-Counted_bars-1; // Index of the first uncounted
if (i == 0)
{
i = 2; // the newest signal bar is suppose to be at index 2
}
if (NewBar()) Alerted =false; //Reset for NewBar
while(i>SignalIndex) // Loop for uncounted bars
{
if (isUpSwingBar(i))
{
Up_Arrow_Buffer[i-ArrowOffset] = Low[i-ArrowOffset] - (ArrowDistance * Point);
Down_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
if (!Alerted)
{
if (PlatformAlert) Alert("сигнал: на покупку " + Symbol()+ " At " + DoubleToStr(Ask,Digits) + " ; TF: M" + Period());
if (EmailAlert) SendMail("сигнал: ","на покупку " + Symbol()+ " At " + DoubleToStr(Ask,Digits) + " ; TF: M" + Period());
Alerted=true;
}
}
else if (isDownSwingBar(i))
{
Down_Arrow_Buffer[i-ArrowOffset] = High[i-ArrowOffset] + (ArrowDistance * Point);
Up_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
if (!Alerted)
{
if (PlatformAlert) Alert("сигнал: На продажу " + Symbol()+ " At " + DoubleToStr(Bid,Digits) + " ; TF: M" + Period());
if (EmailAlert) SendMail("сигнал: ","На продажу " + Symbol()+ " At " + DoubleToStr(Bid,Digits) + " ; TF: M" + Period());
Alerted=true;
}
}
else
{
Up_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
Down_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
}
i--;
}
//----
return(0);
}
bool isUpSwingBar(int i)
{
if (Low[i] < Low[i-1] && High[i] < High[i-1] && Low[i] < Low[i+1] && Low[i+1] < Low[i+2])
{
return (true);
}
return (false);
}
bool isDownSwingBar(int i)
{
if (High[i] > High[i-1] && Low[i] > Low[i-1] && High[i] > High[i+1] && High[i+1] > High[i+2] &&
High[i+2])
{
return (true);
}
return (false);
}
//+------------------------------------------------------------------+
bool NewBar() {
if (Time[0] != pTime)
{
pTime = Time[0];
return (true);
}
return (false);}
Сообщение отредактировал alibydubby: 28 March 2014 - 00:43