function Saying( "Buy ", repeat ) { speak=Nz(StaticVarGet("lastspeak")); if( speak<=repeat ) { StaticVarSet("lastspeak", speak+1 ); Saying ( "Buy "); } } PrevBar=StaticVarGet("PB"); CurrentBar=LastValue( BarIndex() ); NewBar = PrevBar != CurrentBar; StaticVarSet("PB",CurrentBar); if(Buy) StaticVarSet("lastspeak", 0 ) Saying ("Buy ",3); 我写成这样子,系统报错,说buy没有初始化
function Saying( text, repeat ) { speak=Nz(StaticVarGet("lastspeak")); if( speak<=repeat ) { StaticVarSet("lastspeak", speak+1 ); Say( text ); } } PrevBar=StaticVarGet("PB"); CurrentBar=LastValue( BarIndex() ); NewBar = PrevBar != CurrentBar; StaticVarSet("PB",CurrentBar); if(NewBar) StaticVarSet("lastspeak", 0 ); if(lastvalue(buysignal)) Saying("buy", 2); 不可以把if(newbar)改掉,或其他,除了saying那一句, 其实就是用自己写的function saying(a,b)来代替say(), 这里buysignal是你的买入条件
非常感谢hgy兄长不厌其烦,耐心细致的及时示范和清楚的讲解,今天盘中我就可以测试看看声音报警了,期待着成功的好消息。 目前回看历史图表,我发现有时候应该出箭头信号的地方居然没有 ,有的地方却出来了,是不是电脑软件计算有时候也会有失误遗漏 ,很简单的kdj金叉死叉语句 ,都感觉有些地方显示的不对 ,是不是我的ami软件出现什么故障? 搞的我都没有信心继续写下去了,你有qq吗?我的是377970700,希望你如果方便就加我帮助我看看到底是什么原因?头疼死我了。一直想不通到底是为什么。
你好,hgy兄长,刚才测试了,一出现信号,还是一直叫个不停,就是按照你说的意思我写的啊,请你看看问题到底出现在哪里?我是莫名其妙,期待回复,非常感谢 Buy= Cross(J,D); Sell= Cross(D,J); function Saying( text, repeat ) { speak=Nz(StaticVarGet("lastspeak")); if( speak<=repeat ) { StaticVarSet("lastspeak", speak+1 ); Say( text ); } } PrevBar=StaticVarGet("PB"); CurrentBar=LastValue( BarIndex() ); NewBar = PrevBar != CurrentBar; StaticVarSet("PB",CurrentBar); if(NewBar) StaticVarSet("lastspeak", 0 ); if(LastValue(Buy))Saying("buy ", 3); if(LastValue(Sell))Saying("sell ", 3);
_SECTION_BEGIN("Stochastic %D"); periods = Param( "Periods", 9, 1, 200, 1 ); Ksmooth = Param( "%K avg", 3, 1, 200, 1 ); Dsmooth = Param( "%D avg", 3, 1, 200, 1 ); Plot( StochD( periods , Ksmooth, DSmooth ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); _SECTION_END(); _SECTION_BEGIN("Stochastic %K1"); periods = Param( "Periods", 9, 1, 200, 1 ); Ksmooth = Param( "%K avg", 3, 1, 200, 1 ); Plot( StochK( periods , Ksmooth), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); _SECTION_END(); Buy=Cross(StochK(9,3),StochD(9,3,3)); Sell=Cross(StochD(9,3,3),StochK(9,3)); shape2 = Buy * shapeUpArrow + Sell * shapeDownArrow; PlotShapes( shape2, colorYellow , 0, IIf( Buy,J, J ) ); function Saying( text, repeat ) { speak=Nz(StaticVarGet("lastspeak")); if( speak<=repeat ) { StaticVarSet("lastspeak", speak+1 ); Say( text ); } } PrevBar=StaticVarGet("PB"); CurrentBar=LastValue( BarIndex() ); NewBar = PrevBar != CurrentBar; StaticVarSet("PB",CurrentBar); if(NewBar) StaticVarSet("lastspeak", 0 ); //if(LastValue(Buy))Saying("buy ", 3); //if(LastValue(Sell))Saying("sell ", 3); 就是这个,你找个实时数据测试,在5分钟里面看看,我这里还是一旦交叉,一直报
_SECTION_BEGIN("Stochastic %K1"); periods = Param( "Periods", 9, 1, 200, 1 ); Ksmooth = Param( "%K avg", 3, 1, 200, 1 ); Plot( StochK( periods , Ksmooth), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); _SECTION_END(); Buy=Cross(StochK(9,3),StochD(9,3,3)); Sell=Cross(StochD(9,3,3),StochK(9,3)); shape2 = Buy * shapeUpArrow + Sell * shapeDownArrow; PlotShapes( shape2, colorYellow , 0, IIf( Buy,50, 50 ) ); function Saying( text, repeat ) { speak=Nz(StaticVarGet("lastspeak")); if( speak<=repeat ) { StaticVarSet("lastspeak", speak+1 ); PlotText(NumToStr(speak,1.0),BarCount+speak,80,2); Say( text ); } } PrevBar=StaticVarGet("PB"); CurrentBar=LastValue( BarIndex() ); NewBar = PrevBar != CurrentBar; StaticVarSet("PB",CurrentBar); if(NewBar) StaticVarSet("lastspeak", 0 ); if(LastValue(Buy))Saying("buy ", 3); if(LastValue(Sell))Saying("sell ", 3); 脚本没问题的,saying用了全局变量,所以如果你在主图上使用了,就不要重复用在附图上,那样会出错的
这个帖子充分说明了afl 需要一步一步学,而不是请别人帮我写个指标拿来就能用的。有些基础知识使用者是必须掌握的。我觉得xiyun最好从基本知识抓起,否则就是现在这样,别人给你一个完美的工具,可是还是知其然不知其所以然。而且越到后面越发现基础知识的重要,譬如你设计一个自动交易程序,即便别人写好了框架给你,如果自己如果不会debug,对afl的基础知识不精通,那基本上是搞不出能用的代码的。
你好,hgy 兄长,我是先在主图上面测试的结果是一旦有信号就一直响,所以后来才在附图上面写个简单的作测试看看,结果也是一样的,只要有信号就一直响,不知道你那里测试是什么结果,为什么我们的结果是不一样啊,头疼死我了。希望你再仔细帮助我找找其中的真正原因。我的确是搞不定了,哪一位已经搞定了这个问题的,希望你认真详细的给大家贴个示范和针对具体问题的实际分析和指点帮助看看,这才是论坛应有的讨论交流和学习气氛吧。非常感谢hgy兄长一直身先士卒,不厌其烦的认真指点和具体示范,帮助后辈同学们解决了很多困扰和头疼的实际问题,给海洋论坛留下了很多让大家可以从中借鉴和学习提高的精华好贴。我很期待大家能够帮助我尽快解决这个莫名其妙的问题。