龙听期货论坛's Archiver

龙听 发表于 2017-12-28 11:14

让指标符合条件时,发出警告[MC]

Multicharts/Tradestation 的Alerts/警示功能,蛮常用的..
看盘时当条件符合时,可发出声音来提示.
使用RSI 来举例,当大于70,及小于30要发出声音做警示

程序写法如下:

[code]
inputs:Price( Close ),Length( 14 ),OverSold( 30 ),OverBought( 70 ),OverSColor( Cyan ),OverBColor( Red ) ;

variables: var0( 0 ) ;

var0 = RSI( Price, Length ) ;
Plot1( var0, "RSI" ) ;Plot2( OverBought, "OverBot" ) ;Plot3( OverSold, "OverSld" ) ;

if var0 > OverBought
then
SetPlotColor( 1, OverBColor ) else
if  var0 < OverSold
then
SetPlotColor( 1, OverSColor ) ;//这里提一下,这是让线变色的写法.
//==到这里都是RSI 指标
condition1 = var0 crosses over OverSold ;
if condition1
then
PlaySound("C:\Windows\Media\WindowsBalloon.wav")  //填上音效的档案路径 else
begincondition1 = var0 crosses under OverBought;
if condition1
then
PlaySound("C:\Windows\Media\ring.wav");//填上音效的档案路径
end;
[/code]

页: [1]