您現(xiàn)在的位置:程序化交易>> 期貨公式>> 交易開拓者(TB)>> 開拓者知識>>正文內(nèi)容

平倉錯誤 [開拓者 TB]

  • 咨詢內(nèi)容: 想請教一下,下面是我的代碼,我設(shè)置的平多條件是紫色的LLH小于黃色的ma時才能平多,為什么這里給我平了呢?

    ?

    ?來源:CXH99.COM

  • TB技術(shù)人員:
    Params
    ? ? ? ???
    ? ? ? ? Numeric N(600);
    ? ? ? ? Numeric FastLength(12);
    ? ? ? ? Numeric SlowLength(26);
    ? ? ? ? Numeric MACDLength(18);
    Numeric FastLength0(500);
    ? ? ? ? Numeric SlowLength0(1000);
    ? ? ? ? Numeric MACDLength0(700);
    Vars
    ? ? ? ? Series<Numeric> LOTS;
    ? ? ? ? Series<Numeric> MA;
    Series<Numeric> MACDValue0;
    ? ? ? ? Series<Numeric> AvgMACD0;
    ? ? ? ? Series<Numeric> Diff0;
    Series<Numeric> MACDValue;
    ? ? ? ? Series<Numeric> AvgMACD;
    ? ? ? ? Series<Numeric> Diff;
    ? ? ? ? Series<Numeric> Diff1;
    Series<Numeric> HH;
    Series<Numeric> HH1;
    Series<Numeric> HHH;
    Series<Numeric> HHL;
    Series<Numeric> HHLB;
    Series<Numeric> LLHB;
    ? ? ? ? Series<Numeric> LL;
    ? ? ? ? Series<Numeric> LL1;
    ? ? ? ? Series<Numeric> LLL;
    ? ? ? ? Series<Numeric> LLH;
    Series<Numeric> FLAG1;
    ? ? ? ? Series<Numeric> FLAG2;
    ? ? ? ? Series<Numeric> FLAG11;
    ? ? ? ? Series<Numeric> FLAG22;
    Series<Numeric> X;
    ? ? ? ? Series<Numeric> Y;
    Series<Numeric> DKH;
    Series<Numeric> DKL;
    Series<Numeric> myPrice;
    Bool validTime;
    Bool ZD1;
    Bool ZD2;
    Bool ZD3;
    Bool ZD4;
    Bool ZK1;
    Bool ZK2;
    Bool ZK3;
    Bool ZK4;
    Bool PD1;
    Bool PK1;




    Events
    ? ? ? ???onBar(ArrayRef<Integer> indexs)
    {
    LOTS=1;

    validTime = (TIME>=0.0900 and time <=0.1500) and (time >=0.2100 and time <=0.0100);

    MA=AverageFC(C[1],N);
    ? ? ? ???

    ? ? ? ? PlotNumeric("MA",ma);


    MACDValue0 = XAverage(Close, FastLength0) - XAverage(Close, SlowLength0) ;
    AvgMACD0= XAverage(MACDValue0,MACDLength0);
    Diff0= MACDValue0[1] - AvgMACD0[1];

    MACDValue = XAverage( Close, FastLength ) - XAverage(Close, SlowLength ) ;
    AvgMACD = XAverage(MACDValue,MACDLength);
    Diff = MACDValue[1] - AvgMACD[1];
    Diff1 = MACDValue[1] - AvgMACD[1];

    IF(diff>0 and diff[1]>0 and diff[2]>0 and diff[3]>0 and diff[4]>0 and diff[5]>0 and diff[6]>0 and diff[7]<0){FLAG1=CurrentBar;}
    IF(diff<0 and diff[1]<0 and diff[2]<0 and diff[3]<0 and diff[4]<0 and diff[5]<0 and diff[6]<0 and diff[7]>0){FLAG2=CurrentBar;}
    x=flag2-FLAG1;
    HH=Highest (H[1],x+7);
    IF(diff<0 and diff[1]<0 and diff[2]<0 and diff[3]<0 and diff[4]<0 and diff[5]<0 and diff[6]<0 and diff[7]>0){HH1=HH;}Else{HH1=HH1[1]; }
    IF(HH1[1]>HH1[2]){HHH=HH1[1];}
    IF(HH1<>HH1[1]){HHLB=CurrentBar;}Else{HHLB=HHLB[1];}
    HHL=Lowest(L[1],CurrentBar[1]-HHLB+7);

    IF(diff1>0 and diff1[1]>0 and diff1[2]>0 and diff1[3]>0 and diff1[4]>0 and diff1[5]>0 and diff1[6]>0 and diff1[7]<0){FLAG11=CurrentBar;}
    IF(diff1<0 and diff1[1]<0 and diff1[2]<0 and diff1[3]<0 and diff1[4]<0 and diff1[5]<0 and diff1[6]<0 and diff1[7]>0){FLAG22=CurrentBar;}
    y=FLAG11-FLAG22;
    LL=Lowest (L[1],Y+7);
    IF(diff1>0 and diff1[1]>0 and diff1[2]>0 and diff1[3]>0 and diff1[4]>0 and diff1[5]>0 and diff1[6]>0 and diff1[7]<0){LL1=LL;}Else{LL1=LL1[1];}
    IF(LL1[1]<LL1[2]){LLL=LL1[1];}
    IF(LL1<>LL1[1]){LLHB=CurrentBar;}Else{LLHB=LLHB[1];}
    LLH=Highest(H[1],CurrentBar[1]-LLHB+7);
    PlotNumeric("LLH",LLH);
    PlotNumeric("HHL",HHL);

    ZD1=Diff0>=0 and MA[1]<=HH1 and L[2]<=HH1 and H>HH1;
    ZD2=Diff0>=0 and MA[1]>=HH1 and L[2]<=HH1 and H>MA[1];
    ZD3=Diff0>=0 and MA[1]>=HHH and L[2]<=HHH and H>MA[1];
    ZD4=Diff0>=0 and MA[1]<=HHH and L[2]<=HHH and H>HHH;


    ZK1=Diff0<=0 and MA[1]>=LL1 and H[2]>=LL1 and L<LL1;
    ZK2=Diff0<=0 and MA[1]<=LL1 and H[2]>=LL1 and L<MA[1];
    ZK3=Diff0<=0 and MA[1]<=LLL and H[2]>=LLL and L<MA[1];
    ZK4=Diff0<=0 and MA[1]>=LLL and H[2]>=LLL and L<LLL;


    PD1=L>=EntryPrice and LLH<MA[1] and H[1]>=LL1 and L<LL1;


    PK1=H<=EntryPrice and HHL>MA[1] and L[1]<=HH1 and H>HH1;


    ? ? ? ? If (validTime=True and MarketPosition<>1 and CurrentBar>=1)
    ? ? ? ? {
    ? ? ? ? If( ZD1){myPrice = Max (HH1,open);myPrice = IIF (BarStatus==2,0,myPrice);Buy(Lots,myPrice);}
    Else If ( ZD4){myPrice = Max (HHH,open);myPrice = IIF (BarStatus==2,0,myPrice);Buy(Lots,myPrice);}
    Else If (ZD2 OR ZD3){myPrice = Max (MA[1],open);myPrice = IIF (BarStatus==2,0,myPrice);Buy(Lots,myPrice);}
    }//開多

    IF (validTime=True AND MarketPosition<>-1 and CurrentBar>=1)
    {
    If (ZK1){myPrice = Min(LL1,open);myPrice = IIF (BarStatus==2,0,myPrice);SellShort(Lots,myPrice);}
    ? ? ? ???Else If (ZK4){myPrice = Min (LLL,open);myPrice = IIF (BarStatus==2,0,myPrice);SellShort(Lots,myPrice);}
    ? ? ? ???Else If (ZK2 OR ZK3){myPrice = Min (MA[1],open);myPrice = IIF (BarStatus==2,0,myPrice);SellShort(Lots,myPrice);}
    ? ? ? ? }//開空倉
    ? ? ? ???
    ? ? ? ???
    ? ? ? ? If (validTime=True AND MarketPosition==1 and BarsSinceLastEntry >= 1 )
    {
    ? ? ? ? If(PD1){Sell(0,Min(LL1,Open));}
    ? ? ? ? }//平多
    ? ? ? ???
    ? ? ? ? If (validTime=True AND MarketPosition==-1 and BarsSinceLastEntry >= 1 )
    ? ? ? ? {
    ? ? ? ? If(PK1){BuyToCover(0,Max(HH1,Open));}
    }//平
    ? ? ? ???
    ? ? ? ???
    ? ? ? ???
    }

    ?

  • TB客服: 發(fā)不出來圖,就描述一下。我的想法是:平多條件是LLH小于ma時才能平多,平空的條件是HHL大于ma時才能平空,但是在圖表上看這個條件沒起作用,不知道是怎么回事。特在此請教。

    ?

  • 網(wǎng)友回復(fù):
    armyhuan 發(fā)表于 2019-11-4 09:06
    發(fā)不出來圖,就描述一下。我的想法是:平多條件是LLH小于ma時才能平多,平空的條件是HHL大于ma時才能平空, ...

    代碼有誤吧?
    條件中應(yīng)該寫為validtime==true吧? 判斷式是雙等號。

 

