//+------------------------------------------------------------------+ //| STS_1.10.mq5 | //| Azotskiy Aktiniy ICQ:695710750 | //| https://login.mql5.com/en/users/aktiniy | //+------------------------------------------------------------------+ #property copyright "Azotskiy Aktiniy ICQ:695710750" #property link "https://login.mql5.com/en/users/aktiniy" #property version "1.10" #property description "STS - Strategy Testing System" #property description " " #property description "Application for emulation of trading environment, based on indicator" #property description " " #property indicator_separate_window #property indicator_buffers 5 #property indicator_plots 1 //--- plot TST_C #property indicator_label1 "TST_C" #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 clrRed,clrBlue,C'0,0,0',C'0,0,0',C'0,0,0',C'0,0,0',C'0,0,0',C'0,0,0' #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input long magic_numb=65758473787389;// Magic number input datetime start=D'2017.08.03 00:00:00'; // Modeling start date input datetime stop=D'2017.09.01 00:00:00'; // Modeling end date input bool show_ask=true; // Display the Ask price input color col_bid=clrGray; // Color of the Bid line input color col_ask=clrRed; // Color of the Ask line input color col_buy=clrBlack; // Color of Buy orders input color col_sell=clrBlack; // Color of Sell orders input color col_tp=clrRed; // Color of Take Profit input color col_sl=clrBlue; // Color of Stop Loss input color col_info=clrRed; // Font color of the information panel //--- indicator buffers double TST_C_O[]; double TST_C_H[]; double TST_C_L[]; double TST_C_C[]; double TST_C_Col[]; //--- arrays with data for calculations MqlRates period_m1[]; MqlRates period_array[]; //--- the number of bars based on timeseries int bars_m1; int bars_period; //--- time and coordinate data of indicators datetime real_start=0; // deliberately earlier time to give an example of a good visualization datetime end_time_indicator=start; // the current time for indicator calculations int end_bar_indicator=0; // the currently drawn bar of the indicator int all_bars_indicator=0; // the number of all bars of the indicator, from the start to the current time //--- int bars_now_rates=0; // the number of bars in the modeling interval for the current period datetime time_open_end_rates=0; // the opening time of the current bar of the current period datetime time_open_next_rates=0; // opening time of the bar following the current bar of the current period int number_now_rates=0; // the current bar of the current period char status=1; // status of the filling function //--- state of the buttons bool button_play=false;// initial modeling value (pause) char button_speed=1;// initial speed value (button 1) //--- dynamic prices, Ask and Bid lines double price_bid_now=0; double price_ask_now=0; int spread=0;// spread value string line_bid="line_bid"; string line_ask="line_ask"; //--- int dig_pow=0;// multiplier based on the number of decimal places of the price //--- names of the global variables string time_end="time_indicator";// last time of the indicator string order_buy="order_buy";// buy order string order_sell="order_sell";// sell order string tp_buy="tp_buy";// take profit for a buy order string tp_sell="tp_sell";// take profit for a sell order string sl_buy="sl_buy";// stop loss for a buy order string sl_sell="sl_sell";// stop loss for a sell order string order_point="order_point";// profit in points string vol_buy="vol_buy"; // volume of a buy order string vol_sell="vol_sell"; // volume of a sell order string time_end_order_check="time_end_order_check"; // last checking time of order string info_point_all="info_point_all"; // number of points string info_point_last="info_point_last"; string info_point_now="info_point_real"; string info_vol_all="info_lot_all"; // volume of lots string info_vol_last="info_lot_last"; string info_vol_now="info_lot_real"; string info_money_all="info_money_all"; // size of profit string info_money_last="info_money_last"; string info_money_now="info_money_real"; bool del_status=false;// status for deleting global variables //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,TST_C_O,INDICATOR_DATA); SetIndexBuffer(1,TST_C_H,INDICATOR_DATA); SetIndexBuffer(2,TST_C_L,INDICATOR_DATA); SetIndexBuffer(3,TST_C_C,INDICATOR_DATA); SetIndexBuffer(4,TST_C_Col,INDICATOR_COLOR_INDEX); ArraySetAsSeries(TST_C_O,true); ArraySetAsSeries(TST_C_H,true); ArraySetAsSeries(TST_C_L,true); ArraySetAsSeries(TST_C_C,true); ArraySetAsSeries(TST_C_Col,true); ZeroMemory(TST_C_O); ZeroMemory(TST_C_H); ZeroMemory(TST_C_L); ZeroMemory(TST_C_C); ZeroMemory(TST_C_Col); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);// set the values to not be drawn IndicatorSetString(INDICATOR_SHORTNAME,"STS "+IntegerToString(magic_numb)); // indicator name IndicatorSetInteger(INDICATOR_DIGITS,_Digits);// display precision PlotIndexSetInteger(0,PLOT_SHOW_DATA,false);// prohibit displaying the results of the current values for the indicator PlotIndexSetInteger(1,PLOT_SHOW_DATA,false); //--- set the buttons func_button_create(0,"222","\\Images\\for_STS\\sell_on.bmp","\\Images\\for_STS\\sell_off.bmp",2,2,true); func_button_create(0,"1","\\Images\\for_STS\\up_on.bmp","\\Images\\for_STS\\up_off.bmp",48,2,true); func_button_create(0,"2","\\Images\\for_STS\\down_on.bmp","\\Images\\for_STS\\down_off.bmp",115,2,true); func_button_create(0,"111","\\Images\\for_STS\\buy_on.bmp","\\Images\\for_STS\\buy_off.bmp",137,2,true); func_button_create(0,"4","\\Images\\for_STS\\play.bmp","\\Images\\for_STS\\pause.bmp",185,2,true); func_button_create(0,"5","\\Images\\for_STS\\1_on.bmp","\\Images\\for_STS\\1_off.bmp",206,2,true); func_button_create(0,"6","\\Images\\for_STS\\2_on.bmp","\\Images\\for_STS\\2_off.bmp",227,2,false); func_button_create(0,"7","\\Images\\for_STS\\3_on.bmp","\\Images\\for_STS\\3_off.bmp",248,2,false); func_button_create(0,"8","\\Images\\for_STS\\4_on.bmp","\\Images\\for_STS\\4_off.bmp",269,2,false); func_button_create(0,"9","\\Images\\for_STS\\5_on.bmp","\\Images\\for_STS\\5_off.bmp",290,2,false); func_button_create(0,"10","\\Images\\for_STS\\6_on.bmp","\\Images\\for_STS\\6_off.bmp",311,2,false); func_button_create(0,"11","\\Images\\for_STS\\7_on.bmp","\\Images\\for_STS\\7_off.bmp",332,2,false); func_edit_create(0,"12",71,2,41,20,"0.01"); //--- the Del button func_button_create(0,"13","\\Images\\for_STS\\del_on.bmp","\\Images\\for_STS\\del_off.bmp",2,2,false); ObjectSetInteger(0,"13",OBJPROP_CORNER,CORNER_RIGHT_LOWER);// set the chart's corner, relative to which coordinates of the point are defined ObjectSetInteger(0,"13",OBJPROP_ANCHOR,ANCHOR_RIGHT_LOWER);// set the anchoring type //--- the Hide button func_button_create(0,"20","\\Images\\for_STS\\hide_on.bmp","\\Images\\for_STS\\hide_off.bmp",47,2,false); ObjectSetInteger(0,"20",OBJPROP_CORNER,CORNER_RIGHT_LOWER);// set the chart's corner, relative to which coordinates of the point are defined ObjectSetInteger(0,"20",OBJPROP_ANCHOR,ANCHOR_RIGHT_LOWER);// set the anchoring type //--- take profit management func_button_create(0,"14","\\Images\\for_STS\\up_on.bmp","\\Images\\for_STS\\up_off.bmp",2,24,true); func_edit_create(0,"15",24,24,41,20,"TP"); func_button_create(0,"16","\\Images\\for_STS\\down_on.bmp","\\Images\\for_STS\\down_off.bmp",67,24,true); //--- stop loss management func_button_create(0,"17","\\Images\\for_STS\\up_on.bmp","\\Images\\for_STS\\up_off.bmp",96,24,true); func_edit_create(0,"18",118,24,41,20,"SL"); func_button_create(0,"19","\\Images\\for_STS\\down_on.bmp","\\Images\\for_STS\\down_off.bmp",161,24,true); //--- setting the information labels "INFO panel" func_label_create(0,info_money_all,2,2,"Money All: 0.00",col_info); func_label_create(0,info_money_last,2,22,"Money Last: 0.00",col_info); func_label_create(0,info_money_now,2,44,"Money Now: 0.00",col_info); func_label_create(0,info_vol_all,2,66,"Volume All: 0.00",col_info); func_label_create(0,info_vol_last,2,88,"Volume Last: 0.00",col_info); func_label_create(0,info_vol_now,2,110,"Volume Now: 0.00",col_info); func_label_create(0,info_point_all,2,132,"Point All: 0",col_info); func_label_create(0,info_point_last,2,154,"Point Last: 0",col_info); func_label_create(0,info_point_now,2,176,"Point Now: 0",col_info); //--- set the last time, up to which the indicator was last drawn if(GlobalVariableCheck(time_end))end_time_indicator=datetime(GlobalVariableGet(time_end)); //--- calculate the time offset long win_bars=ChartGetInteger(0,CHART_VISIBLE_BARS,ChartWindowFind());// the number of bars that fit on the chart if((win_bars*3)=0) {ObjectSetDouble(0,line_ask,OBJPROP_PRICE,price_ask_now);} //--- the current values for orders int point_now=0; double vol_now=0; double money_now=0; if(ObjectFind(0,order_buy)>=0 && GlobalVariableGet(order_buy)>0)// a buy order is present { int p_now=int((price_bid_now-GlobalVariableGet(order_buy))*dig_pow); double v_now=GlobalVariableGet(vol_buy); double m_now=p_now*v_now*10; point_now+=p_now; vol_now+=v_now; money_now+=m_now; } if(ObjectFind(0,order_sell)>=0 && GlobalVariableGet(order_sell)>0)// a sell order is present { int p_now=int((GlobalVariableGet(order_sell)-price_ask_now)*dig_pow); double v_now=GlobalVariableGet(vol_sell); double m_now=p_now*v_now*10; point_now+=p_now; vol_now+=v_now; money_now+=m_now; } GlobalVariableSet(info_point_now,point_now); GlobalVariableSet(info_vol_now,vol_now); GlobalVariableSet(info_money_now,money_now); } COrder position; //object of the "COrder" class position.Delete(price_bid_now,price_ask_now,(-1)); position.Check(end_time_indicator,GlobalVariableGet(order_buy),GlobalVariableGet(tp_buy),GlobalVariableGet(sl_buy), GlobalVariableGet(order_sell),GlobalVariableGet(tp_sell),GlobalVariableGet(sl_sell)); func_info_print("Money All: ",info_money_all,2); func_info_print("Money Last: ",info_money_last,2); func_info_print("Money Now: ",info_money_now,2); func_info_print("Volume All: ",info_vol_all,2); func_info_print("Volume Last: ",info_vol_last,2); func_info_print("Volume Now: ",info_vol_now,2); func_info_print("Point All: ",info_point_all,0); func_info_print("Point Last: ",info_point_last,0); func_info_print("Point Now: ",info_point_now,0); position.Modify(); } //--- managing the Hide button char x=char(GlobalVariableGet("hide")); if(x==1) { ObjectSetInteger(0,"20",OBJPROP_STATE,false); ObjectSetInteger(0,"14",OBJPROP_YDISTANCE,24); ObjectSetInteger(0,"15",OBJPROP_YDISTANCE,24); ObjectSetInteger(0,"16",OBJPROP_YDISTANCE,24); ObjectSetInteger(0,"17",OBJPROP_YDISTANCE,24); ObjectSetInteger(0,"18",OBJPROP_YDISTANCE,24); ObjectSetInteger(0,"19",OBJPROP_YDISTANCE,24); } if(x==2) { ObjectSetInteger(0,"20",OBJPROP_STATE,true); ObjectSetInteger(0,"14",OBJPROP_YDISTANCE,-24); ObjectSetInteger(0,"15",OBJPROP_YDISTANCE,-24); ObjectSetInteger(0,"16",OBJPROP_YDISTANCE,-24); ObjectSetInteger(0,"17",OBJPROP_YDISTANCE,-24); ObjectSetInteger(0,"18",OBJPROP_YDISTANCE,-24); ObjectSetInteger(0,"19",OBJPROP_YDISTANCE,-24); } } //+------------------------------------------------------------------+ //| Func Info Print | //+------------------------------------------------------------------+ void func_info_print( string word, // added word string name, // name of the variable char bit // decimal places ) { string x=word+DoubleToString((NormalizeDouble(GlobalVariableGet(name),2)),bit); ObjectSetString(0,name,OBJPROP_TEXT,x); } //+------------------------------------------------------------------+ //| Class COrder | //+------------------------------------------------------------------+ class COrder { public: void Placed( char m_type,// order type (1-buy, 2-sell) double m_price_bid, // Bid price double m_price_ask, // Ask price int m_take_profit,// points to take profit int m_stop_loss // points to stop loss ) { switch(m_type) { case 1: { GlobalVariableSet(order_buy,m_price_ask); Line(GlobalVariableGet(order_buy),order_buy,col_buy,STYLE_SOLID,1,true); if(m_take_profit>0) { GlobalVariableSet(tp_buy,(m_price_ask+(_Point*m_take_profit))); Line(GlobalVariableGet(tp_buy),tp_buy,col_tp,STYLE_DASH,1,true); } if(m_stop_loss>0) { GlobalVariableSet(sl_buy,(m_price_ask-(_Point*m_stop_loss))); Line(GlobalVariableGet(sl_buy),sl_buy,col_sl,STYLE_DASH,1,true); } } break; case 2: { GlobalVariableSet(order_sell,m_price_bid); Line(GlobalVariableGet(order_sell),order_sell,col_sell,STYLE_SOLID,1,true); if(m_take_profit>0) { GlobalVariableSet(tp_sell,(m_price_bid-(_Point*m_take_profit))); Line(GlobalVariableGet(tp_sell),tp_sell,col_tp,STYLE_DASH,1,true); } if(m_stop_loss>0) { GlobalVariableSet(sl_sell,(m_price_bid+(_Point*m_stop_loss))); Line(GlobalVariableGet(sl_sell),sl_sell,col_sl,STYLE_DASH,1,true); } } break; } } void Delete( double m_price_bid,// Bid price double m_price_ask,// Ask price char m_del_manual// deletion type (-1 - auto, 1 - buy, 2 - sell) ) { switch(m_del_manual) { case(-1): if(ObjectFind(0,order_buy)<0 && GlobalVariableGet(order_buy)>0) {Small_del_buy(m_price_bid);} if(ObjectFind(0,order_sell)<0 && GlobalVariableGet(order_sell)>0) {Small_del_sell(m_price_ask);} break; case 1: if(ObjectFind(0,order_buy)>=0) { ObjectDelete(0,order_buy); Small_del_buy(m_price_bid); } break; case 2: if(ObjectFind(0,order_sell)>=0) { ObjectDelete(0,order_sell); Small_del_sell(m_price_ask); } break; } } void Modify() { Small_mod(order_buy,false,1); Small_mod(tp_buy,true,0); Small_mod(sl_buy,true,0); Small_mod(order_sell,false,2); Small_mod(tp_sell,true,0); Small_mod(sl_sell,true,0); } void Check( datetime m_time, double m_price_buy, double m_price_tp_buy, double m_price_sl_buy, double m_price_sell, double m_price_tp_sell, double m_price_sl_sell ) { int start_of_z=0; int end_of_z=0; datetime time_end_check=datetime(GlobalVariableGet(time_end_order_check)); if(time_end_check<=0){time_end_check=m_time;} GlobalVariableSet(time_end_order_check,m_time); start_of_z=Bars(_Symbol,PERIOD_M1,real_start,time_end_check); end_of_z=Bars(_Symbol,PERIOD_M1,real_start,m_time); for(int z=start_of_z; z0)// there is a BUY order { if(ObjectFind(0,tp_buy)>=0) { if(m_price_tp_buy<=p_bid_high && m_price_tp_buy>=p_bid_low)// TP triggered {del.Delete(m_price_tp_buy,0,1);}// close at the TP price } if(ObjectFind(0,sl_buy)>=0) { if(m_price_sl_buy>=p_bid_low && m_price_sl_buy<=p_bid_high)// SL triggered {del.Delete(m_price_sl_buy,0,1);}// close at the SL price } } if(m_price_sell>0)// there is a SELL order { if(ObjectFind(0,tp_sell)>=0) { if(m_price_sl_sell<=p_ask_high && m_price_sl_sell>=p_ask_low)// SL triggered {del.Delete(0,m_price_sl_sell,2);}// close at the SL price } if(ObjectFind(0,sl_sell)>=0) { if(m_price_tp_sell>=p_ask_low && m_price_tp_sell<=p_ask_high)// TP triggered {del.Delete(0,m_price_tp_sell,2);}// close at the TP price } } } } void Line(double m_price,// price to place the order opening line string m_line_name, //line name color m_line_color, // line color ENUM_LINE_STYLE m_line_style,// line style int m_line_width,// line width bool m_line_selection // possibility to select and move ) { if(!ObjectCreate(0,m_line_name,OBJ_HLINE,ChartWindowFind(),0,m_price))// create a horizontal line { Print(__FUNCTION__,": failed to create a horizontal line! Error code = ",GetLastError()); } ObjectSetInteger(0,m_line_name,OBJPROP_COLOR,m_line_color);// set the line color ObjectSetInteger(0,m_line_name,OBJPROP_STYLE,m_line_style);// set the line display style ObjectSetInteger(0,m_line_name,OBJPROP_WIDTH,m_line_width);// set the line width ObjectSetInteger(0,m_line_name,OBJPROP_BACK,true);// display in the foreground (false) or background (true) ObjectSetInteger(0,m_line_name,OBJPROP_SELECTABLE,m_line_selection);// enable (true) or disable (false) the mode of moving the line with the mouse ObjectSetInteger(0,m_line_name,OBJPROP_SELECTED,false); ObjectSetInteger(0,m_line_name,OBJPROP_HIDDEN,true);// hide (true) or display (false) the graphical object name in the object list ObjectSetInteger(0,m_line_name,OBJPROP_ZORDER,0);// set the priority for receiving the event of a mouse click on the chart } private: void Small_mod(string m_name,// name of the object and global variable bool m_mode,// permission to change position char m_type//1-buy, 2-sell ) { if(ObjectFind(0,m_name)>=0) { double price_obj_double=ObjectGetDouble(0,m_name,OBJPROP_PRICE); int price_obj=int(price_obj_double*dig_pow); double price_glo_double=GlobalVariableGet(m_name); int price_glo=int(price_glo_double*dig_pow); if(price_obj!=price_glo && m_mode==true) { GlobalVariableSet(m_name,(double(price_obj)/double(dig_pow))); } if(price_obj!=price_glo && m_mode==false) { switch(m_type) { case 1:// order buy if(price_obj>price_glo)//TP { GlobalVariableSet(tp_buy,(double(price_obj)/double(dig_pow))); Line(GlobalVariableGet(tp_buy),tp_buy,col_tp,STYLE_DASH,1,true); } if(price_objprice_glo)//SL { GlobalVariableSet(sl_sell,(double(price_obj)/double(dig_pow))); Line(GlobalVariableGet(sl_sell),sl_sell,col_sl,STYLE_DASH,1,true); } if(price_obj=0)ObjectDelete(0,tp_buy);// delete the take profit line if(ObjectFind(0,sl_buy)>=0)ObjectDelete(0,sl_buy);// delete the stop loss line int point_plus=int(MathRound((m_price_bid-GlobalVariableGet(order_buy))/_Point));// calculate the profit of a trade GlobalVariableSet(order_buy,0); // zero the variable for the price of the placed order GlobalVariableSet(info_vol_last,GlobalVariableGet(vol_buy)); GlobalVariableSet(vol_buy,0); GlobalVariableSet(info_point_last,point_plus); GlobalVariableSet(info_money_last,(GlobalVariableGet(info_point_last)*GlobalVariableGet(info_vol_last)*10)); Small_concatenation(info_point_all,info_point_last); Small_concatenation(info_vol_all,info_vol_last); Small_concatenation(info_money_all,info_money_last); } void Small_del_sell(double m_price_ask) { if(ObjectFind(0,tp_sell)>=0)ObjectDelete(0,tp_sell);// delete the take profit line if(ObjectFind(0,sl_sell)>=0)ObjectDelete(0,sl_sell);// delete the stop loss line int point_plus=int(MathRound((GlobalVariableGet(order_sell)-m_price_ask)/_Point));// calculate the profit of a trade GlobalVariableSet(order_sell,0); // zero the variable for the price of the placed order GlobalVariableSet(info_vol_last,GlobalVariableGet(vol_sell)); GlobalVariableSet(vol_sell,0); GlobalVariableSet(info_point_last,point_plus); GlobalVariableSet(info_money_last,(GlobalVariableGet(info_point_last)*GlobalVariableGet(info_vol_last)*10)); Small_concatenation(info_point_all,info_point_last); Small_concatenation(info_vol_all,info_vol_last); Small_concatenation(info_money_all,info_money_last); } void Small_concatenation(string m_name_first, string m_name_second) { if(GlobalVariableGet(m_name_first)==0) {GlobalVariableSet(m_name_first,GlobalVariableGet(m_name_second));} else { double conc=GlobalVariableGet(m_name_first); conc+=GlobalVariableGet(m_name_second); GlobalVariableSet(m_name_first,conc); } } }; //+------------------------------------------------------------------+ //| Func Merger | //+------------------------------------------------------------------+ void func_merger() { switch(button_speed) { case 1: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_of_form_jeweler_candle(period_m1,bars_m1,time_open_end_rates,end_time_indicator,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); } break; case 2: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_of_form_candle(period_m1,bars_m1,time_open_end_rates,end_time_indicator,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); end_time_indicator+=func_calc_time(time_open_end_rates,time_open_next_rates,13); } break; case 3: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_of_form_candle(period_m1,bars_m1,time_open_end_rates,end_time_indicator,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); end_time_indicator+=func_calc_time(time_open_end_rates,time_open_next_rates,11); } break; case 4: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_of_form_candle(period_m1,bars_m1,time_open_end_rates,end_time_indicator,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); end_time_indicator+=func_calc_time(time_open_end_rates,time_open_next_rates,9); } break; case 5: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_of_form_candle(period_m1,bars_m1,time_open_end_rates,end_time_indicator,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); end_time_indicator+=func_calc_time(time_open_end_rates,time_open_next_rates,7); } break; case 6: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_of_form_candle(period_m1,bars_m1,time_open_end_rates,end_time_indicator,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); end_time_indicator+=func_calc_time(time_open_end_rates,time_open_next_rates,5); } break; case 7: { func_filling(period_array,end_time_indicator,all_bars_indicator,time_open_end_rates,time_open_next_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); func_candle_per_seconds(period_array,end_time_indicator,bars_now_rates,number_now_rates,end_bar_indicator,TST_C_O,TST_C_H,TST_C_L,TST_C_C,TST_C_Col,status); price_bid_now=TST_C_C[end_bar_indicator]; price_ask_now=price_bid_now+(spread*_Point); } break; } } //+------------------------------------------------------------------+ //| Func Calc Time | //+------------------------------------------------------------------+ int func_calc_time(datetime time_s, // initial bar time datetime time_e, // end bar time char part) // part of the acceleration { int x=int(time_e)-int(time_s); x=x/part; return(x); } //+------------------------------------------------------------------+ //| Func Candle Per Seconds | //+------------------------------------------------------------------+ void func_candle_per_seconds(MqlRates &input_rates[], datetime &input_end_time_indicator, int input_bars_now_rates, int input_number_now_rates, int &input_end_bar_indicator, double &output_o[], double &output_h[], double &output_l[], double &output_c[], double &output_col[], char &work_status) { if(work_status==-1) { if(input_number_now_ratesoutput_c[input_end_bar_indicator])output_col[input_end_bar_indicator]=0; else output_col[input_end_bar_indicator]=1; } input_end_bar_indicator--; output_o[input_end_bar_indicator]=input_rates[input_number_now_rates].open; output_h[input_end_bar_indicator]=input_rates[input_number_now_rates].high; output_l[input_end_bar_indicator]=input_rates[input_number_now_rates].low; output_c[input_end_bar_indicator]=input_rates[input_number_now_rates].close; if(output_o[input_end_bar_indicator]>output_c[input_end_bar_indicator])output_col[input_end_bar_indicator]=0; else output_col[input_end_bar_indicator]=1; input_end_time_indicator=input_rates[input_number_now_rates+1].time; } } } //+------------------------------------------------------------------+ //| Func Filling | //+------------------------------------------------------------------+ void func_filling(MqlRates &input_rates[],// input data (of the current period) to fill datetime input_end_time_indicator,// the current time of the indicator int input_all_bars_indicator,// the number of all bars of the indicator datetime &output_time_end_filling,// the opening time of the last bar datetime &output_time_next_filling,// the opening time of the next bar int input_end_bar_indicator,// the current (drawn) bar of the indicator double &output_o[], double &output_h[], double &output_l[], double &output_c[], double &output_col[], char &work_status) // operation status { if(work_status==1) { int stopped_rates_bar; for(int x=input_all_bars_indicator,y=0;x>0;x--,y++) { if(input_rates[y].timeoutput_c[x])output_col[x]=0; else output_col[x]=1; output_time_end_filling=input_rates[y].time; output_time_next_filling=input_rates[y+1].time; input_end_bar_indicator=x; stopped_rates_bar=y; } else break; } output_o[input_end_bar_indicator]=input_rates[stopped_rates_bar].open; output_h[input_end_bar_indicator]=output_o[input_end_bar_indicator]; output_l[input_end_bar_indicator]=output_o[input_end_bar_indicator]; output_c[input_end_bar_indicator]=output_o[input_end_bar_indicator]; work_status=-1; } } //+------------------------------------------------------------------+ //| Func Of Form Candle | //+------------------------------------------------------------------+ void func_of_form_candle(MqlRates &input_rates[], int input_bars, datetime &input_time_end_filling, datetime &input_end_time_indicator, datetime &input_time_next_filling, int input_end_bar_indicator, double &output_o[], double &output_h[], double &output_l[], double &output_c[], double &output_col[], char &work_status) { if(work_status==-1) { int start_of_z=0; int end_of_z=0; start_of_z=Bars(_Symbol,PERIOD_M1,real_start,input_time_end_filling); end_of_z=Bars(_Symbol,PERIOD_M1,real_start,input_end_time_indicator); for(int z=start_of_z; zinput_rates[z].low)output_l[input_end_bar_indicator]=input_rates[z].low; if(output_o[input_end_bar_indicator]>output_c[input_end_bar_indicator])output_col[input_end_bar_indicator]=0; else output_col[input_end_bar_indicator]=1; } if(input_end_time_indicator>=input_time_next_filling)work_status=1; } } //+------------------------------------------------------------------+ //| Func Of Form Jeweler Candle | //+------------------------------------------------------------------+ void func_of_form_jeweler_candle(MqlRates &input_rates[],// information for generating ticks int input_bars,// size of the information array datetime &input_time_end_filling,// end time of quick fill datetime &input_end_time_indicator,// the last simulation time of the indicator datetime &input_time_next_filling, // time remaining until a full bar of the current timeframe is completely formed int input_end_bar_indicator,// the currently drawn bar of the indicator double &output_o[], double &output_h[], double &output_l[], double &output_c[], double &output_col[], char &work_status // operation end type (command for the quick fill function) ) { if(work_status==-1) { int start_of_z=0; int current_of_z=0; start_of_z=Bars(_Symbol,PERIOD_M1,real_start,input_time_end_filling)-1; current_of_z=Bars(_Symbol,PERIOD_M1,real_start,input_end_time_indicator)-1; if(start_of_zinput_rates[z].low)output_l[input_end_bar_indicator]=input_rates[z].low; if(output_o[input_end_bar_indicator]>output_c[input_end_bar_indicator])output_col[input_end_bar_indicator]=0; else output_col[input_end_bar_indicator]=1; } input_end_time_indicator=input_rates[current_of_z].time; } // get the ticks in the array static int x=0;// array counter and start flag static double tick_current[]; static int tick_current_size=0; if(x==0) { int i=current_of_z-1; func_tick_generation(input_rates[i],tick_current); tick_current_size=ArraySize(tick_current); if(output_h[input_end_bar_indicator]==0) {output_h[input_end_bar_indicator]=tick_current[x];} if(output_l[input_end_bar_indicator]==0) {output_l[input_end_bar_indicator]=tick_current[x];} output_c[input_end_bar_indicator]=tick_current[x]; } if(xoutput_h[input_end_bar_indicator]) {output_h[input_end_bar_indicator]=tick_current[x];} if(tick_current[x]output_c[input_end_bar_indicator])output_col[input_end_bar_indicator]=0; else output_col[input_end_bar_indicator]=1; x++; } else { input_end_time_indicator=input_rates[current_of_z+1].time; x=0; tick_current_size=0; ArrayFree(tick_current); } if(input_end_time_indicator>input_time_next_filling) {work_status=1;} } } //+------------------------------------------------------------------+ //| Func Tick Generation | //+------------------------------------------------------------------+ void func_tick_generation( MqlRates &rates,// data on candle double &tick[]// dynamic array of ticks ) { if(rates.open==rates.close && rates.high==rates.low && rates.open==rates.high){rates.tick_volume=1;} if(rates.tick_volume<4)// less than four ticks { ArrayResize(tick,int(rates.tick_volume));// resize the array to the number of ticks if(rates.tick_volume==1)tick[0]=rates.close;// one tick if(rates.tick_volume==2)// two ticks { tick[0]=rates.open; tick[1]=rates.close; } if(rates.tick_volume==3)// three ticks { tick[0]=rates.open; tick[2]=rates.close; if(rates.open==rates.close)// went in one direction and returned to the level of Open { if(rates.high==rates.open)tick[1]=rates.low; if(rates.low==rates.open)tick[1]=rates.high; } if(rates.close==rates.low && rates.open!=rates.high)tick[1]=rates.high;// went in one direction, rolled back and broke the level of Open if(rates.close==rates.high && rates.open!=rates.low)tick[1]=rates.low; if(rates.open==rates.high && rates.close!=rates.low)tick[1]=rates.low;// went in one direction, rolled back, but did not break the level of Open if(rates.open==rates.low && rates.close!=rates.high)tick[1]=rates.high; if((rates.open==rates.low && rates.close==rates.high) || (rates.open==rates.high && rates.close==rates.low)) { tick[1]=NormalizeDouble((((rates.high-rates.low)/2)+rates.low),_Digits);// several points in one direction } } } if(rates.tick_volume>3)// more than three ticks { // calculate the candle size by points int candle_up=0; int candle_down=0; int candle_centre=0; if(rates.open>rates.close) { candle_up=int(MathRound((rates.high-rates.open)/_Point)); candle_down=int(MathRound((rates.close-rates.low)/_Point)); } if(rates.open<=rates.close) { candle_up=int(MathRound((rates.high-rates.close)/_Point)); candle_down=int(MathRound((rates.open-rates.low)/_Point)); } candle_centre=int(MathRound((rates.high-rates.low)/_Point)); int candle_all=candle_up+candle_down+candle_centre;// total length of movement int point_max=int(MathRound(double(candle_all)/2));// the maximum possible number of ticks double share_up=double(candle_up)/double(candle_all); double share_down=double(candle_down)/double(candle_all); double share_centre=double(candle_centre)/double(candle_all); // calculate the number of reference points on each section char point=0; if(rates.tick_volume<10)point=char(rates.tick_volume); else point=10; if(point>point_max)point=char(point_max); char point_up=char(MathRound(point*share_up)); char point_down=char(MathRound(point*share_down)); char point_centre=char(MathRound(point*share_centre)); // check for reference points on the selected ranges if(candle_up>0 && point_up==0) {point_up=1;point_centre=point_centre-1;} if(candle_down>0 && point_down==0) {point_down=1;point_centre=point_centre-1;} // resize the output array ArrayResize(tick,11); char p=0;// index of the ticks array (tick[]) tick[p]=rates.open;// the first tick is equal to the Open price if(rates.open>rates.close)// downward { func_tick_small(rates.high,1,candle_up,point_up,tick,p); func_tick_small(rates.low,-1,candle_centre,point_centre,tick,p); func_tick_small(rates.close,1,candle_down,point_down,tick,p); ArrayResize(tick,p+1); } if(rates.open<=rates.close)// upward or Doji { func_tick_small(rates.low,-1,candle_down,point_down,tick,p); func_tick_small(rates.high,1,candle_centre,point_centre,tick,p); func_tick_small(rates.close,-1,candle_up,point_up,tick,p); ArrayResize(tick,p+1); } } } //+------------------------------------------------------------------+ //| Func Tick Small | //+------------------------------------------------------------------+ void func_tick_small( double end,// end of movement char route,// direction of movement int candle,// distance of movement char point,// the number of points double &tick[],// array of ticks char &i// the current index of the array ) { if(point==1) { i++; if(i>10)i=10;// adjustment tick[i]=end; } if(point>1) { double wave_v=(point+1)/2; double step_v=(candle-1)/MathFloor(wave_v)+1; step_v=MathFloor(step_v); for(char p_v=i+1,i_v=i; p_v10)i=10;// adjustment tick[i]=end; } } } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if(CHARTEVENT_KEYDOWN==id) { if(lparam==67)//--- the 'C' key { //--- copy data func_copy_period(real_start,stop,bars_m1,period_m1,PERIOD_M1); func_copy_period(real_start,stop,bars_period,period_array,_Period); } } if(CHARTEVENT_OBJECT_CLICK==id) { switch(int(StringToInteger(sparam))) { case 222://sell { if(GlobalVariableGet(order_sell)==0) { string input_edit=ObjectGetString(0,"15",OBJPROP_TEXT);// get TP and SL int tp=int(StringToInteger(input_edit)); input_edit=ObjectGetString(0,"18",OBJPROP_TEXT); int sl=int(StringToInteger(input_edit)); bool go=false; if(tp>spread*3 || tp==0)go=true; else Alert("TP must be 3 or more times greater than spread"); if(sl>spread*3 || sl==0)go=true; else Alert("SL must be 3 or more times greater than spread"); input_edit=ObjectGetString(0,"12",OBJPROP_TEXT); double input_double=NormalizeDouble(StringToDouble(input_edit),2); if(go==true && input_double>0) { COrder sell; sell.Placed(2,price_bid_now,price_ask_now,tp,sl); GlobalVariableSet(vol_sell,input_double); } } else { COrder del; del.Delete(price_bid_now,price_ask_now,2); } ObjectSetInteger(0,sparam,OBJPROP_STATE,true); } break; case 1://up func_change_edit("12",0.01,1); ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 2://down func_change_edit("12",0.01,2); ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 111://buy if(GlobalVariableGet(order_buy)==0) { string input_edit=ObjectGetString(0,"15",OBJPROP_TEXT);// get TP and SL int tp=int(StringToInteger(input_edit)); input_edit=ObjectGetString(0,"18",OBJPROP_TEXT); int sl=int(StringToInteger(input_edit)); bool go=false; if(tp>spread*3 || tp==0)go=true; else Alert("TP must be 3 or more times greater than spread"); if(sl>spread*3 || sl==0)go=true; else Alert("SL must be 3 or more times greater than spread"); input_edit=ObjectGetString(0,"12",OBJPROP_TEXT); double input_double=NormalizeDouble(StringToDouble(input_edit),2); if(go==true && input_double>0) { COrder buy; buy.Placed(1,price_bid_now,price_ask_now,tp,sl); GlobalVariableSet(vol_buy,input_double); } } else { COrder del; del.Delete(price_bid_now,price_ask_now,1); } ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 4: if(ObjectGetInteger(0,sparam,OBJPROP_STATE)==true) button_play=false; else button_play=true; break; case 5:// button "1" func_change_speed_button(sparam); button_speed=1; status=1; break; case 6:// button "2" func_change_speed_button(sparam); button_speed=2; status=1; break; case 7:// button "3" func_change_speed_button(sparam); button_speed=3; status=1; break; case 8:// button "4" func_change_speed_button(sparam); button_speed=4; status=1; break; case 9:// button "5" func_change_speed_button(sparam); button_speed=5; status=1; break; case 10:// button "6" func_change_speed_button(sparam); button_speed=6; status=1; break; case 11:// button "7" func_change_speed_button(sparam); button_speed=7; status=1; break; case 13:// button "Del" ObjectSetInteger(0,"13",OBJPROP_STATE,true); del_status=true; Alert("Deletion of global variables has been successfully set"); Alert("Change the terminal, reattach the indicator or restart the terminal"); break; case 14:// up_TP func_change_edit("15",1,1); ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 16:// down_TP func_change_edit("15",1,2); ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 17:// up_SL func_change_edit("18",1,1); ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 19:// down_SL func_change_edit("18",1,2); ObjectSetInteger(0,sparam,OBJPROP_STATE,true); break; case 20:// button "Hide" { char x=char(GlobalVariableGet("hide")); if(x==0 || x==1) { ObjectSetInteger(0,sparam,OBJPROP_STATE,true); GlobalVariableSet("hide",2); } if(x==2) { ObjectSetInteger(0,sparam,OBJPROP_STATE,false); GlobalVariableSet("hide",1); } } break; } } ChartRedraw(); } //+------------------------------------------------------------------+ //| Func Change Edit | //+------------------------------------------------------------------+ void func_change_edit( string name_edit,// name of the edit box double factor,// multiplier char up_or_down//1-up, 2-down ) { string input_edit=ObjectGetString(0,name_edit,OBJPROP_TEXT); double input_double=StringToDouble(input_edit); switch(up_or_down) { case 1: input_double=input_double+(1*factor); if(factor==1){ObjectSetString(0,name_edit,OBJPROP_TEXT,string(int(input_double)));} else{ObjectSetString(0,name_edit,OBJPROP_TEXT,DoubleToString(NormalizeDouble(input_double,2),2));} break; case 2: input_double=input_double-(1*factor); if(input_double>0) { if(factor==1){ObjectSetString(0,name_edit,OBJPROP_TEXT,string(int(input_double)));} else{ObjectSetString(0,name_edit,OBJPROP_TEXT,DoubleToString(NormalizeDouble(input_double,2),2));} } else { if(factor==1){ObjectSetString(0,name_edit,OBJPROP_TEXT,"0");} else{ObjectSetString(0,name_edit,OBJPROP_TEXT,"0.0");} } break; } } //+------------------------------------------------------------------+ //| Func Change Speed Button | //+------------------------------------------------------------------+ void func_change_speed_button( string name_push_button // Name of the pressed button ) { for(int x=5;x<12;x++) { string name=IntegerToString(x); if(name!=name_push_button) ObjectSetInteger(0,name,OBJPROP_STATE,false);// set the state of the button (released) } } //+------------------------------------------------------------------+ //| Func Copy Period | //+------------------------------------------------------------------+ void func_copy_period( datetime fcopy_start,// start date datetime fcopy_stop,// stop date int &fcopy_bars,// the number of candles MqlRates &fcopy_period[],// array of data to be filled ENUM_TIMEFRAMES fcopy_timeframes// period ) { fcopy_bars=Bars(_Symbol,fcopy_timeframes,fcopy_start,fcopy_stop);// count the number of candles in history ArrayResize(fcopy_period,fcopy_bars+1);// resize the receiver array int copy=CopyRates(_Symbol,fcopy_timeframes,fcopy_start,fcopy_stop,fcopy_period);// copy the data if(copy==-1)Alert("Copy error, period ",EnumToString(fcopy_timeframes),", press С"); else Print("Copying of period ",EnumToString(fcopy_timeframes),", is successful"); } //+------------------------------------------------------------------+ //| Func Button Create | //+------------------------------------------------------------------+ void func_button_create( long chart_ID, string name,// button name string file_on,// "on" image string file_off,// "off" image int x,// X position int y,// Y position bool state// button state ) { ObjectCreate(chart_ID,name,OBJ_BITMAP_LABEL,ChartWindowFind(),0,0);// create the button ObjectSetString(chart_ID,name,OBJPROP_BMPFILE,0,file_on);// image for the "on" state ObjectSetString(chart_ID,name,OBJPROP_BMPFILE,1,file_off);// image for the "off" state ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);// set the button coordinates ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,0);// set the visibility area of the button ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,0); ObjectSetInteger(chart_ID,name,OBJPROP_XOFFSET,0);// set the image part that has to be displayed in the visibility area ObjectSetInteger(chart_ID,name,OBJPROP_YOFFSET,0); ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);// set the state of the button (released) ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);// set the chart's corner, relative to which coordinates of the point are defined ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,ANCHOR_LEFT_UPPER);// set the anchoring method ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clrBlack);// set the border color when object selection mode is enabled ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,STYLE_SOLID);// set the border style when object selection mode is enabled ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,1);// set a size of the anchor point for moving an object ObjectSetInteger(chart_ID,name,OBJPROP_BACK,false);// display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,false);// enable (true) or disable (false) the mode of moving the label with the mouse ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,false); ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,true);// hide (true) or display (false) the graphical object name in the object list ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,0);// set the priority for receiving the event of a mouse click on the chart } //+------------------------------------------------------------------+ //| Func Edit Create | //+------------------------------------------------------------------+ void func_edit_create( long chart_ID, string name,// button name int x,// X position int y,// Y position int width,// width int height,// height string text// width ) { ObjectCreate(chart_ID,name,OBJ_EDIT,ChartWindowFind(),0,0);// create the edit box ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);// set the edit box coordinates ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);// set the edit box size ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height); ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);// fill the edit box ObjectSetString(chart_ID,name,OBJPROP_FONT,"Consolas");// set the font ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,10); // set the font size ObjectSetInteger(chart_ID,name,OBJPROP_ALIGN,ALIGN_RIGHT);// set the text alignment mode ObjectSetInteger(chart_ID,name,OBJPROP_READONLY,false);// cancel (false) the read-only mode ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);// set the chart's corner, relative to which coordinates of the object are defined ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clrBlack);// set the text color ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,clrWhiteSmoke);// set the background color ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,clrDarkGray);// set the border color ObjectSetInteger(chart_ID,name,OBJPROP_BACK,false);// display in the foreground (false) ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,false);// disable (false) the mode of moving the label with the mouse ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,false); ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,true);// hide (true) the name in the object list ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,0);// set the priority for receiving the event of a mouse click on the chart } //+------------------------------------------------------------------+ //| Func Label Create | //+------------------------------------------------------------------+ void func_label_create( long chart_ID, string name,// name of the text label int x,// X position int y,// Y position string text,// text color color_label ) { if(!ObjectCreate(chart_ID,name,OBJ_LABEL,ChartWindowFind(),0,0))//--- create the text label { Print(__FUNCTION__, ": failed to create the text label! Error code = ",GetLastError()); } ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);// set the label coordinates ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);// set the chart's corner, relative to which coordinates of the point are defined ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);// set the text ObjectSetString(chart_ID,name,OBJPROP_FONT,"Consolas");// set the text font ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,13);// set the font size ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,0);// set the slope of the text ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);// set the anchoring method ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,color_label);// set the color ObjectSetInteger(chart_ID,name,OBJPROP_BACK,false);// display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,false);// enable (true) or disable (false) the mode of moving the label with the mouse ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,false); ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,true);// hide (true) or display (false) the graphical object name in the object list ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,0);// set the priority for receiving the event of a mouse click on the chart } //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if(del_status) { GlobalVariableDel(time_end); GlobalVariableDel(order_buy); GlobalVariableDel(order_sell); GlobalVariableDel(tp_buy); GlobalVariableDel(tp_sell); GlobalVariableDel(sl_buy); GlobalVariableDel(sl_sell); GlobalVariableDel(order_point); GlobalVariableDel(vol_buy); GlobalVariableDel(vol_sell); GlobalVariableDel(time_end_order_check); GlobalVariableDel(info_point_all); GlobalVariableDel(info_point_last); GlobalVariableDel(info_point_now); GlobalVariableDel(info_vol_all); GlobalVariableDel(info_vol_last); GlobalVariableDel(info_vol_now); GlobalVariableDel(info_money_all); GlobalVariableDel(info_money_last); GlobalVariableDel(info_money_now); Print("Global variables deleted"); } else { GlobalVariableSet(time_end,end_time_indicator); } } //+------------------------------------------------------------------+