控制Chart的宽度

Discussion in 'AmiBroker' started by strikeme, Mar 17, 2009.

  1. 请问前辈以下需求如何以AFL实现?

    1-minute即时分时走势,
    设Chart Width为 300 Bar。
    开盘後第1根Bar在最左边,右边空白为299;
    开盘後50分钟,50根Bar在左边,右边空白为250;
    开盘後108分钟,108根Bar在左边,右边空白为192;
    以此类推 ……

    就像是yahoo所提供的Chart一样︰
    http://hk.finance.yahoo.com/q/bc?s=^DJI&t=1d


    以下是小弟写的︰
    用来控制Chart的宽度,请前辈指教︰
    AFL参考自 http://www.amibroker.org/userkb/2007/10/11/keeping-your-chart-right-justified/

    _SECTION_BEGIN("RightChartWidth");
    procedure RightChartWidth( ChartWidth )
    {
    DT = DateTime();
    BI = BarIndex();
    FirstDateTime = LastValue( Nz(Ref( DT,-ChartWidth) ) );
    FirstDateTimestr = DateTimeToStr( FirstDateTime );
    LastDateTimestr = DateTimeToStr( LastValue(DT) );
    AB = CreateObject("Broker.Application");
    AW = AB.ActiveWindow;
    AW.ZoomToRange( FirstDateTimestr, LastDateTimestr );
    }
    JC1= ParamTrigger("Justify Chart 1","Chart Width 60");
    JC2= ParamTrigger("Justify Chart 2","Chart Width 120");
    JC3= ParamTrigger("Justify Chart 3","Chart Width 180");
    JC4= ParamTrigger("Justify Chart 4","Chart Width 240");
    JC5= ParamTrigger("Justify Chart 5","Chart Width 300");
    CW1 = 68;
    CW2 = 128;
    CW3 = 188;
    CW4 = 248;
    CW5 = 308;
    if( JC1)RightChartWidth( CW1 );
    else if( JC2)RightChartWidth( CW2 );
    else if( JC3)RightChartWidth( CW3 );
    else if( JC4)RightChartWidth( CW4 );
    else if( JC5)RightChartWidth( CW5 );
    _SECTION_END();