OBJ_ARROW_BUY

Buy sign.

Example

The following script creates and moves Buy sign on the chart. Special functions have been developed to create and change graphical object's properties. You can use these functions "as is" in your own applications.

#propertystrict//--- description#propertydescription"Script draws \"Buy\" signs in the chart window."//--- display window of the input parameters during the script's launch#propertyscript_show_inputs//--- input parameters of the scriptinputcolorInpColor=C'3,95,172'; // Color of signs//+------------------------------------------------------------------+//| Create Buy sign |//+------------------------------------------------------------------+bool ArrowBuyCreate(constlong chart_ID=0, // chart's IDconststring name="ArrowBuy", // sign nameconstint sub_window=0, // subwindow indexdatetime time=0, // anchor point timedouble price=0, // anchor point priceconstcolor clr=C'3,95,172', // sign colorconstENUM_LINE_STYLE style=STYLE_SOLID, // line style (when highlighted)constint width=1, // line size (when highlighted)constbool back=false, // in the backgroundconstbool selection=false, // highlight to moveconstbool hidden=true, // hidden in the object listconstlong z_order=0) // priority for mouse click {//--- set anchor point coordinates if they are not set ChangeArrowEmptyPoint(time,price);//--- reset the error valueResetLastError();//--- create the signif(!ObjectCreate(chart_ID,name,OBJ_ARROW_BUY,sub_window,time,price)) {Print(__FUNCTION__,": failed to create \"Buy\" sign! Error code = ",GetLastError());return(false); }//--- set a sign colorObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);//--- set a line style (when highlighted)ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);//--- set a line size (when highlighted)ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);//--- display in the foreground (false) or background (true)ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);//--- enable (true) or disable (false) the mode of moving the sign by mouseObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);//--- hide (true) or display (false) graphical object name in the object listObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);//--- set the priority for receiving the event of a mouse click in the chartObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);//--- successful executionreturn(true); }//+------------------------------------------------------------------+//| Move the anchor point |//+------------------------------------------------------------------+bool ArrowBuyMove(constlong chart_ID=0, // chart's IDconststring name="ArrowBuy", // object namedatetime time=0, // anchor point time coordinatedouble price=0) // anchor point price coordinate {//--- if point position is not set, move it to the current bar having Bid priceif(!time) time=TimeCurrent();if(!price) price=SymbolInfoDouble(Symbol(),SYMBOL_BID);//--- reset the error valueResetLastError();//--- move the anchor pointif(!ObjectMove(chart_ID,name,0,time,price)) {Print(__FUNCTION__,": failed to move the anchor point! Error code = ",GetLastError());return(false); }//--- successful executionreturn(true); }//+------------------------------------------------------------------+//| Delete Buy sign |//+------------------------------------------------------------------+bool ArrowBuyDelete(constlong chart_ID=0, // chart's IDconststring name="ArrowBuy") // sign name {//--- reset the error valueResetLastError();//--- delete the signif(!ObjectDelete(chart_ID,name)) {Print(__FUNCTION__,": failed to delete \"Buy\" sign! Error code = ",GetLastError());return(false); }//--- successful executionreturn(true); }//+------------------------------------------------------------------+//| Check anchor point values and set default values |//| for empty ones |//+------------------------------------------------------------------+void ChangeArrowEmptyPoint(datetime &time,double &price) {//--- if the point's time is not set, it will be on the current barif(!time) time=TimeCurrent();//--- if the point's price is not set, it will have Bid valueif(!price) price=SymbolInfoDouble(Symbol(),SYMBOL_BID); }//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart() {datetime date[]; // array for storing dates of visible barsdouble low[]; // array for storing Low prices of visible barsdouble high[]; // array for storing High prices of visible bars//--- number of visible bars in the chart windowintbars=(int)ChartGetInteger(0,CHART_VISIBLE_BARS);//--- memory allocationArrayResize(date,bars);ArrayResize(low,bars);ArrayResize(high,bars);//--- fill the array of datesResetLastError();if(CopyTime(Symbol(),Period(),0,bars,date)==-1) {Print("Failed to copy time values! Error code = ",GetLastError());return; }//--- fill the array of Low pricesif(CopyLow(Symbol(),Period(),0,bars,low)==-1) {Print("Failed to copy the values of Low prices! Error code = ",GetLastError());return; }//--- fill the array of High pricesif(CopyHigh(Symbol(),Period(),0,bars,high)==-1) {Print("Failed to copy the values of High prices! Error code = ",GetLastError());return; }//--- create Buy signs in Low point for each visible barfor(int i=0;i<bars;i++) {if(!ArrowBuyCreate(0,"ArrowBuy_"+(string)i,0,date[i],low[i],InpColor))return;//--- check if the script's operation has been forcefully disabledif(IsStopped())return;//--- redraw the chartChartRedraw();// 0.05 seconds of delaySleep(50); }//--- move Buy signs to High point for each visible barfor(int i=0;i<bars;i++) {if(!ArrowBuyMove(0,"ArrowBuy_"+(string)i,date[i],high[i]))return;//--- check if the script's operation has been forcefully disabledif(IsStopped())return;//--- redraw the chartChartRedraw();// 0.05 seconds of delaySleep(50); }//--- delete Buy signsfor(int i=0;i<bars;i++) {if(!ArrowBuyDelete(0,"ArrowBuy_"+(string)i))return;//--- redraw the chartChartRedraw();// 0.05 seconds of delaySleep(50); }//--- }