int OnInit()
{
ObjectCreate(0,"B1",OBJ_BUTTON,0,0,0);
ObjectSet("B1",OBJPROP_CORNER,2);
ObjectSetInteger(0,"B1",OBJPROP_XDISTANCE,10);
ObjectSetInteger(0,"B1",OBJPROP_YDISTANCE,80);
ObjectSetInteger(0,"B1",OBJPROP_XSIZE,50);
ObjectSetInteger(0,"B1",OBJPROP_YSIZE,25);
ObjectSetString(0,"B1",OBJPROP_TEXT,"BUY");
ObjectSetInteger(0,"B1",OBJPROP_COLOR,White);
ObjectSetInteger(0,"B1",OBJPROP_BGCOLOR,clrGreen);
ObjectSetInteger(0,"B1",OBJPROP_BORDER_COLOR,clrGreen);
ObjectSetInteger(0,"B1",OBJPROP_BORDER_TYPE,BORDER_FLAT);
ObjectSetInteger(0,"B1",OBJPROP_HIDDEN,true);
ObjectSetInteger(0,"B1",OBJPROP_STATE,false);
ObjectSetInteger(0,"B1",OBJPROP_FONTSIZE,10);
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
if(sparam=="B1") // Close button has been pressed
{
ticket=OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"",0,0,Green);
ObjectSetInteger(0,"B1",OBJPROP_STATE,false);
}
}