Почитай документацию подробно. Я оттуда все брал для работы
с объектами. Там есть функция вроде ObjectTotal(), пробегая по всем
объектам мы смотрим их имена. А имя присваиваем при создании
объекта.
Вот пример.
Вот пример.
#property indicator_chart_window extern int period_for_channel=6; extern int period_for_average=3; extern int time_before_change=20; datetime BarTime=0; double AveragePrice = 0; double PriceForChannel[]; int Signal=-1; string arrowName="Arrow"; int AKDC; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ bool isNewBar() { //---- bool res=false; if (BarTime!=Time[0]) { BarTime=Time[0]; res=true; } //---- return(res); } //1- покупка, -1 - продажа int MakeDeal (int deal) { if ( !GlobalVariableCheck( Symbol()+"AKDC" ) ) if ( GlobalVariableSet ( Symbol()+"AKDC", AKDC ) > 0 ) if ( !GlobalVariableCheck( Symbol() ) ) if ( GlobalVariableSet ( Symbol(), deal ) > 0 ) return(1); } int init() { //---- indicators ObjectCreate("line_up",OBJ_TREND,0,Time[1], 0,Time[1],0); ObjectCreate("line_down",OBJ_TREND,0,Time[1], 0,Time[1],0); ObjectCreate("Average",OBJ_TREND,0,Time[1], 0,Time[1],0); ObjectCreate("AKDC",OBJ_LABEL,0,0,0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("line_up"); ObjectDelete("line_down"); ObjectDelete("Average"); ObjectDelete("AKDC"); ObjectDelete(arrowName); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- if ((Minute()==59)&&(Seconds( )>=40)) ObjectSet("AKDC",OBJPROP_COLOR,Red); if (isNewBar()) { ArrayResize(PriceForChannel,period_for_channel*2); for (int i=0;i<period_for_channel;i++) { PriceForChannel[2*i]=Open[i+1]; PriceForChannel[2*i+1]=Close[i+1]; } int max_index=ArrayMaximum(PriceForChannel); int min_index=ArrayMinimum(PriceForChannel); double MAX_PRICE=PriceForChannel[max_index]; double MIN_PRICE=PriceForChannel[min_index]; ObjectDelete("line_up"); ObjectDelete("line_down"); ObjectDelete("Average"); ObjectCreate("line_up",OBJ_TREND,0,Time[period_for_channel], MAX_PRICE,Time[1],MAX_PRICE); ObjectSet("line_up",OBJPROP_COLOR,Blue); ObjectSet("line_up",OBJPROP_RAY,False); ObjectCreate("line_down",OBJ_TREND,0,Time[period_for_channel], MIN_PRICE,Time[1],MIN_PRICE); ObjectSet("line_down",OBJPROP_COLOR,Blue); ObjectSet("line_down",OBJPROP_RAY,False); ObjectSet("AKDC", OBJPROP_CORNER,1 ); ObjectSet("AKDC", OBJPROP_XDISTANCE, 30); ObjectSet("AKDC", OBJPROP_YDISTANCE, 30); AKDC=(MAX_PRICE-MIN_PRICE)/Point; ObjectSetText("AKDC", "АКДЦ = "+(AKDC), 12, "Times New Roman", Green); AveragePrice = 0; for (int j=0;j<period_for_average;j++) AveragePrice+=Open[j+1]+Close[j+1]; AveragePrice=NormalizeDouble(AveragePrice/(2*period_for_average),Digits); ObjectCreate("Average",OBJ_TREND,0,Time[period_for_average], AveragePrice,Time[1],AveragePrice); ObjectSet("Average",OBJPROP_COLOR,Green); } if ((Ask>AveragePrice)&&(Signal!=1)) { ObjectDelete(arrowName); ObjectCreate(arrowName,OBJ_ARROW,0,Time[0],Low[0]-Point*10); ObjectSet(arrowName,OBJPROP_ARROWCODE,241); ObjectSet(arrowName,OBJPROP_COLOR,Blue); Signal=1; MakeDeal(Signal); } if ((Bid<AveragePrice)&&(Signal!=-1)) { ObjectDelete(arrowName); ObjectCreate(arrowName,OBJ_ARROW,0,Time[0],High[0]+Point*10); ObjectSet(arrowName,OBJPROP_ARROWCODE,242); ObjectSet(arrowName,OBJPROP_COLOR,Blue); Signal=-1; MakeDeal(Signal); } //---- return(0); } //+------------------------------------------------------------------+
Спасибо!
Смысла дорабатывать разработки под MT3 еже нет.
Перехожу на MT4, там все проще.(лучше поздно, чем никогда)
Спасибо
Тема закрыта.
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
В MT4 есть функция FindObject. А в MT3 не знаю как подступиться.
Хоть бы название объектов знать, которые по умолчанию присваиваются OBJ_HLine и OBJ_TRENDLINE, можно было бы их методом перебора найти.
Помогите, пожалуйста!