有人可以幫助我這個代碼。它並沒有完全正確地繪製趨勢線。或者如果有人有更好的方法,請告訴我。
插入代碼#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(){//---- indiors IndiorBuffers(2); IndiorDigits(位);/----繪圖設置//---- indior buffers映射SetIndexBuffer(0,ceiling); SetIndexBuffer(1,地板); SetIndexLabel(0,Upper band); SetIndexLabel(1,Lower band); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); ArraySetAsSeries(天花板,TRUE); ArraySetAsSeries(地板,真正的);/---- return(0); } int deinit(){//---- ObjectDelete(Ceiling); ObjectDelete(地板);/---- return(0); } int start(){//int counted_bars = IndiorCounted();/---- int shift; bool varNewBar = funcIsNewBar(Period()); if(varNewBar){ObjectDelete(Ceiling); ObjectDelete(地板); procDrawTrends(); for(shift = Bars-1; shiftgt; = 0; shift--){ceiling#91; shift#93; = ObjectGetValueByShift(Ceiling,shift);樓層#91;移#93; = ObjectGetValueByShift(地板,移);返回(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 ;; while(ZigZagHighCount lt; 3 ZigZagLowCount lt; 3){double ZigZag = iCustom(NULL,0,ZigZag,varExtDepth,varExtDeviation,varExtBackstep,0,ZigZagShift); if((ZigZag == High#91; ZigZagShift#93; || ZigZag == Low#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(Ceiling,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);對象集(天花板,OBJPROP_STYLE,STYLE_SOLID);對象集(樓OBJPROP_STYLE,STYLE_SOLID);對象集(天花板,OBJPROP_WIDTH,2);對象集(樓OBJPROP_WIDTH,2);對象集(天花板,OBJPROP_COLOR,藍色);對象集(樓OBJPROP_COLOR,紅色);對象集(天花板,OBJPROP_RAY,真正的);對象集(樓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,/,theyear,thehour,:,theminute);返回(thedate); }/ ----------------------支持funcion(s)------------------- ----- bool funcIsNewBar(int timeFrame){bool res = false;/數組包含當前(零)條的開放時間//對於7(七)個時間幀靜態日期時間_sTime#91; 7#93 ;; int i = 6;/注意:下面我將是6或時間框架將是一天。 switch(timeFrame){case 1:i = 0;打破;案例5:i = 2;打破;案例15:i = 3;打破;案例30:i = 4;打破;案例60:i = 5;打破;案例240:休息;案例1440:休息;默認值:timeFrame = 1440; }/----如果(_sTime#91;我#93; == 0 || _sTime#91;我#93;!= iTime(符號(),timeFrame,0)){_ sTime#91;我# 93; = iTime(符號(),timeFrame,0); RES = TRUE; }/---- return(res); }