Download MetaTrader 5
To add comments, please log in or register
Find out the latest MQL5.community news!
rme0108
29
rme0108 2015.10.22 06:18 

Hi,

apollogies for this question, but I can't seem to get it done right on MT4. 

I have an array status[20] defined below input parameters using the following.

string status[20];

Now I'm trying to assing the word "pending" to each of them using a for i loop in  

int init ()

{

for(int i=0; i<20; i++)

     {

        status[i]=(pending);

        } 

return(0);

  } 

This doesn't work. I use ObjectCreate, ObjectSetText, ObjectSet to display these and other values on the chart, but the array hasn't loaded the values. I tried with numbers instead but got the same result.

When I assign values to my string using this: 

string status[20];="1pending1","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","pending","lastof20"}; 

The values are correctly assigned to my array and display correctly on the chart.

Thanks for your help in advance 

honest_knave
959
honest_knave 2015.10.22 06:23  
string status[20];
for(int i=0; i<20; i++)
  {
   status[i]="pending";
  } 
rme0108
29
rme0108 2015.10.22 06:41  
honest_knave:

sorry about the typo, of course in my code it is status[i]="pending"; and not status[i]=(pending);

 

this is my

int Init()

  {

//---


      //GetTickSize (); I"m doing it manually, where one pip on my broker is 0.0001

      //establish initial position using moving average

      GetBuySellPosition ();

      //define all the values/strings

      

      for(int i=0; i<20; i++)

     {

        status[i]="pending";

        }

      

   //---

   return(0);

  } 

i just double checked, but it doesn't work. there must be something else wrong in there. 

Can values be assigned to arrays in the int init (); ? 

Carl Schreiber
5940
Carl Schreiber 2015.10.22 09:42  

1) Please use SRC-button if you post code!

2) Walk through the problematic part by using the Debugger! Place DebugBreak(); before the lines you need or press F9.

/
To add comments, please log in or register