Please, use the proper formatting when inserting a code snippet. It's hard to read and understand your code without the website formatting.
When you call "Copy___" functions, you're not actually checking if they return any errors. Check if they return -1 and, if so, what error GetLastError returns.
I couldn't really see anything wrong in your code (considering the parameters passed to the Copy functions contain correct values). Try debugging your code by setting breakpoints in this function.
Please, use the proper formatting when inserting a code snippet. It's hard to read and understand your code without the website formatting.
When you call "Copy___" functions, you're not actually checking if they return any errors. Check if they return -1 and, if so, what error GetLastError returns.
I couldn't really see anything wrong in your code (considering the parameters passed to the Copy functions contain correct values). Try debugging your code by setting breakpoints in this function.
Thank you very much and sorry for wrong format. I printed the CopyLow and it returned as 1, therefore the GetLastError is not activated.
void FindLowsHighsMajor(){ //find low / high within a cluster of candles double highs[], lows[]; datetime barTime[]; //ArraySetAsSeries(highs,true); //ArraySetAsSeries(lows,true); bool exact = false; int bar_index = iBarShift(_Symbol,MajorTimeframe,majorRangeHighTime,exact); int bar_index2 = iBarShift(_Symbol,MajorTimeframe,prevMajorRangeHighTime,exact); datetime time_indexLong = iTime(_Symbol,MajorTimeframe,bar_index - 1); datetime time_index2Long = iTime(_Symbol,MajorTimeframe,bar_index2 - 1); Print("time_indexLong: ", time_indexLong," time_index2Long: ",time_index2Long); int highCount = CopyLow(_Symbol,PERIOD_M1,time_indexLong,time_index2Long,lows); Print("highCount: ",highCount); GetLastError(); Print("Array lows:"); ArrayPrint(lows,_Digits,0,0,WHOLE_ARRAY); if(majorTrendLong == true){ majorRangeLow = lows[ArrayMinimum(lows)]; int barCount = CopyTime(_Symbol,PERIOD_M1,time_indexLong,time_index2Long,barTime); majorRangeLowTime = barTime[ArrayMinimum(lows)]; Print("Array barTime:"); ArrayPrint(barTime,_Digits,0,0,WHOLE_ARRAY); bar_index=iBarShift(_Symbol,MajorTimeframe,majorRangeLowTime,exact); majorRangeLowTime = iTime(_Symbol,MajorTimeframe,bar_index); Print("majorRangeLow: ",majorRangeLow," majorRangeHigh: ",majorRangeHigh, " majorRangeLowTime: ",majorRangeLowTime," majorRangeHighTime: ",majorRangeHighTime);
This is what returned, everything that is marked yellow is correct. But why is there only one value written even if there are two days full of 1min bars? And why is this value even out of the range I´ve written in the copylow function?
Is it a problem when I call this function during a loop? I think it should always initialize the arrays again when the function is called. Could it be a problem with year2023 in the datetime?
Thank you very much
You might have to use CopySeries with PERIOD_M1 and COPY_RATES_LOW and COPY_RATES_TIME to get all of the lows and times into a double array (for the lows) and a datetime array (for the times).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I´m not the best in coding but I have a good base.
I tried to code an expert adviser and figured out an issue I can not solve by myself. I tried multiple things and modified for hours but it doesn´t seem to work. Maybe someone has the right hint for me.
So I loop throug all the candles on a input timeframe "MajorTimeframe" and search for breaks of a range. If there is a break and since the last MajorRangeLow or MajorRangeHigh there is a bar between I call the function for finding the low or high within this cluster of candles. I need the the time of the bar and the low/high of this bar to draw my trend later on. So there is my code:
What I figured out during the Printing statements is: the time_indexLong and time_index2Long are correct, but the copylow function is messing everything up. For example I had a time_indexLong = 26.Dec.2023 00:00 and time_index2Long = 28.Dec.2023 00:00 and the array "lows" just included one low and this low doesn´t exist during this timeslot. Same for array "barTime", just one value and 02.july.2024. Has someone an idea how to fix it?
Thank you very much