【美股最權威投資國外期貨/程式交易/最佳外匯交易平台指南】【GoForTrading/GO交易】's Archiver

gogogo 發表於 2014-10-3 23:31

AmiBroker显示K线剩余时间的代码

_SECTION_BEGIN("Time Left");function GetSecondNum(){Time = Now( 4 );Seconds = int( Time % 100 );Minutes = int( Time / 100 % 100 );Hours = int( Time / 10000 % 100 );SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );return SecondNum;}RequestTimedRefresh( 1 );TimeFrame = Interval();SecNumber = GetSecondNum();Newperiod = SecNumber % TimeFrame == 0;SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;SecsToGo = TimeFrame - SecsLeft;x=Param("xposn",300,0,1000,1);y=Param("yposn",50,0,1000,1);GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );if ( NewPeriod ){GfxSelectSolidBrush( colorYellow );GfxSelectPen( colorYellow, 2 );Say( "New period" );}GfxRoundRect( x+45, y+17, x-3, y-2, 0, 0 );GfxSetBkMode(1);GfxSelectFont( "Arial", 12, 700, False );GfxSetTextColor( colorBlack );GfxTextOut( ""+SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );_SECTION_END();

[size=4]修改成   『小时:分:秒』   的格式[/size]

_SECTION_BEGIN("Time Left");
tempnum = Now( 4 ) - TimeNum();
TimeRem = Interval() - ((int(tempnum[BarCount - 1] / 100) * 60) + (tempnum[BarCount - 1] - int(tempnum[BarCount - 1] / 100) * 100));
if (TimeRem[BarCount - 1] < 0) TimeRem = 0;
MinuteVar = int(TimeRem / 60);
SecondsVar = int(frac(TimeRem / 60) * 60);
TitleTimeRem = EncodeColor(colorWhite) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") +  SecondsVar;
Hora=Param("Horizontal Positiona",525,1,1200,1);
Vera=Param("Vertical Positiona",17,1,830,1);
GfxSetBkMode( colorWhite );
FST=Param("Font Size Time",12,11,100,1);
GfxSelectFont( "Arial", FST, 700, italic = False, underline = False, True );
GfxSetTextColor(ParamColor("Color",colorWhite) );
GfxTextOut( ""+MinuteVar+":"+WriteIf(SecondsVar > 9, "","0")+SecondsVar+"", Hora+30 , Vera+65 );
_SECTION_END();

[color=Red]不過"小時"沒辦法倒數

只能用分(鐘)線才會動[/color]

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.