WHRoeder
WHRoeder
好友

通过他们的个人资料或用户搜索添加好友,您将能够看到他们是否在线

WHRoeder
已在MQL5.community注册
Bwalya Tambule
Bwalya Tambule 2015.06.06
welcome
fedoraproject
fedoraproject 2017.06.17
I want to put draw limit on trend line line for last 100 bar below is the code. Please Help



//+------------------------------------------------------------------+
//| SwingMan HiLo Activator2.mq4 |
//| SwingMan |
//| soc607@t-online.de |
//+------------------------------------------------------------------+
#property copyright "SwingMan"
#property link "soc607@t-online.de"

#property indicator_chart_window

//---- indicator settings
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

//---- input parameters ----------------------------------------------
extern int Period_HiLo = 10;
//--------------------------------------------------------------------

//---- indicator buffers
double BufferHighs[];
double BufferLows[];
//-- Arrays
double dHighs[],dLows[];
//-- variables
int iTrend;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//-- Arrays
ArraySetAsSeries(dHighs,true);
ArraySetAsSeries(dLows,true);
//---- indicator buffers mapping
SetIndexBuffer(0,BufferHighs);
SetIndexBuffer(1,BufferLows);

//---- drawing settings
SetIndexStyle(0,DRAW_LINE,0,2); // Highs
SetIndexStyle(1,DRAW_LINE,0,2); // Lows

IndicatorDigits(Digits);

SetIndexDrawBegin(0,Period_HiLo);
SetIndexDrawBegin(1,Period_HiLo);

//---- name for DataWindow and indicator subwindow label
IndicatorShortName("SwingMan HiLoActivator2");
Comment("SwingMan HiLoActivator2 (" + Period_HiLo +") ");

SetIndexLabel(0,"Highs");
SetIndexLabel(1,"Lows");
//--
iTrend = 0;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if (counted_bars<0) return(-1);
if(Bars0) counted_bars--;
int limit = Bars - counted_bars;

ArrayResize(dHighs,Bars);
ArrayResize(dLows,Bars);
//----
for (int i = 0; i =0; i--)
{
BufferHighs[i] = EMPTY_VALUE;
BufferLows[i] = EMPTY_VALUE;
//-- first trend
if (iTrend == 0) {
if (Close[i] > dHighs[i]) iTrend = 1;
else
if (Close[i] < dLows[i]) iTrend = -1;
}

//-- up trend
if (iTrend == 1) {
if (Close[i] dHighs[i]) {
BufferLows[i] = dLows[i];
iTrend = 1;
}
else {
BufferHighs[i] = dHighs[i];
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+