返回列表 發帖

alert問題

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;

剛看到,我看看,
十五年期貨從業,十年量化研究,零傭金開戶,交易所保證金,享高比率返傭!期貨量化無門檻返傭,上萬歐美量化策略,100G量化文檔,最新歐美期貨雜志,無論研究或實盤,均可免費獲得!詳情聯系論壇管理員。

TOP

有解決方法嗎?

TOP

返回列表
意甲联赛ac米兰国米