Может кто-нибудь помочь мне с этим кодом. Он не совсем правильно рисует линии тренда. Или, если у кого-то есть лучший способ, пожалуйста, дайте мне знать.
Введенный код #property indior_chart_window #property indior_buffers 2 extern int varExtDepth = 12; extern int varExtDeviation = 5; extern int varExtBackstep = 3; двойной потолок № 91; # 93 ;; двойной пол # 91; # 93 ;; int init () {//---- indiorBuffers (2); IndiorDigits (цифры);/---- настройки рисунка/---- отображение буферов indior SetIndexBuffer (0, потолок); SetIndexBuffer (1, этаж); SetIndexLabel (0, верхняя полоса); SetIndexLabel (1, нижняя полоса); SetIndexEmptyValue (0,0.0); SetIndexEmptyValue (1,0.0); ArraySetAsSeries (потолок, правда); ArraySetAsSeries (пол, правда);/---- return (0); } int deinit () {//---- ObjectDelete (Потолок); ObjectDelete (покрытие);/---- return (0); } int start () {//int counted_bars = IndiorCounted ();/---- int shift; bool varNewBar = funcIsNewBar (Period ()); if (varNewBar) {ObjectDelete (Потолок); ObjectDelete (покрытие); procDrawTrends (); for (shift = Bars-1; shiftgt; = 0; shift--) {потолок # 91; shift # 93; = ObjectGetValueByShift (Потолок, сдвиг); пол # 91; сдвиг # 93; = ObjectGetValueByShift (покрытие, сдвиг); }} return (0); }/ ---------------------------------------------- -------------------- void procDrawTrends () {int ZigZagHighCount = 0, ZigZagLowCount = 0, ZigZagCount = 0; int ZigZagShift = 0; двойной ZZHigh # 91; 2 # 93; ZZLow # 91; 2 # 93 ;; datetime ZZHTime # 91; 2 # 93; ZZLTime # 91; 2 # 93 ;; (ZigZagHighCount lt; 3 ZigZagLowCount lt; 3) {double ZigZag = iCustom (NULL, 0, ZigZag, varExtDepth, varExtDeviation, varExtBackstep, 0, ZigZagShift); if ((ZigZag == High # 91; ZigZagShift # 93; || ZigZag == Низкий # 91; ZigZagShift # 93;) ZigZagCount == 0) {ZigZagCount ; ZigZagShift ;} else {if (ZigZag == High # 91; ZigZagShift # 93;) {ZZHigh # 91; ZigZagHighCount # 93; = ZigZag; ZZHTime # 91; ZigZagHighCount # 93; = iTime (NULL, 0, ZigZagShift); ZigZagHighCount ; ZigZagCount ; }/делать обратное короткое, если (ZigZag == Low # 91; ZigZagShift # 93;) {ZZLow # 91; ZigZagLowCount # 93; = ZigZag; ZZLTime # 91; ZigZagHighCount # 93; = iTime (NULL, 0, ZigZagShift); ZigZagLowCount ; ZigZagCount ; }} ZigZagShift ; } ObjectCreate (потолок, OBJ_TREND, 0, ZZHTime # 91; 1 # 93; ZZHigh # 91; 1 # 93; ZZHTime # 91; 0 # 93; ZZHigh # 91; 0 # 93;); ObjectCreate (покрытие, OBJ_TREND, 0, ZZLTime # 91; 1 # 93;, ZZLow # 91; 1 # 93;, ZZLTime # 91; 0 # 93;, ZZLow # 91; 0 # 93;); ObjectSet (потолочная, OBJPROP_STYLE, STYLE_SOLID); ObjectSet (покрытие, OBJPROP_STYLE, STYLE_SOLID); ObjectSet (потолок, OBJPROP_WIDTH, 2); ObjectSet (покрытие, OBJPROP_WIDTH, 2); ObjectSet (Потолок, OBJPROP_COLOR, синий); ObjectSet (покрытие, OBJPROP_COLOR, красный); ObjectSet (потолочная, OBJPROP_RAY, правда); ObjectSet (покрытие, OBJPROP_RAY, правда);/---- string varMessage, n = \ n; varMessage = StringConenate (ZigZagCount:, ZigZagCount, n, ZigZagHighCount:, ZigZagHighCount, n, ZigZagLowCount:, ZigZagLowCount, n, ZZHTime # 91; 0 # 93 ;: funcSetDateTime (ZZHTime # 91; 0 # 93;), n, ZZHigh # 91; 0 # 93 ;: ZZHigh # 91; 0 # 93;, n, ZZHTime # 91; 1 # 93 ;: funcSetDateTime (ZZHTime # 91; 1 # 93;), n, ZZHigh # 91; 1 # 93 ;: ZZHigh # 91; 1 # 93;, n, ZZLTime # 91; 0 # 93 ;: funcSetDateTime (ZZLTime # 91; 0 # 93;), n, ZZLow # 91; 0 # 93 ;: ZZLow # 91; 0 # 93;, n, ZZLTime # 91; 1 # 93 ;:, funcSetDateTime (ZZLTime # 91; 1 # 93;), n, ZZLow # 91; 1 # 93 ;: ZZLow # 91; 1 # 93;); Комментарий (varMessage); Возвращение (0); } string funcSetDateTime (datetime varTime) {datetime curtime = varTime; int theday = TimeDay (curtime); int themonth = TimeMonth (curtime); int theyear = TimeYear (curtime); int thehour = TimeHour (curtime); int theminute = TimeMinute (curtime); string thedate = StringConenate (themonth,, theday,, itear,, thehour,:, theminute); возвращать (thedate); }/ ---------------------- поддержка funcion (s) ------------------- ----- bool funcIsNewBar (int timeFrame) {bool res = false;/массив содержит время открытия текущего (нулевого) бара/для 7 (семи) таймфреймов статическое datetime _sTime # 91; 7 # 93 ;; int i = 6;/Примечание: i ниже будет 6 или таймфрейм будет днем. switch (timeFrame) {случай 1: i = 0; перерыв; случай 5: i = 2; перерыв; случай 15: i = 3; перерыв; случай 30: i = 4; перерыв; случай 60: i = 5; перерыв; case 240: break; дело 1440: разрыв; default: timeFrame = 1440; }/---- if (_sTime # 91; i # 93; == 0 || _sTime # 91; i # 93;! = iTime (Symbol (), timeFrame, 0)) {_sTime # 91; i # 93; = iTime (Symbol (), timeFrame, 0); разреш = TRUE; }/---- return (res); }