Missing Chart Lines from EA

 
I wrote an EA to simply draw a line on the chart when a Moving Average Cross occurred.
I have several charts open for different pairs and the EA running on multiple open charts.
My alert is triggered but when I look at my chart there are NO lines.

Here is my method...It is called from the start method when the cross happens ...


void SignalTrade(bool type)
{
intObjectCount++;
/* Counter for Line Objects */
/* static int intObjectCount=0; - this is defined before the init () method */

PlaySound("alert.wav");
ObjectCreate("Line"+intObjectCount, OBJ_VLINE, 0, Time[1], Bid);
ObjectSet("Line"+intObjectCount, OBJPROP_STYLE, STYLE_DASH);
if(type==true)
ObjectSet("Line"+intObjectCount, OBJPROP_COLOR, Green);
else
ObjectSet("Line"+intObjectCount, OBJPROP_COLOR, Red);

ObjectSet("Line"+intObjectCount, OBJPROP_BACK, true);
WindowsRedraw();

}

This is how I call the method...

SignalTrade(false, Bid, Time[0]);

Any Ideas ...

Thanks

 

HTH you...

(1)

void SignalTrade(bool type)

SignalTrade(false, Bid, Time[0]);

for starters, not see how this would compile as you have 1 formal parameter and call has 3 actuals

(2)

how about:

void SignalTrade(bool type,datetime dtLine)

SignalTrade(false, Time[0]);

and:

ObjectCreate("Line"+intObjectCount, OBJ_VLINE, 0, dtLine, 0);

and: fwiw

why not save your fingers? and also speed up the code? and only one code line to modify IF at later date etc, you want to change format of object's name

string s = "Line"+intObjectCount;

now, use s wherever you once used "Line"+intObjectCount

(3)

OBJ_VLINE 0 Vertical line. Uses time part of first coordinate.

ObjectCreate("Line"+intObjectCount, OBJ_VLINE, 0, Time[1], Bid);

(4)

WindowsRedraw();

WindowRedraw();

(5)

create a script and run on chart. You will get your line...

int start ()
{
  bool type=true;
  int intObjectCount=1;
  ObjectCreate("Line"+intObjectCount, OBJ_VLINE, 0, Time[1],0);// Bid); notice how works with price=0. Not issue, but Vline price not relevant
  ObjectSet("Line"+intObjectCount, OBJPROP_STYLE, STYLE_DASH);
  if(type==true)
    ObjectSet("Line"+intObjectCount, OBJPROP_COLOR, Green);
  else
    ObjectSet("Line"+intObjectCount, OBJPROP_COLOR, Red);

  ObjectSet("Line"+intObjectCount, OBJPROP_BACK, true);
  //WindowRedraw();     //Since creating object for "first time" this is redundant as not 'changing' properties
  return(0);
}

fwiw...

int start ()
{
  bool type=true;
  int intObjectCount=1;
  string s="Line"+intObjectCount;

  ObjectCreate(s, OBJ_VLINE, 0, Time[1],0);// Bid); notice how works with price=0. Not issue, but Vline price not relevant
  ObjectSet(s, OBJPROP_STYLE, STYLE_DASH);
  if(type==true)
    ObjectSet(s, OBJPROP_COLOR, Green);
  else
    ObjectSet(s, OBJPROP_COLOR, Red);

  ObjectSet(s, OBJPROP_BACK, true);
  //WindowRedraw();     //Since creating object for "first time" this is redundant as not 'changing' properties
  return(0);
}