有思路,想編寫各種指標(biāo)公式,交易模型,選股公式,還原公式的朋友

可聯(lián)系技術(shù)人員 QQ: 262069696  點(diǎn)擊在線交流或微信號:cxh99cxh99  進(jìn)行 有償收費(fèi) 編寫!

怎么收費(fèi),代編流程等詳情請點(diǎn)擊閱讀!

(注:由于人數(shù)限制,QQ或微信請選擇方便的一個聯(lián)系我們就行,加好友時請簡單備注下您的需求,否則無法通過。謝謝您!)


【字體: 】【打印文章】【查看評論

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 一卡二卡三卡在线| 亚洲欧洲自拍拍偷综合| 国产精品白丝在线观看有码| 好紧好爽太大了h视频| 久久精品国产欧美日韩| 污污视频在线观看黄| 国产va免费精品| 亚洲成a人片在线不卡| 嫩草视频在线免费观看| 久久人人爽人人爽人人片av不| 欧美日韩亚洲国产千人斩| 出租屋换租妻小雯21回| 韩国伦理s级在线| 国产精品宾馆在线| heyzo在线播放| 散步乳栓项圈尾巴乳环小说| 亚洲中久无码永久在线观看同| 男人桶女人的肌肌30分| 四虎永久免费地址在线观看| 国产91小视频| 国产精品视频久| √天堂中文官网8在线| 日日躁夜夜躁狠狠躁超碰97 | 成人网站在线进入爽爽爽| 九九视频在线观看视频23| 欧美熟妇另类久久久久久不卡| 免费观看午夜在线欧差毛片| 花蝴蝶免费版高清版| 国产欧美曰韩一区二区三区 | 青青国产成人久久91网站站| 国产精品夜间视频香蕉| heyzo亚洲精品日韩| 成人国产午夜在线视频| 久久人人妻人人做人人爽| 欧美bbbbbxxxxx| 亚洲精品无码你懂的| 精品久久久中文字幕一区| 国产99久久亚洲综合精品| 顶级欧美色妇xxxxx| 国产欧美日韩精品综合| 91中文字幕yellow字幕网|