Hi guys, I have write a ea that can find the lowestSL price,
but there's only 2 position and 2stoploss,
I try to print the SLArray,
but where does the 0.0 come from?
Size the array to the number of open positions.
You are probably printing the lowest SL somewhere later.
Hi guys, I have write a ea that can find the lowestSL price,
but there's only 2 position and 2stoploss,
I try to print the SLArray,
but where does the 0.0 come from?
Hi,
try to print the value of i: e.g. Print(i, " ", SLArray[i]);
Maybe this could help you.
Best regards
So, what was the problem?
Somebody else may find this topic in future because they have a similar problem. Your solution may help them.
double SLArray[]; void OnTick() { ArrayResize(SLArray,100,0); for(int i = PositionsTotal()-1; i>=0; i--) { ulong Ticket = PositionGetTicket(i); if(PositionSelectByTicket(Ticket)==true) { SLArray[i] = PositionGetDouble(POSITION_SL); Print(SLArray[i]); } } int LowestSL = ArrayMinimum(SLArray,0,WHOLE_ARRAY); }
double SLArray[]; void OnTick() { ArraySetAsSeries(SLArray,true); ArrayResize(SLArray,PositionsTotal(),0); for(int i = PositionsTotal()-1; i>=0; i--) { ulong Ticket = PositionGetTicket(i); if(PositionSelectByTicket(Ticket)==true) { SLArray[i] = PositionGetDouble(POSITION_SL); } } int LowestSL = ArrayMinimum(SLArray,0,WHOLE_ARRAY); Print(SLArray[LowestSL]); }
just like few hours ago what you told me to do,
change the array,
it would not print the 0.0 anymore,
really appreciate it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys, I have write a ea that can find the lowestSL price,
but there's only 2 position and 2stoploss,
I try to print the SLArray,
but where does the 0.0 come from?