script doesnt run

 

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
 
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 ?

 
Are you checking the Expert tab/logs to see if the print worked, or are you expecting a pop-up alert?
 
brad: Does the mrket have to be open to run or why doent it work?
No ticks on the weekend when market is closed.
 
WHRoeder:
No ticks on the weekend when market is closed.


Does a script using the function void OnStart() need a tick?
 
Scripts shouldn't. I didn't read close enough.
 

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

thanks,

Brad.

 
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++; }
 
you're right! had to che k the experts tab.