Hi!
You are mixing the array and the buffer handler.
Alternatively you don't neet two calls to iCustom(). I changed the Print statement so it shows the current bar's values. Like this:
int pinbar_handle; double pinbarup[], pinbarcolor []; int pinbar_handle= iCustom(NULL,0,"Pinbar",0,true,false,false,0.33,0.4,true,false,false,0.1,0.5,1,0,0.1); ArraySetAsSeries(pinbarup, true); ArraySetAsSeries(pinbarcolor, true); CopyBuffer(pinbar_handle, 0, 0, 5, pinbarup); Print("Updown =",pinbarup[4]); CopyBuffer(pinbar_handle, 1, 0, 5, pinbarcolor); Print("Color =",pinbarcolor[4]);
And in addition, you must always check the return value of CopyBuffer(). Otherwise you'll get an array out of range some day.
if(CopyBuffer(pinbar_handle, 0, 0, 5, pinbarup)<0) { Print("Error copying buffer"); { else { Print("Updown =",pinbarup[4]); }
And finally, if your EA is calculating every tick, use the previous candle value instead pinbarup[3]. Indicator may return values that change every tick for the current bar.
Dear Fred, thanks a lot for your help.
I still cant understand why i dont see any change in pinbarcolor[] , i put the 5 buffers(0,1,2,3 and 4) to print but all of them just give me the result Color =0.0
In the indicator, there is a moment where Color becomes 0 or 1 , i want to see this change to pass it as a buy or sell condition
if ((!NoseBodyInsideLeftEyeBody) || ((MathMax(Open[i], Close[i]) <= MathMax(Open[i + 1], Close[i + 1])) && (MathMin(Open[i], Close[i]) >= MathMin(Open[i + 1], Close[i + 1])))) // Nose body inside Left Eye body if required { UpDown[i] = Low[i] - 5 * _Point - NoseLength / 5; Color[i] = 0; // This is the moment that i want to capture!!!
This is how im trying to capture
static datetime Old_Time; datetime New_Time[1]; bool IsNewBar=false; // copying the last bar time to the element New_Time[0] int copied=CopyTime(_Symbol,_Period,0,1,New_Time); if(copied>0) // ok, the data has been copied successfully { if(Old_Time!=New_Time[0]) // if old time isn't equal to new bar time { IsNewBar=true; // if it isn't a first call, the new bar has appeared if(MQL5InfoInteger(MQL5_DEBUGGING)) Print("We have new bar here ",New_Time[0]," old time was ",Old_Time); Old_Time=New_Time[0]; // saving bar time // ArraySetAsSeries(pinbarup, true); ArraySetAsSeries(pinbarcolor, true); //CopyBuffer(pinbar_handle, 0, 0, 5, pinbarup); //Print("Updown =",pinbarup[0]); CopyBuffer(pinbar_handle, 1, 0, 5, pinbarcolor); Print("Color =",pinbarcolor[4]); } } else { Alert("Error in copying historical times data, error =",GetLastError()); ResetLastError(); return; }
You have an error either in initializing the indicator or when copying the buffer. change the code in order to get the errors be printed. iCustom() and CopyBuffer() alone is a bad idea.
for instance:
AbsStrng_Handle2 = iCustom(CorrCurrenciesMatching[i].symbol,0,"absolutestrengthmarket_v1",TimeFrame,MathMode,Price,Length2,PreSmooth2,Smooth2,Signal,MA_Mode,IndicatorValue,ArrowCode,AlertMode2,ShowName,ShowTimeFrame,FontName,FontSize,TextColor,UniqueName); if(AbsStrng_Handle2==INVALID_HANDLE) { Alert(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà AbsStrng_Handle2 "+GetLastError()); return; }
and:
if(CopyBuffer(ThreePairsInd_Handle,0,0,4,ThreePairsSignal)<0) { Alert("Error copying ThreePairs indicator Buffers - Error: "+GetLastError()); return; }
You can't call these functions without checking if they went well or not. I often get an error with iCustom because its name must be exactly the same as the file name. Another error is when the parameters are not good. This must be checked in your code.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear friends, im trying to use a indicator signal in my EA but i have no idea why CopyBuffer just give me ordered numbers, let me show the code:
Then, in my EA:
Here is my problem, i need to know the direction of the pinbar to place the buy or sell order, but the only result that i receive from copybuffer is:
Updown = 10
Color = 11
Updown = 12
Color = 13
Updown = 14
Color = 15
...
I dont know why im receiving ordered numbers from 2 different buffers and how can i use this data to place the orders
Thanks in advice guys.