Board logo

标题: 【布林通道(Bollinger Bands)】 [打印本页]

作者: 龙听    时间: 2022-11-3 13:45     标题: 【布林通道(Bollinger Bands)】

  1. inputs:
  2.         BollingerPrice( Close ),
  3.         TestPriceUBand( Close ),
  4.         TestPriceLBand( Close ),
  5.         Length( 20 ),
  6.         NumDevsUp( 2 ),
  7.         NumDevsDn( -2 ),
  8.         Displace( 0 ) ;

  9. variables:
  10.         var0( 0 ),
  11.         var1( 0 ),
  12.         var2( 0 ),
  13.         var3( 0 ) ;

  14. var0 = AverageFC( BollingerPrice, Length ) ;
  15. var1 = StandardDev( BollingerPrice, Length, 1 ) ;
  16. var3 = var0 + NumDevsUp * var1 ;
  17. var2 = var0 + NumDevsDn * var1 ;

  18. condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
  19. if condition1 then
  20.         begin
  21.         Plot1[Displace]( var3, "UpperBand" ) ;
  22.         Plot2[Displace]( var2, "LowerBand" ) ;
  23.         Plot3[Displace]( var0, "MidLine" ) ;

  24.                          
  25.         if Displace <= 0 then
  26.                 begin
  27.                 condition1 = TestPriceLBand crosses over var2 ;
  28.                 if condition1 then
  29.                         Alert( "Price crossing over lower price band" )
  30.                 else
  31.                 begin
  32.                 condition1 = TestPriceUBand crosses under var3 ;
  33.                 if condition1 then
  34.                         Alert( "Price crossing under upper price band" ) ;
  35.                 end;
  36.                 end ;
  37.         end ;
复制代码





欢迎光临 龙听期货论坛 (http://www.qhlt.cn/) Powered by Discuz! 7.2