Top2n: Low - Array contains Low prices from 0 to do
Where do you see it? Put an array inside your function. Initialise variablel with "-1". In general, please use the Stylizer - your code is hard to read. Also you return something anyway, even if there was an error. That's not good.
//+------------------------------------------------------------------+ //| Получим Lowest для заданного промежутка | //+------------------------------------------------------------------+ doubleiLowest( string symbol, // символ int timeframe, // период int count, // число элементов int start // индекс ) { doubleLow[]; double result=-1; ArraySetAsSeries(Low,true); int copied=CopyLow(symbol,timeframe,start,count,Low); if(copied==start) { result=Low[ArrayMinimum(Low)]; } return(result); }
but it's the full analogue of the function from the four
//+------------------------------------------------------------------+ //| Получим Lowest для заданного промежутка | //+------------------------------------------------------------------+ doubleiLowest( string symbol, // символ int timeframe, // период int type, // идентификатор таймсерии int count, // число элементов int start // индекс ) { doubleLow[]; int copied=0.0; double result=-1; ArraySetAsSeries(Low,true); if(type==PRICE_CLOSE)copied=CopyClose(symbol,timeframe,start,count,Low); if(type==PRICE_OPEN)copied=CopyOpen(symbol,timeframe,start,count,Low); if(type==PRICE_HIGH)copied=CopyHigh(symbol,timeframe,start,count,Low); if(type==PRICE_LOW)copied=CopyLow(symbol,timeframe,start,count,Low); if(copied==start) { result=Low[ArrayMinimum(Low)]; } return(result); } //+------------------------------------------------------------------+
Where do you see it? Put an array inside your function. Initialise variablel with "-1". In general, please use the Stylizer - your code is hard to read. Also you return something anyway, even if there was an error. This is not good.
ArrayMinimum returns the INDEX of the element whose value is the lowest. Now we need to get the value itself from theLow array by the indexlow:
Low[low]
Nothing...
//| Получим Low для заданного номера бара |
//+------------------------------------------------------------------+
double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int do)
{
int low=0; double l=0;
ArraySetAsSeries(Low,true);
int copied=CopyLow(symbol,timeframe,0,do,Low);
if(copied>0 && index<copied){ low=ArrayMinimum(Low);//ArrayMinimum(
l = Low[low];
}
return(l);
}
Nothing...
//| Получим Low для заданного номера бара |
//+------------------------------------------------------------------+
double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int index)
{
int low=0; double l=0;
ArraySetAsSeries(Low,true);
int copied=CopyLow(symbol,timeframe,0,index,Low);
if(copied>0 && index<copied){ low=ArrayMinimum(Low);//ArrayMinimum(
l = Low[low];
}
return(l);
}
What isLow in your code?
Low - Array contains Low prices from 0 to do
Where do you see it? Put an array inside your function. Initialise variablel with "-1". In general, please use the Stylizer - your code is hard to read. Also you return something anyway, even if there was an error. That's not good.
Added: and why are you comparing like that:
You will never get a result that way.
//| Получим Lowest для заданного промежутка |
//+------------------------------------------------------------------+
double iLowest(string symbol,ENUM_TIMEFRAMES timeframe,int bands)
{
double Low[];
double result=-1;
ArraySetAsSeries(Low,true);
int copied=CopyLow(symbol,timeframe,0,bands,Low);
if(copied==bands)
{
result=Low[ArrayMinimum(Low)];
}
return(result);
}
Vladimir I think it's more universal
//| Получим Lowest для заданного промежутка |
//+------------------------------------------------------------------+
double iLowest(
string symbol, // символ
int timeframe, // период
int count, // число элементов
int start // индекс
)
{
double Low[];
double result=-1;
ArraySetAsSeries(Low,true);
int copied=CopyLow(symbol,timeframe,start,count,Low);
if(copied==start)
{
result=Low[ArrayMinimum(Low)];
}
return(result);
}
//| Получим Lowest для заданного промежутка |
//+------------------------------------------------------------------+
double iLowest(
string symbol, // символ
int timeframe, // период
int type, // идентификатор таймсерии
int count, // число элементов
int start // индекс
)
{
double Low[];
int copied=0.0;
double result=-1;
ArraySetAsSeries(Low,true);
if(type==PRICE_CLOSE)copied=CopyClose(symbol,timeframe,start,count,Low);
if(type==PRICE_OPEN)copied=CopyOpen(symbol,timeframe,start,count,Low);
if(type==PRICE_HIGH)copied=CopyHigh(symbol,timeframe,start,count,Low);
if(type==PRICE_LOW)copied=CopyLow(symbol,timeframe,start,count,Low);
if(copied==start)
{
result=Low[ArrayMinimum(Low)];
}
return(result);
}
//+------------------------------------------------------------------+
Where do you see it? Put an array inside your function. Initialise variablel with "-1". In general, please use the Stylizer - your code is hard to read. Also you return something anyway, even if there was an error. This is not good.
Thank you!!!
I can't figure out how to add a standard trailing stop class to an EA, show me an example if you don't mind.
Example: \MQL5\Experts\Examples\MACD\MACD Sample.mq5