如何将指标的数值或 划线数值放入信号里? [MC]
-
MC用户求助:
其实您可以直接将指标中的计算公式复制到信号中去,这个其实是通用的,它们都是通过调用函数或者进行一些逻辑计算得到的数值结果。拿MACD指标和MACD的信号为例,MC的公式编译器中有MACD的指标也有MACD的信号策略,您可以对比一下diff和dea的数值计算过程,其实是一样的;除了MACD之外,您还可以看到其它一些指标和信号也有这种情况。下面附上MACD的指标和信号借参考:
//MACD指标
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
Plot1( var0, "MACD" ) ;
Plot2( var1, "MACDAvg" ) ;
Plot3( var2, "MACDDiff" ) ;
Plot4( 0, "ZeroLine" ) ;
condition1 = var2 crosses over 0 ;
if condition1 then
Alert( "Bullish alert" )
else
begin
condition1 = var2 crosses under 0 ;
if condition1 then
Alert( "Bearish alert" ) ;
end;
//MACD LE 多头信号
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
condition1 = CurrentBar > 2 and var2 crosses over 0 ;
if condition1 then
Buy ( "MacdLE" ) next bar at market ;
//MACD SE空头信号
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
condition1 = CurrentBar > 2 and var2 crosses under 0 ;
if condition1 then
Sell Short ( "MacdSE" ) next bar at market ; -
MC回复讨论一:
其实您可以直接将指标中的计算公式复制到信号中去,这个其实是通用的,它们都是通过调用函数或者进行一些逻辑计算得到的数值结果。拿MACD指标和MACD的信号为例,MC的公式编译器中有MACD的指标也有MACD的信号策略,您可以对比一下diff和dea的数值计算过程,其实是一样的;除了MACD之外,您还可以看到其它一些指标和信号也有这种情况。下面附上MACD的指标和信号借参考:
//MACD指标
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
Plot1( var0, "MACD" ) ;
Plot2( var1, "MACDAvg" ) ;
Plot3( var2, "MACDDiff" ) ;
Plot4( 0, "ZeroLine" ) ;
condition1 = var2 crosses over 0 ;
if condition1 then
Alert( "Bullish alert" )
else
begin
condition1 = var2 crosses under 0 ;
if condition1 then
Alert( "Bearish alert" ) ;
end;
//MACD LE 多头信号
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
condition1 = CurrentBar > 2 and var2 crosses over 0 ;
if condition1 then
Buy ( "MacdLE" ) next bar at market ;
//MACD SE空头信号
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
condition1 = CurrentBar > 2 and var2 crosses under 0 ;
if condition1 then
Sell Short ( "MacdSE" ) next bar at market ;
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容