大伊人青草狠狠久久-大伊香蕉精品视频在线-大伊香蕉精品一区视频在线-大伊香蕉在线精品不卡视频-大伊香蕉在线精品视频75-大伊香蕉在线精品视频人碰人

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

海龜模型 改成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

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

 

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

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

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

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


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

相關文章

    沒有相關內容
主站蜘蛛池模板: 性色视频在线 | 国产精品精品国产一区二区 | 国产在线视频资源 | 伊人久久成人爱综合网 | 青春禁区视频在线观看动漫版 | 国产成人无精品久久久久国语 | 久久亚洲国产精品五月天婷 | 新香蕉视频在线 | 天天拍夜夜添久久精品中文 | 国产精品第一页爽爽影院 | 亚洲精品久久久久久婷婷 | 亚洲精品国产第一区二区三区 | 一级黄色α片 | 国产伊人网 | 久久国产这里只精品免费 | 久章草在线视频 | 激情婷婷网 | 日本高清免费不卡毛片 | 免费中文字幕 | 国产成人刺激视频在线观看 | 中文字幕一区二区三区四区 | 亚洲字幕久久 | 香港之夜免费观看 | 奇米影视第七色 | 九九色播 | 久操视频网站 | 四虎影院免费视频 | 苦瓜se影院在线视频网站 | 神马影院我不卡手机版 | 奇米狠狠 | 日韩伦理亚洲欧美在线一区 | 国产一区二区免费不卡在线播放 | 色偷偷亚洲精品一区 | 亚洲永久精品一区二区三区 | 九九国产精品 | 国产精品亚洲专区在线播放 | 成人亚洲欧美 | 欧美亚洲另类久久综合 | 九九精品成人免费国产片 | 亚洲国产第一区二区香蕉 | 亚洲高清在线观看看片 |