人人爽天天爽夜夜爽qc-人人爽天天爽夜夜爽曰-人人天天爱天天做天天摸-人人天天夜夜-色网站在线-色网站在线看

您現(xiàn)在的位置:程序化交易>> 期貨公式>> 文華財經>> 文華財經知識>>正文內容

海龜模型 改成WH8 [文華財經]

  • 咨詢內容: ?請教老師,可否幫忙改成WH8格式?示范中的和這個不一樣。
    import?talib?as?taimport?numpy?as?npfrom?EsSeries?import?NumericSeriesimport?EsTalib
    g_params['axPositionNum'??=?99??g_params['topPoint'???????=?30???g_params['inPoint'????????=?50??g_params['loatStopStart'??=?40???g_params['loatStopPoint'??=?10???
    p1=?7????????p?=?3?????????p2?=?50???????RiskRatio?=?10???ATRLength?=?20?*p1?boLength?=?20?*p1?fsLength?=?55?*p1??teLength?=?10?*p1??LPTF?=?True????PreEP?=?0???????AvgTR?=?1???????

    SendOrderThisBar?=?False????PreBreakoutFailure?=?False??
    myEntryPrice?=?0myExitPrice?=?0DonchianHi?=?0DonchianLo?=?0fsDonchianHi?=?0fsDonchianLo?=?0ExitHighestPrice?=?0ExitLowestPrice?=?0
    ContractId?=?'HFE|F|RB|2010'br/>def?initialize(context):????global?ContractId????SetBarInterval(ContractId,?''?1,?5000)????SetActual()
    def?handle_data(context):????global?ContractId
    ????????bars?=?HisBarsInfo()????barLen?=?len(bars)????if?barLen?<?10:????????return
    def?condict():????a?=?(0.090000?<?Time(ContractId,?Enum_Period_Min(),?1)?<?0.240000)????return?a
    ???def?initialize(context):?????SetOrderWay(2)?


    def?TrueRange(barsinfo:list):????if?len(barsinfo)?<=?0:????????return?None,?None,?None
    ????ths?=?[]????tls?=?[]????trs?=?[]????hs?=?[]????ls?=?[]
    ????for?i,?p?in?enumerate(barsinfo):????????high?=?barsinfo[i]["HighPrice"]????????low?=?barsinfo[i]["LowPrice"]????????hs.append(high)????????ls.append(low)
    ????????if?i?==?0:????????????th?=?high????????????tl?=?low????????else:????????????pclose?=?barsinfo[i-1]["LastPrice"]????????????th?=?high?if?high?>=?pclose?else?pclose????????????tl?=?low??if?low??<=?pclose?else?pclose
    ????????tr?=?th?-?tl????????ths.append(th)????????tls.append(tl)????????trs.append(tr)
    ????return?np.array(hs),?np.array(ls),?np.array(trs)

    def?XAverage(prices:np.array,?length):????fac?=?2.0/(length+1)????xa?=?1
    ????if?len(prices)?<?length:????????return?xa????
    ????for?i,?p?in?enumerate(prices):????????if?i?==?0:????????????xa?=?p????????else:????????????xa?=?xa?+?fac?*?(p?-?xa)????????return?xa
    def?handle_data(context):????global?RiskRatio,?ATRLength,?boLength????global?teLength,?fsLength,?LPTF????global?PreEP,?AvgTR,?SendOrderThisBar????global?PreBreakoutFailure,?ContractId????global?myEntryPrice,?myExitPrice????global?ExitHighestPrice,?ExitLowestPrice????global?DonchianHi,?DonchianLo???????global?fsDonchianHi,?fsDonchianLo
    ????if?BarStatus()?==?0:????????PreEP?=?np.nan????????PreBreakoutFailure?=?False
    ????MinPoint?=?PriceTick()????
    ????barsinfo?=?HisBarsInfo()
    ????bslen?=?len(barsinfo)
    ????if?bslen?<?fsLength:????????return
    ????op?=?barsinfo[-1]["OpeningPrice"]
    ????highs,?lows,?trs?=?TrueRange(barsinfo)????????high??=?highs[-1]????low???=?lows[-1]????phigh?=?high?if?len(highs)?<=?1?else?highs[-2]????plow??=?low??if?len(lows)??<=?1?else?lows[-2]
    ????N?=?AvgTR????AvgTR?=?XAverage(trs,?ATRLength)
    ???????TotalEquity?=?Available()?+?Margin()????TurtleUnits?=?(TotalEquity*RiskRatio/100)/(N*ContractUnit(ContractId))????TurtleUnits?=?int(TurtleUnits)????maxUnites?=?int(Available()/(high*ContractUnit(ContractId)))????TurtleUnits?=?min(maxUnites?,?TurtleUnits)????LogInfo("avl:%f,?mar:%f,?conu:%f,?tu:%f,?N:%f,?mp:%f,?cidx:%d,?bslen:%d\n"?\????????%(Available(),?Margin(),?ContractUnit(ContractId),?TurtleUnits,?N,?MinPoint,?CurrentBar(),?bslen))
    ????DonchianHi???=?ta.MAX(highs[:-1],?timeperiod=boLength)[-1]????DonchianLo???=?ta.MIN(lows[:-1],??timeperiod=boLength)[-1]????fsDonchianHi?=?ta.MAX(highs[:-1],?timeperiod=fsLength)[-1]????fsDonchianLo?=?ta.MIN(lows[:-1],??timeperiod=fsLength)[-1]????ExitHighestPrice?=?ta.MAX(highs[:-1],?timeperiod=teLength)[-1]????ExitLowestPrice?=?ta.MIN(lows[:-1],??timeperiod=teLength)[-1]
    ????LogInfo("mpos:%d,?bpos:%d,?spos:%d\n"?%(MarketPosition(),?BuyPosition(),?SellPosition()))????LogInfo("low:%f,high:%f,dh:%f,dl:%f,fdh:%f,fdl:%f,ehp:%f,elp:%f,pep:%f,n:%f\n"?%(low,?high,?DonchianHi,?\????????DonchianLo,?fsDonchianHi,?fsDonchianLo,?ExitHighestPrice,?ExitLowestPrice,PreEP,N))
    ???????if?MarketPosition()?==?0?and?((not?LPTF)?or?PreBreakoutFailure)?and?condict():????????if?Close()[-1]?>?DonchianHi?+?p*PriceTick()?and?Open()[-1]-Open()[-2]?<?200*PriceTick()?and?Close()[-1]?>?Open()[-1]?and?TurtleUnits?>=?1?and?Close()[-1]?-?Open()[-1]?<?p2*PriceTick()?and?Close()[-1]?>?max(Close()[-2]?,?Open()[-2])?:????????????myEntryPrice?=?min(high,?DonchianHi?+?MinPoint)????????????myEntryPrice?=?max(op,?myEntryPrice)????????????PreEP?=?myEntryPrice????????????Buy(TurtleUnits,?Close()[-1]+1*PriceTick())????????????SendOrderThisBar?=?True????????????PreBreakoutFailure?=?False
    ????????if?Close()[-1]?<?DonchianLo?-?p*PriceTick()?and?Open()[-2]-Open()[-1]<200*PriceTick()?and?Close()[-1]?<?Open()[-1]?and?TurtleUnits?>=?1?and?Open()[-1]?-?Close()[-1]?<?p2*PriceTick()?and?Close()[-1]?<?min(Close()[-2]?,?Open()[-2])?:????????????#?????????????myEntryPrice?=?max(low,?DonchianLo?-?MinPoint)????????????#?????????????myEntryPrice?=?min(op,?myEntryPrice)????????????PreEP?=?myEntryPrice????????????SellShort(TurtleUnits,?Close()[-1]-1*PriceTick())????????????SendOrderThisBar?=?True????????????PreBreakoutFailure?=?False
    ????#?????if?MarketPosition()?==?0?and?condict():????????if?Close()[-1]?>?fsDonchianHi?+?p*PriceTick()?and?Open()[-1]-Open()[-2]<100*PriceTick()?and?Close()[-1]?>?Open()[-1]?and?TurtleUnits?>=?1?and?Close()[-1]?-?Open()[-1]?<?p2*PriceTick()?and?Close()[-1]?>?max(Close()[-2]?,?Open()[-2])?:????????????#?????????????myEntryPrice?=?min(high,?fsDonchianHi?+?MinPoint)????????????#?????????????myEntryPrice?=?max(op,?myEntryPrice)????????????PreEP?=?myEntryPrice????????????Buy(TurtleUnits,?Close()[-1])????????????SendOrderThisBar?=?True????????????PreBreakoutFailure?=?False
    ????????if?Close()[-1]?<?fsDonchianLo?-?p*PriceTick()?and?Open()[-2]-Open()[-1]<100*PriceTick()?and?Close()[-1]?<?Open()[-1]?and?TurtleUnits?>=?1?and?Open()[-1]?-?Close()[-1]?<?p2*PriceTick()?and?Close()[-1]?<?min(Close()[-2]?,?Open()[-2]):????????????#?????????????myEntryPrice?=?max(low,?fsDonchianLo?-?MinPoint)????????????#?????????????myEntryPrice?=?min(op,?myEntryPrice)????????????PreEP?=?myEntryPrice????????????SellShort(TurtleUnits,?Close()[-1])????????????SendOrderThisBar?=?True????????????PreBreakoutFailure?=?False
    ????#?????if?MarketPosition()?==?1?and?condict():????????if?Close()[-1]??<?ExitLowestPrice?:????????????myExitPrice?=?max(low,?ExitLowestPrice?-?MinPoint)????????????myExitPrice?=?min(op,?myExitPrice)????????????#?全平多倉????????????bpos?=?BuyPosition()????????????if?bpos?>?0:????????????????Sell(bpos,?Close()[-1]-1*PriceTick()?)????????else:????????????if?PreEP?!=?np.nan?and?TurtleUnits?>=?1?and?BuyPosition()?<=?400?and?Close()[-1]?-?Open()[-1]?<?p2*PriceTick()?and?Close()[-1]?>?max(Close()[-2]?,?Open()[-2])?:????????????????if??Close()[-1]?>=?PreEP?+?0.5*N?and?Close()[-1]?>?Open()[-1]?:????????????????????myEntryPrice?=?high????????????????????PreEP?=?myEntryPrice????????????????????Buy(TurtleUnits,?Close()[-1])????????????????????SendOrderThisBar?=?True????????????if?PreEP?!=?np.nan?and?BuyPosition()?>=?400?and?Close()[-1]?-?Open()[-1]?<?p2*PriceTick()?and?Close()[-1]?>?max(Close()[-2]?,?Open()[-2]):????????????????if??Close()[-1]?>=?PreEP?+?0.5*N?and?Close()[-1]?>?Open()[-1]?:????????????????????myEntryPrice?=?high????????????????????PreEP?=?myEntryPrice????????????????????Buy(int(TurtleUnits/3),?Close()[-1])????????????????????SendOrderThisBar?=?True

    ????????????#?????????????if?(Close()[-1]??<=?(PreEP?-?2*N)?-?p*PriceTick()?or?Close()[-1]?<?Open()[-1])?and?SendOrderThisBar?==?False:????????????????myExitPrice?=?PreEP?-?2*N????????????????#?????????????????bpos?=?BuyPosition()????????????????if?bpos?>?0:????????????????????Sell(bpos,?Close()[-1]-1*PriceTick()?)????????????????PreBreakoutFailure?=?True????#?????elif?MarketPosition()?==?-1?and?condict():????????#????????#?????????if?Close()[-1]?>?ExitHighestPrice??:????????????myExitPrice?=?min(high,?ExitHighestPrice?+?MinPoint)????????????#?????????????myExitPrice?=?max(op,?myExitPrice)????????????#?????????????spos?=?SellPosition()????????????if?spos?>?0:????????????????BuyToCover(spos,?Close()[-1]?+1*PriceTick())????????else:????????????if?PreEP?!=?np.nan?and?TurtleUnits?>=?1?and?SellPosition()?<=?1500?and?Open()[-1]?-?Close()[-1]?<?p2*PriceTick()?and?Close()[-1]?<?min(Low()[-2]?,?Low()[-3]?,?Low()[-4],?Low()[-5],?Low()[-6],?Low()[-7]?,?Low()[-8],?Low()[-9],?Low()[-10]?):????????????????if??Close()[-1]?<=?PreEP?-?0.5*N?and?Close()[-1]?<?Open()[-1]:????????????????????myEntryPrice?=?low????????????????????PreEP?=?myEntryPrice????????????????????SellShort(TurtleUnits,?Close()[-1])????????????????????SendOrderThisBar?=?True????????????if?PreEP?!=?np.nan?and?SellPosition()?>?1500?and?Open()[-1]?-?Close()[-1]?<?p2*PriceTick()?and?Close()[-1]?<?min(Low()[-2]?,?Low()[-3]?,?Low()[-4],?Low()[-5],?Low()[-6],?Low()[-7]?,?Low()[-8],?Low()[-9],?Low()[-10]):????????????????if??Close()[-1]?<=?PreEP?-?0.5*N?and?Close()[-1]?<?Open()[-1]:????????????????????myEntryPrice?=?low????????????????????PreEP?=?myEntryPrice????????????????????SellShort(int(TurtleUnits/2),?Close()[-1])????????????????????SendOrderThisBar?=?True

    ????????????#?????????????if?(Close()[-1]?>=?(PreEP?+?2*N)?+?p*PriceTick())?and?SendOrderThisBar?==?False:????????????????myExitPrice?=?PreEP?+?2*N????????????????#?????????????????spos?=?SellPosition()????????????????if?spos?>?0:????????????????????BuyToCover(spos,?Close()[-1]+1*PriceTick()?)????????????????PreBreakoutFailure?=?True
    ????#?????if?SellPosition()?>=?1800?and?condict():????????BuyToCover(SellPosition(),?Close()[-1]+1*PriceTick())????if?SellPosition()?>=?1800?and?condict():????????Sell(SellPosition(),?Close()[-1]-1*PriceTick())???????????#?止損????SetStopPoint(g_params['topPoint')????#?止贏????SetWinPoint(g_params['inPoint')????#?浮動止損????SetFloatStopPoint(g_params['loatStopStart',?g_params['loatStopPoint')

    ????

    ?

    ?來源:程序化99

  • 文華技術人員: ?指標源碼與麥語言相差太大,無法改寫的
    或者,您詳細描述下指標的取值定義思路,我們根據思路直接幫您編寫實現(xiàn)

 

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

可聯(lián)系技術人員 QQ: 262069696  點擊在線交流或微信號:cxh99cxh99  進行 有償收費 編寫!

怎么收費,代編流程等詳情請點擊閱讀!

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


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

相關文章

    沒有相關內容
主站蜘蛛池模板: 色偷偷视频| 色在线网 | 操欧美美女| 免费国产成人α片 | 国产一区高清视频 | 91精品国产91久久久久久青草 | 九九九在线视频 | 亚洲一区二区免费视频 | 国产凹凸在线观看一区二区 | 人人狠人人透人人爱 | 欧美三级中文字幕hd | 欧美视频高清在线观看 | 欧美不卡一区二区三区免 | 无遮挡h黄漫动漫在线观看 无遮挡h纯内动漫在线观看 | 一丝不遮视频免费观看 | 成人毛片在线观看 | 综合自拍亚洲综合图不卡区 | 国产精品九九九久久九九 | 天天射寡妇射 | 国产免费黄色网址 | 免费的色视频 | 亚洲字幕久久 | 精品伊人久久大线蕉色首页 | 又黄又爽视频好爽视频 | 国产黄的网站免费 | 漂流教室在线观看 | 日日摸夜夜添夜夜添特色大片 | 天天做天天爱天天影视综合 | 在线成人小视频 | 黄色网址视频在线播放 | 久久久这里只有免费精品2018 | 嫩草在线视频www免费观看 | 2020国产精品视频免费 | 久久午夜夜伦伦鲁鲁片 | 亚洲最大的黄色网址 | 日韩一区二区三区视频在线观看 | 免费一级毛片在线播放不收费 | japan高清日本乱xxxx | 7m视频在线观看高清国产7m | 天海翼一区二区三区四区 | 又黄又变态又免费的视频 |