欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件策略编写求助区 → 海龟经典软件-TRADING BLOX策略

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有12094人关注过本帖平板打印复制链接

主题:海龟经典软件-TRADING BLOX策略

帅哥哟,离线,有人找我吗?
solarhe2006
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:252 积分:1001 威望:0 精华:0 注册:2010/2/15 16:47:58
海龟经典软件-TRADING BLOX策略  发帖心情 Post By:2011/3/30 21:34:55 [只看该作者]

 

Entry Order Filled:

VARIABLES: stopAmount, stopPrice, originalATR TYPE: Price

VARIABLES: unitFillPrice, newStopPrice TYPE:Price

VARIABLES: newUnitExitStop, originalExitStop, newExitStop TYPE: Price

VARIABLES: entryDayIndex TYPE: Integer

VARIABLES: unitsOn, unitIndex TYPE: Integer

 

'----------------------------

' Get the total number of units on now, including this new unit

unitsOn = instrument.totalUnits

 

' Calculate the new exit stop for this new unit, based on the fill price

if instrument.position = LONG then newUnitExitStop = order.fillPrice - order.entryRisk

if instrument.position = SHORT then newUnitExitStop = order.fillPrice + order.entryRisk

 

' Set exit stop for this new unit added

instrument.setExitStop( unitsOn, newUnitExitStop )

 

 

'------------------------------

' If more than one unit on, then

' Reset the stops for all units, except the current one, based on this new unit

' For each unit, look for the original ATR and calculate the original stop price

' Add to the original stop 

'------------------------------

 

IF unitsOn > 1 THEN

    IF instrument.position = LONG THEN

        FOR unitIndex = 1 TO unitsOn - 1 

        

            ' Compute the ATR TYPE: of the entry for this unit.

            entryDayIndex = instrument.bar - instrument.unitEntryDayIndex[ unitIndex ]

            originalATR = averageTrueRange[ entryDayIndex ]

            

            ' Get the fill price.

            unitFillPrice = instrument.unitentryfill[ unitIndex ]

            

            ' Compute the original exit stop.

            originalExitStop = unitFillPrice - stopInATR * originalATR

            

            ' Now compute the new stop based on the original ATR.

            newStopPrice = originalExitStop + ( unitsOn - unitIndex ) * unitAdd * originalATR

            

            ' Constrain the stop to the fill price or the new unit stop.

            newExitStop = min( newStopPrice, unitFillPrice, newUnitExitStop )

            

            ' Give the instrument this new stop.

            instrument.setExitStop( unitIndex, newExitStop )

        NEXT

    ENDIF

    

    IF instrument.position = SHORT THEN

        FOR unitIndex = 1 TO unitsOn - 1 

        

            ' Compute the ATR TYPE: of the entry for this unit.

            entryDayIndex = instrument.bar - instrument.unitEntryDayIndex[ unitIndex ]

            originalATR = averageTrueRange[ entryDayIndex ]

            

            ' Get the fill price.

            unitFillPrice = instrument.unitentryfill[ unitIndex ]

            

            ' Compute the original exit stop.

            originalExitStop = unitFillPrice + stopInATR * originalATR

            

            ' Now compute the new stop based on the original ATR.

            newStopPrice = originalExitStop - ( unitsOn - unitIndex ) * unitAdd * originalATR

            

            ' Constrain the stop to the fill price or the new unit stop.

            newExitStop = max( newStopPrice, unitFillPrice, newUnitExitStop )

            

            ' Give the instrument this new stop.

            instrument.setExitStop( unitIndex, newExitStop )

        NEXT

    ENDIF

ENDIF

 

 

' ----------------------------------

' Track theoretical positions

' ----------------------------------

 

' Only run these calcs if we have to

IF ( tradeIfWinner = FALSE ) THEN 

 

    ' If this is the first unit on, then set the theoretical position at this point

    IF unitsOn = 1 THEN 

        theoreticalPosition = instrument.position

        theoreticalEntryPrice = order.fillprice

        theoreticalExitStop = order.stopprice

    ENDIF

ENDIF

 


 回到顶部
总数 11 1 2 下一页