Download MetaTrader 5
To add comments, please log in or register
Log in to MQL5.community using OpenID. It is convenient!
brettosm8
241
brettosm8 2014.02.23 10:15 

hi there,

thanks for your assistance. I'm trying to write some code that will print out my horizontal lines but the script is loaded and then removed. Does the mrket have to be open to run or why doent it work?

anks, brad.

int TotalHLines=0;

void OnStart()
  {
  Print("hello");
   TotalHLines=ObjectsTotal(OBJ_HLINE);
   for(int i=0;i<TotalHLines;i++)
      {
         Print(ObjectName(i));
      }//End of for loop
  }// End of OnStart
Alain Verleyen
Moderator
28517
Alain Verleyen 2014.02.23 10:21  
brad:

hi there,

thanks for your assistance. I'm trying to write some code that will print out my horizontal lines but the script is loaded and then removed. Does the mrket have to be open to run or why doent it work?

anks, brad.

There is no problem with this script.

Do you have some horizontal lines on your chart ?

Keith Watford
Moderator
7862
Keith Watford 2014.02.23 10:31  
Are you checking the Expert tab/logs to see if the print worked, or are you expecting a pop-up alert?
whroeder1
13592
whroeder1 2014.02.23 13:12  
brad: Does the mrket have to be open to run or why doent it work?
No ticks on the weekend when market is closed.
Keith Watford
Moderator
7862
Keith Watford 2014.02.23 13:54  
WHRoeder:
No ticks on the weekend when market is closed.


Does a script using the function void OnStart() need a tick?
whroeder1
13592
whroeder1 2014.02.23 16:48  
Scripts shouldn't. I didn't read close enough.
brettosm8
241
brettosm8 2014.03.01 06:38  

when i drop the script on the chart the screen appears like this:

thanks,

Brad.

whroeder1
13592
whroeder1 2014.03.01 13:17  
Try looking in the Experts tab for your printout, as previously answered.
GumRai: Are you checking the Expert tab/logs
This finds that there are 2 HLINEs on the chart of nnn objects, and then prints out the names of the first two objects, not the names of the HLINEs.
TotalHLines=ObjectsTotal(OBJ_HLINE);
for(int i=0;i<TotalHLines;i++){
      Print(ObjectName(i));
If you want to print out the names of the HLINEs, you need to find them, wherever they are in the list.
TotalHLines=0;
for(int i=ObjectsTotal() - 1; i >= 0; i--){
      string on = ObjectName(i);
      if( ObjectType(on) == OBJ_HLINE){
         Print(on); TotalHLines++; }
brettosm8
241
brettosm8 2014.03.01 22:54  
you're right! had to che k the experts tab.
/
To add comments, please log in or register