////// 部分开始 /* 当买入不同于掩护并且卖出不同于空头时使用此 afl/ RequestTimedRefresh(1, onlyvisible = False); _SECTION_BEGIN("Algoji.com 盘中.afl"); intra = ParamToggle("激活盘中模式", "NO|YES" ); per10 = Param("交易条目来自 (HHMM)", 920, 900, 2300, 1 ); per11 = Param("Trade Entry Upto(HHMM)", 1445, 900, 2300, 1 ); per12 = Param( "交易退出 (HHMM)", 1515, 900, 2300, 100 ); pop= ParamToggle("百分比或点数", "点数|百分比"); slp = Param("止损", 0, 0, 1000, 0.1); tsl= Param("跟踪停止", 0, 0, 1000, 0.1); tgtp = Param("目标", 0, 0, 1000, 0.1); Col = ParamColor("修改信号的颜色", colorYellow ); delay= ParamToggle("Trade Intrabar?", "YES|Candle Completion"); dlong= ParamToggle("禁用 Long?", " -1); Cover= Ref(Cover,-1);} qt= Param("交易数量", 0, 0, 1000000) ; 曝光=参数(“曝光”,0,0,1000000);if(exposure>0) qt= round(exposure/ValueWhen(Day()!=Ref(Day(),-1), C)); maxl= Param("使用 SL 的数量 (MaxLoss)",0,0,100000 ); if(maxl>0 AND !pop) qt=round(maxl/slp); if(maxl>0 AND pop) { basicprice= LastValue(ValueWhen(Day()!=Ref(Day(),-1), C)); sl=slp -1); Cover= Ref(Cover,-1);} qt= Param("交易数量", 0, 0, 1000000) ; 曝光=参数(“曝光”,0,0,1000000);if(exposure>0) qt= round(exposure/ValueWhen(Day()!=Ref(Day(),-1), C)); maxl= Param("使用 SL 的数量 (MaxLoss)",0,0,100000 ); if(maxl>0 AND !pop) qt=round(maxl/slp); if(maxl>0 AND pop) { basicprice= LastValue(ValueWhen(Day()!=Ref(Day(),-1), C)); sl=slp基本价格/100;qt = 圆形(最大 / SL);} intraex = 内部 AND (TimeNum() > per12 * 100); intraen = !intra OR ( TimeNum() <= per11 * 100 AND TimeNum() >= per10 * 100 ); 购买1 = 购买;卖出 1 = 卖出;短 1 = 短;封面1 =封面;买入=卖出=空头=复盖=0;bflag = sflag = sp=bp = 0; slarr = tgtarr = qtarr = 空;for ( i = 10; i < BarCount; i++ ) { if ( ( Cover1[i] OR intraex[i]OR( H[i] > slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( L[i] < tgtarr[i-1] AND tgt > 0 ) ) AND sflag ) { Cover[i] = 1; 封面价格[i]= C[i]; 标志 = 0; d= dd[i]; 教授= sp-C[i];} if ( ( Sell1[i] OR intraex[i] OR( L[i] < slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( H[i] > tgtarr[i-1] AND tgt > 0 ) ) AND bflag ) { Sell[i] = 1; 销售价格[i]= C[i]; bflag = 0; d= dd[i]; 教授= C[i]-bp;} if ( Buy1[i] AND intraen[i] AND bflag == 0 ) { Buy[i] = 1; bflag = 1; bp=C[i];sl=slp;tgt=tgtp; 如果(流行){sl = slpbp/100;tgt= tgtp bp/100;} if (slp) slarr[i] = bp-sl; 如果 ( tgtp ) tgtarr[i] = bp+tgt; } if ( bflag AND Buy[i]==0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Max(slarr[i-1], H[i] (1-tsl/100)); if(tsl>0 AND !pop) slarr[i] = Max(slarr[i-1], H[i]-tsl); } if ( Short1[i] AND intraen[i] AND sflag == 0 ) { Short[i] = 1; 标志 = 1; Sp = C[i];sl=slp;tgt=tgtp; 如果(流行){sl = slp sp/100;tgt= tgtp Sp/100;} if ( slp ) slarr[i] = sp + sl; 如果 ( tgtp ) tgtarr[i] = sp - tgt; } if ( sflag AND Short[i] == 0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Min(slarr[i-1], L[i](1+tsl/100)); if(tsl>0 AND !pop) slarr[i] = Min(slarr[i-1], L[i]+tsl); } } 绘图(slarr,“SL”,Col,styleThick);绘图(tgtarr,“TGT”,Col,styleThick);PlotShapes(IIf(购买,shapeUpArrow,shapeNone),Col,0,H,Offset = 15);PlotShapes(IIf(Short, shapeDownArrow, shapeNone), Col, 0, L, Offset = 15); PlotShapes(IIf(Cover, shapeStar, shapeNone), Col, 0, H, Offset = -25); PlotShapes(IIf(Sell, shapeStar, shapeNone), Col, 0, L, Offset = -25); sig = IIf( BarsSince( Buy ) < BarsSince( Short ), 1, 0 ); messageboard = ParamToggle("留言板", "显示|隐藏", 1 ); if ( 留言板 == 1 ) { GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode(1); GfxSetTextColor(colorWhite); GfxSelectSolidBrush(colorDarkTeal); // 这是盒子的背景颜色 pxHeight = Status(" GfxTextOut("目标:" + WriteIf(tgtp==0, "未激活", ""+tgtarr), 13, y - 60 ); GfxTextOut( ( "当前盈亏: " + WriteVal( IIf( sig == 1, (C-ValueWhen(Buy,C))*qt, (ValueWhen(Short,C)-C)*qt ), 2.2 ) ) , 13, y-40 ); // GfxTextOut( ( "jhjh " ), 13, y-20 ); } //自动交易部分开始 instr= ParamList("Instrument Name","EQ|FUTIDX|FUTSTK|OPTIDX|OPTSTK|FUTCOM"); stag= ParamStr("策略标签", "STG1"); qty= NumToStr(qt[BarCount-1], 1.0, False) ; bp= sp= NumToStr(关闭[BarCount-1],1.2, False); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} if(delay) {Buy=Ref(Buy,-1); 卖出=参考(卖出,-1);短=参考(短,-1);Cover= Ref(Cover,-1);} 全局算法;algoji = Name() + NumToStr( Interval() / 60, 1.0, False ) ; 过程 aStaticVarSet( SName, Svalue ) { 全局算法;StaticVarSet( Sname + algoji, Svalue ); } 函数 aStaticVarGet( SName ) { 全局算法;Var = StaticVarGet( Sname + algoji ); if ( IsNull( Var = StaticVarGet( Sname + algoji ) ) ) Var = 0; 返回变量;} 符号 = 名称();//_TRACE("t"+t); Checkdt=Nz(aStaticVarGet("lastdt")); dt = 最后值(日期时间());Checkdtss=Nz(aStaticVarGet("lastdtss")); dtss = 最后值(日期时间());Checkdtc=Nz(aStaticVarGet("lastdtc")); dtc = 最后值(日期时间());Checkdts=Nz(aStaticVarGet("lastdts")); dts = LastValue( 日期时间() ); RTBuy = LastValue( Buy) AND Checkdt != dt; RTShort = LastValue(Short) AND Checkdtss != dtss; RTCover = LastValue(Cover) AND Checkdtc != dtc; RTSell = LastValue(Sell) AND Checkdts != dts; if ( RTCover ) { aStaticVarSet("lastdtc",dtc ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE("#"+Nz(StaticVarGet("counter"))+",SX,"+sym+",,,"+bp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",bp,qty,instr,stag); } if ( RTSell ) { aStaticVarSet("lastdts",dts ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE("#"+Nz(StaticVarGet("counter"))+",LX,"+sym+",,,"+sp +","+qty+",,,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } if ( RTBuy ) { aStaticVarSet("lastdt",dt ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE("#"+Nz(StaticVarGet("counter"))+",LE,"+sym+",,,"+bp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",bp,qty,instr,stag); } if ( RTShort ) { aStaticVarSet("lastdtss",dtss ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); sp= NumToStr(关闭[BarCount-1],1.2, False); _TRACE("#"+Nz(StaticVarGet("counter"))+",SE,"+sym+",,,"+sp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",bp,qty,instr, 麈); } Button = ParamToggle("启用按钮交易", "YES|NO" ); 到期= ParamStr("到期",""); 罢工= ParamStr("罢工",""); type= ParamStr("选项类型", ""); 符号=名称()+“|”+到期+“|” +罢工+“|” +类型;函数 GetSecondNum() { 时间 = 现在( 4 ); 秒 = int( 时间 % 100 ); 分钟 = int( 时间 / 100 % 100 ); 小时 = int( 时间 / 10000 % 100 ); SecondNum = int( 小时 * 60 * 60 + 分钟 * 60 + 秒 ); 返回秒数;} function PopupWindowEx(popupID, bodytext, captiontext, timeout, left, top) { displayText = bodytext + captiontext; if ( ( StaticVarGetText( "prevPopup" + popupID ) != displayText) OR (StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) ) { StaticVarSetText( " GfxTextOut("SE", sx1 + 20, sy1 + 20); ex1 = x1; ey1 = y1+60;ex2 = ex1 + 60;ey2 = ey1 + 60;GfxSelectSolidBrush(ColorRGB(255,204,204));//卖GfxRoundRect(ex1,ey1,ex2,ey2,7,7); GfxSetTextColor(ColorRGB(153, 0, 0)); GfxTextOut("LX", ex1 + 20, ey1 + 20); GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) );//卖 GfxRoundRect( ex2, ey1, ex2+60, ey2 , 7, 7 ) ; GfxSetTextColor(colorWhite); GfxTextOut("SX", ex2 + 20, ey1 + 20 ); if ( px > x1 AND pxy1 AND py < y2 AND Click ) { _TRACE( "# ," + NumToStr(Nz(StaticVarGet("counter")),0,False) + ", BUY 从按钮触发, " ); AlertIf(1, "SOUND C:\Windows\Media\tada.wav", "音频警报", 1, 2, 1); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx("ID:1", "BUY", "按钮触发购买"+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > sx1 AND pxsy1 AND py < sy2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SHORT 从按钮触发, " ); AlertIf(2, "SOUND C:\Windows\Media\tada.wav", "音频警报", 2, 2, 1); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "SHORT", "从按钮触发的短路 "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M", "",sp,数量,instr,stag); } //https://algoji.com/ if ( px > ex1 AND pxey1 AND py<ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SELL 从按钮触发, " ); AlertIf( 3, "SOUND C:\Windows\Media\tada.wav", "音频警报", 2, 2, 1); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "SELL", "Sell Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex2 AND px<(ex2+60) AND py>ey1 AND py < ey2 AND Click ) { _TRACE( "#," + NumToStr( DateTime(), formatDateTime ) + ", "SX",sym,"M","",sp,qty,instr,stag); } } "SX",sym,"M","",sp,qty,instr,stag); } }
问问题
86 次