where does the 0.0 come from?

 

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);
  }

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?

 
ziyang2048:

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.

 
ziyang2048:

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

 
Werner Klehr #:

Hi,

try to print the value of i: e.g. Print(i, " ", SLArray[i]);

Maybe this could help you.

Best regards

Keith Watford #:

Size the array to the number of open positions.

You are probably printing the lowest SL somewhere later.

thanks to you all, I have already solved my problem.

 
ziyang2048 #:

thanks to you all, I have already solved my problem.

So, what was the problem?

Somebody else may find this topic in future because they have a similar problem. Your solution may help them.

 
Keith Watford #:

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.