Use Comment Text with EA

 
I'm using an indicator that writes comment text to the chart based on multiple factors. Is there a way to extract that text and use it in an EA?
 
string myComment=ObjectDescription("comment_obj");
 

I've come up with this to check comments, unfortunately this is failing to initiate orders.


I needed a way to track any changes in the comment so if the comments don't match the change is written to a text file which is checked each time. The comment will ALWAYS start with a BUY or a SELL so I am looking for BUY or SELL in the comment string. I am also looking for any change in the comment string. Please have a look at this and let me know where I'm messing up. There are no errors in compile and no errors when dropped on a chart except "....uninit reason 0". I have checked and verified that it works when the CheckComment function in removed.


int CheckComment(string checkComment)

{
string fbciComment=ObjectDescription("EURUSDm_SFBInd_FractalComment2");
int handle;
string pComment;
handle=FileOpen("eutrade.txt", FILE_READ);
if(handle>0)
{
pComment=FileReadString(handle);
FileClose(handle);
}
if(fbciComment != pComment)
{
int index=StringFind(fbciComment, checkComment, 0);
if(index!=-1)
{
return (index);
handle=FileOpen("eutrade.txt", FILE_WRITE);
if(handle<1)
{
Print("can't open file error-",GetLastError());
return(0);
}
FileWriteString(handle,fbciComment,38);
FileClose(handle);
}
else
{
return (0);
}
}
else
{
return (0);
}

}


int start()
{
//----

if (GetOrdersCount() == 0)
{
if (CheckComment("BUY") > 0)
{
fbuy();
}
if (CheckComment("SELL") > 0)
{
fsell();
}
}
return(0);
}

 
I verified that StringFind was not working even though the value of the comment does in fact have the word BUY in it. I tested multiple strings, not sure why it is failing. Possibly because it's spaced out and have numbers and stuff, not sure.