Tham khảo tài liệu 'ehlers, john - cybernetics analysis for stock and futures_3', tài chính - ngân hàng, đầu tư chứng khoán phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 42 CYBERNETIC ANALYSIS FOR STOCKS AND FUTURES aPriceArray 0 nPrice if aPriceArray 3 0 return aSmoothArray 0 aPriceArray 0 2 aPriceArray 1 2 aPriceArray 2 aPriceArray 3 6 if nBarCount 7 aCycleArray 0 aPriceArray 0 - 2 aPriceArray 1 aPriceArray 2 4 else aCycleArray 0 1 - Alpha 1 - Alpha aSmoothArray 0 - 2 aSmoothArray 1 aSmoothArray 2 2 1-Alpha aCycleArray 1 - 1-Alpha 1-Alpha aCycleArray 2 create the actual trading signals nAlpha2 1 Lag 1 aSignalArray 0 nAlpha2 aCycleArray 0 - nAlpha2 aSignalArray 1 process our trading strategy code nStatus 0 if true nStatus 1 if true nStatus -1 currently not in a trade so look for a trigger if nBarCount 10 nStatus 0 signal cross down - we buy if aSignalArray 0 aSignalArray 1 _ FIGURE Continued Trading the Cycle 43 aSignalArray 1 aSignalArray 2 goLong signal cross up - we sell if aSignalArray O aSignalArray 1 _ aSignalArray 1 aSignalArray 2 goShort currently in a trade so look for profit stop_ or reversal else if nBarCount 10 nStatus 0 if nStatus 1 in a long trade if trade is unprofitable after_ 8 bars exit position if closet - nEntryPrice 0 nBarsInTrade 8 closeLong otherwise check for trigger in_ other direction if aSignalArrayCO aSignalArray 1 _ aSignalArray 1 aSignalArray 2 goShort else if nStatus -1 in a_ short trade if trade is unprofitable after_ 8 bars exit position if nEntryPrice - closet 0_ nBarsInTrade 8 closeshort otherwise check for trigger in_ other direction if aSignalArray 0 aSignalArray 1 _ continued FIGURE Continued 44 CYBERNETIC ANALYSIS FOR STOCKS AND FUTURES I aSignalArray l aSignalArray 2 goLong return new Array aSignalArray 0 _ aSignalArray l enter a short trade function goShort drawShapeRelative 1 aSignalArray 1 _ gIDO Short signal _ nStatus -1 nEntryPrice open l nBarsInTrade 1 exit a short trade function closeShortO drawShapeRelative -O .