龙听期货论坛's Archiver

C
+
+


 微信: QQ:

天才白痴 发表于 2019-5-9 17:14

alert問題

本人在寫:
高於前5根BAR 買入
低於前5根BAR賣出
20點takeprofit
買入時:在高位回落0.3%便反向賣出

但寫了數星期ALERT 也不完成
請求各大大幫忙解決



[IntrabarOrderGeneration = True]
[SameExitFromOneEntryOnce = True]
Input: Trailing1( 20 ),Nbar( 5 ), X( 0.3 ), BuyorSellContracts(4),shareCounter1(1);
var: str(""), intrabarpersist mp1(0),intrabarpersist mp0(0), mp2(0), Starp( 0 ), TradeCounts( 0 ), Mycontracts( 0 ), TrailingPrice1( 0 ), intrabarpersist MyHigh( 0 );

var: open_alert(0), takprofit_alert(0); //false = not yet alert

mp2 = mp1;
mp1=mp0;
mp0=marketposition;
str="";

//entry
buy ("Buy") next bar at Highest(high,Nbar) +1 stop ;
sellshort ("Short") next bar at Lowest(low,Nbar)-1 stop ;
TradeCounts = PosTradeCount( 0 ) - 1 ;
Mycontracts = currentcontracts ;

if close >= Highest(high,Nbar) and open_alert = 0 then begin
        str=text(str)+text(Mycontracts)+text(" buy open")+text(BuyorSellContracts);
        open_alert = 1;
        takprofit_alert = 0;
//end else if close > Lowest(high,Nbar) and mp1 = -1 and mp2 = -1 and open_alert = 0 then begin
        //str=text(str)+text(Mycontracts)+text(" buy open")+text(BuyorSellContracts);
        //open_alert = true;
        //takprofit_alert = false;
end else if close <= Lowest(low,Nbar) and open_alert = 0  then begin
        str=text(str)+text(Mycontracts)+text(" sell open")+text(BuyorSellContracts);
        open_alert = 1;
        takprofit_alert = 0;
end;


//long
if mp0 = 1 then begin
        //update high
        if mp1 <> 1 then begin
                MyHigh = High ;
        end else if High > MyHigh then MyHigh = High ;
        //backhand
                sellshort ("call to put") next bar at ( 1 - X / 100 ) * MyHigh stop ;
        //Trailing
        TrailingPrice1 = entryprice + Trailing1 points ;
        //print (date , time_s, TrailingPrice1, entryprice );
        if (close >= TrailingPrice1 and takprofit_alert = 0) then begin
           str=text(str)+text(" Ctp1 ")+text(shareCounter1);
           open_alert = 0;
           takprofit_alert = 1;
        end;
        sell ("Ctp1") next bar at TrailingPrice1 limit;
end

else if mp0 = -1 then
begin
        if mp0 <> mp1 then begin
                if (mp1 = 1) then begin
                       str=text(str)+text(" cut ")+text(Mycontracts)+text(" and call to put ")+text(PosTradeSize(0,0));
                       open_alert = 0;
                end else begin
                        str=text(str)+text(" cut ")+text(Mycontracts)+text(" sell")+text(BuyorSellContracts);
                        open_alert = 0;
                end;
        end ;
        //Trailing
         TrailingPrice1 = entryprice - Trailing1 points;
         if (close <= TrailingPrice1 and takprofit_alert = 0) then begin
             str=text(str)+text(" Ptp1 ")+text(shareCounter1);
             open_alert = 0;
             takprofit_alert = 1;
         end;
         buytocover ("Ptp1") next bar at TrailingPrice1 limit;
end ;


if str<>"" then begin
        alert(str);
        //print (str);
end;

龙听 发表于 2019-7-4 09:36

刚看到,我看看,

天才白痴 发表于 2019-7-12 12:05

有解決方法嗎?

浮盈加仓的旺财 发表于 2020-3-4 16:15

学习学习

页: [1]
渠道·推广(20年运营值得信赖!)▼:温馨提示:期货论坛稳定、流畅的访问体验有赖于赞助商的广告支持,赞助商业务内容非本站官方业务,期货、证券及外汇投资均有亏损的风险,访问赞助商广告即代表您已了解其中的风险。欢迎意向赞助商联系客服或管理员咨询相关事宜。
                     
❤️2025年通过期货论坛开户享受如下优惠政策:政策一:手续费最低交易所+1分起,政策二:日内炒单及大资金享更高比率返还,政策三:保证金可申请交易所标准+0,政策四:开户即享有论坛Prime会员资格(价值199元/年),开户咨询管理员或右侧客服! 😋欧美期货杂志购买、下载与中文翻译:/thread-10603-1-1.html |TB/MC开户优惠政策:/thread-5986-1-1.html2025年最新交易所手续费表:/thread-7537-1-1.htmlSC2.png2025年最新中文翻译:/thread-160355-1-1.html;
欧美期货程序化期刊中文翻译目录: 【1982/83.01-12期】 【1984.01-12期】 【1985.01-12期】 【1986.01-12期】 【1987.01-12期】 【1988.01-12期】 【1989.01-12期】 【1990.01-12期】 【1991.01-12期】 【1992.01-12期】 【1993.01-12期】 【1994.01-12期】 【1995.01-12期】 【1996.01-12期】 【1997.01-12期】 【1998.01-12期】 【1999.01-12期】 【2000.01-12期】 【2001.01-12期】 【2002.01-12期】 【2003.01-12期】 【2004.01-12期】 【2005.01-12期】 【2006.01-12期】 【2007.01-12期】 【2008.01-12期】 【2009.01-12期】 【2010.01-12期】 【2011.01-12期】 【2012.01-12期】 【2013.01-12期】 【2014.01-12期】正在更新中...... 【2015.01-12期】待补 【2016.01-12期】待补 【2017.01-12期】正在更新中...... 【2018.01-12期】 【2019.01-12期】 【2020.01-12期】 【2021.01-12期】 【2022.01-12期】 【2023.01-12期】 【2024.01-12期】 【2025.01-12期】正在更新中......