您現在的位置:程序化交易>> 期貨公式>> 金字塔等>> 金字塔知識>>正文內容

[求助]請教老師一個問題 [金字塔]

  • 咨詢內容: 老師,您好~我想在代碼里實現以下規則:一,買入條件當EMA8上穿EMA21成立后,K線回落至EMA8,即close<=ema8時,發出買入指令;二,平倉條件當CLOSE>=ENTERPRICE*1.08時,發出平倉指令;三,止損條件當CLOSE<=ENTERPRICE*0.96時,發出止損指令;四,當條件分別成立時,在發出指令的K線,做上標記;
    寫的代碼如下,但一直沒有信號,請您改錯并指正一下,非常感謝~
    ema8:=ema(close,8);ema21:=ema(close,21);
    if cross(ema8,ema21) then    begin        buy(close<=ema8,1000,thisclose);      drawtext(holding>0,low,"買入");    end;
    if holding>0 and close<enterprice*0.96 then  begin    sell(holding>0,holding,thisclose);    drawtext(holding=0,low,"止損");  end;
    if holding>0 and close>=enterprice*1.08 then   begin     sell(holding>0,holding,thisclose);     drawtext(holding=0,low,"平倉");   end;



     

  • 金字塔客服: if cross(ema8,ema21) then     begin         buy(close<=ema8,1000,thisclose);       drawtext(holding>0,low,"買入");     end;

     

     

    改成

     

    if barslast(cross(ema8,ema21))>0 and close<=ema8 then     begin         buy(holding=0,1000,thisclose);       drawtext(holding>0,low,"買入");     end;

     

  • 用戶回復:

    老師,您好:

    我在上面的程序段中,加入了提高止損判斷語句。

    當頭寸持倉盈利超過+4%后,若再次跌破EMA21,則止損離場;若盈利超過+8%,則止盈。

    但代碼還是顯示不出來。

    麻煩您能看一下嗎?

     

    ema8:ema(close,8);
    ema21:ema(close,21);

    if barslast(cross(ema8,ema21))>0 and close<=ema8 then
       buy(holding=0,1000,thisclose);
      
    if close<enterprice*0.96 and holding>0 then
       sell(1,holding,thisclose);
      
    if close>=enterprice*1.04 and holding>0 then
    begin
       sell(close>=enterprice*1.08,holding,thisclose);
       sell(close<=ema21,holding,thisclose);
       end

     

  • 網友回復:

    ema8:ema(close,8);
    ema21:ema(close,21);

    if barslast(cross(ema8,ema21))>0 and close<=ema8 then
       buy(holding=0,1000,thisclose);
      
    if close<enterprice*0.96 and holding>0 and enterbars>0 then
       sell(1,holding,thisclose);
      
    if barslast(close>=enterprice*1.04)>0 and close>=enterprice*1.08 and holding>0 and enterbars>0 then
    begin
       sell(holding>0,holding,thisclose);
      
       end
      
    if barslast(close>=enterprice*1.04)>0 and close<=ema21 and  holding>0 and enterbars>0 then
    begin

     

  • 網友回復: 請教老師關于這行代碼: if barslast(cross(ema8,ema21))>0 and close<=ema8 then因為barslast(cross(ema8,ema21))>0 代表了該條件成立,但當cross(ema21,ema8)之后,也會有做多信號發出。 若只想在可以cross(ema8,ema21))和cross(ema21,ema8)之間發出做多信號,需要添加什么條件? PS:非常感謝老師上面的解答~ 以下是引用jinzhe在2013/12/3 8:42:10的發言:
    if cross(ema8,ema21) then     begin         buy(close<=ema8,1000,thisclose);       drawtext(holding>0,low,"買入");     end;

     

     

    改成

     

    if barslast(cross(ema8,ema21))>0 and close<=ema8 then     begin         buy(holding=0,1000,thisclose);       drawtext(holding>0,low,"買入");     end;

 

有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友

可聯系技術人員 QQ: 1145508240  點擊這里給我發消息進行 有償 編寫!不貴!點擊查看價格!


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

相關文章

    沒有相關內容
主站蜘蛛池模板: t66y最新地址一地址二地址三| 亚洲中字慕日产2021| 韩国三级中文字幕hd久久精品| 在线精品小视频| 久久99久久精品视频| 欧美另类老少配hd| 免费日韩在线视频| 被夫上司连续侵犯七天终于| 国产精品国产国产aⅴ| xxx国产精品xxx| 日本a中文字幕| 538在线观看视频| 美女扒开胸露出奶乳免费视频| 欧美日韩在线视频免费完整| 四虎精品影院在线观看视频| va天堂va亚洲va影视中文字幕| 女人被男人狂躁免费视频| 久久国产高清字幕中文| 欧美日韩国产综合视频在线看| 久久精品视频99| 激情内射日本一区二区三区| 国产caowo13在线观看一女4男 | 久久免费公开视频| 欧美成人性色生活片| 免费网站看av片| 被公侵犯电影bd在线播放| 男女混合的群应该取什么名字| 国产乱子伦真实china| 天天成人综合网| 国语做受对白xxxxx在线| 两领导在车上吃我的奶| 日本韩国三级在线| 亚洲午夜小视频| 激情国产AV做激情国产爱| 午夜时刻免费入口| 蕾丝av无码专区在线观看| 国产日产在线观看| 18禁亚洲深夜福利人口| 天下第一日本高清国语在线观看| 三上悠亚中文字幕在线播放| 日本三级在线观看中文字|