ObjectCreate: Trying to draw a trend line with OBJ_TREND in MT4 between Highs - getting error in code

To add comments, please log in or register
tenakha
22
tenakha  

Hi,

I am getting this error:

'[' -array required

I am using ObjectCreate - the documentation is not very clear about the types of params I should be passing.

Here is the code:

   int i = 5;

   // the following line is throwing the error:   
   ObjectCreate(0,"tr"+string(i),OBJ_TREND,0,Time[1],Ask[1],Time[2],Ask[2]);

   ObjectSetInteger(0,"tr"+string(i),OBJPROP_COLOR,Red);
   ObjectSetInteger(0,"tr"+string(i),OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,"tr"+string(i),OBJPROP_WIDTH,1);
   ObjectSetInteger(0,"tr"+string(i),OBJPROP_RAY,false);


Would be grateful for any help - I have not found any working examples online.

Seng Joo Thio
1105
Seng Joo Thio  
tenakha:

Hi,

I am getting this error:

'[' -array required

I am using ObjectCreate - the documentation is not very clear about the types of params I should be passing.

Here is the code:

Would be grateful for any help - I have not found any working examples online.

'Ask' is not an array, so there is no Ask[1] and Ask[2]. Use High[1] and High[2] instead.

tenakha
22
tenakha  
Seng Joo Thio:

'Ask' is not an array, so there is no Ask[1] and Ask[2]. Use High[1] and High[2] instead.

 Thank you so much - your advice worked a treat! The lines are appearing as expected! :-)

To add comments, please log in or register