|
本帖最後由 enochyu 於 12-9-8 00:43 編輯
keithlsp 發表於 12-9-7 12:59
多謝enochyu指教, 但我還是不太明白Array的運作
BB =BarsSince(Buy);
小範例,參考看看
- //
- // set chart, title style
- //
- SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle );
- _N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
- //
- // define parameter
- //
- _DateLine = Day() != Ref( Day(), -1 );
- _FMA = MA( Close, 15 );
- _SMA = MA( Close, 45 );
- Buy = _FMA > _SMA;
- Sell = _FMA <= _SMA;
- //
- // draw day end line
- //
- Plot( _DateLine
- , ""
- , ColorRGB( 50, 50, 50 )
- , styleHistogram | styleOwnScale
- , 0
- , 1 );
- //
- // draw ma line
- //
- Plot( _FMA
- , "FMA"
- , colorYellow
- , styleLine );
- Plot( _SMA
- , "SMA"
- , colorBlue
- , styleLine );
- //
- // draw buy, sell shapes
- //
- PlotShapes( ExRem( Buy, Sell ) * shapeUpArrow
- + ExRem( Sell, Buy ) * shapeDownArrow
- , IIf( Buy, colorYellow, colorBlue )
- , 0
- , IIf( Buy, Low, High )
- , -40 );
- //
- // draw candle line
- //
- Plot( C
- , "Close"
- , ParamColor( "Color", colorBlack )
- , styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
複製代碼 圖例
------
加入 Line 9, 39, 40 行程式碼,我想應該就是你要的效果
- //
- // set chart, title style
- //
- SetChartOptions( 0, chartShowArrows | chartShowDates | chartWrapTitle );
- _N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
- //
- // define parameter
- //
- _DateLine = Day() != Ref( Day(), -1 );
- _FMA = MA( Close, 15 );
- _SMA = MA( Close, 45 );
- Buy = _FMA > _SMA;
- Sell = _FMA <= _SMA;
- //
- // draw day end line
- //
- Plot( _DateLine
- , ""
- , ColorRGB( 50, 50, 50 )
- , styleHistogram | styleOwnScale
- , 0
- , 1 );
- //
- // draw ma line
- //
- Plot( _FMA
- , "FMA"
- , colorYellow
- , styleLine );
- Plot( _SMA
- , "SMA"
- , colorBlue
- , styleLine );
- //
- // draw buy, sell shapes
- //
- PlotShapes( ExRem( Buy, Sell ) * shapeUpArrow
- + ExRem( Sell, Buy ) * shapeDownArrow
- + Buy * _DateLine * shapeUpArrow
- + Sell * _DateLine * shapeDownArrow
- , IIf( Buy, colorYellow, colorBlue )
- , 0
- , IIf( Buy, Low, High )
- , -40 );
- //
- // draw candle line
- //
- Plot( C
- , "Close"
- , ParamColor( "Color", colorBlack )
- , styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
複製代碼 圖例
|
|