커뮤니티

문의드립니다.

프로필 이미지
잡다백수
2018-03-22 17:18:35
207
글번호 117634
답변완료
매번 감사합니다. 1. 기타 코딩 변환 부탁드립니다. inputs: Price( Close ), { price of which the standard deviation is calculated } Length( 90 ), { number of bars used in average true range (ATR) and standard deviation (SD) calculations } nK( 3 ), { number of ATRs to add to average to form Keltner channel } nBB( 2 ), { number of standard deviations used to calculate Bollinger bands } AlertLine( 1 ), { Bollinger band squeeze indicator (BBS_Ind) level at which to issue alerts } TargetPctOfRange( 100 ) ; { percentage of width of rectangle at which to place profit target } variables: Rectangle( false ), ATR( 0 ), SDev( 0 ), BBS_Ind( 0 ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ) ; if MarketPosition <> 0 then Rectangle = false ; { Calculate Bollinger band squeeze indicator } ATR = AvgTrueRange( Length ) ; SDev = StandardDev( Price, Length, 1 ) ; if nK <> 0 and ATR <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATR ) ; if BBS_Ind crosses under AlertLine and Rectangle = false and MarketPosition = 0 then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; end ; end ; if Rectangle = true then begin if Close >= RectangleTop then Buy this bar Close else if Close <= RectangleBase then Sell short this bar at Close ; end ; if MarketPosition = 1 then begin if Close >= RectangleTop + 0.01 * TargetPctOfRange * RectangleRange then Sell( “LX PT” ) this bar at Close ; if Close <= RectangleTop - .5 * RectangleRange then Sell( “LX SL” ) this bar at Close ; end else if MarketPosition = -1 then begin if Close <= RectangleBase - 0.01 * TargetPctOfRange * RectangleRange then BuyToCover( “SX PT” ) this bar at Close ; if Close >= RectangleBase + .5 * RectangleRange then Buy to cover( “SX SL” ) this bar at Close ; end ; Indicator: RectangleEvaluation {Rectangle definition: See comments in code for strategy “RectangleBreakout”. } inputs: Price( Close ), { price of which the standard deviation is calculated } Length( 90 ), { number of bars used in average true range (ATR) and standard deviation (SD) calculations } nK( 3 ), { number of ATRs to add to average to form Keltner channel } nBB( 2 ), { number of standard deviations used to calculate Bollinger bands } AlertLine( 1 ), { Bollinger band squeeze indicator (BBS_Ind) level at which to issue alerts } TargetPctOfRange( 100 ) ; { percentage of width of rectangle at which to place profit target } variables: ATR( 0 ), SDev( 0 ), BBS_Ind( 0 ), Rectangle( false ), LongPosition( false ), ShortPosition( false ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ), LongTarget( 0 ), LongPositionCount( 0 ), ShortTarget( 0 ), ShortPositionCount( 0 ), LongTargetCount( 0 ), ShortTargetCount( 0 ) ; { Calculate Bollinger band squeeze indicator } ATR = AvgTrueRange( Length ) ; SDev = StandardDev( Price, Length, 1 ) ; if nK <> 0 and ATR <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATR ) ; if BBS_Ind crosses under AlertLine and Rectangle = false and LongPosition = false and ShortPosition = false then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; Plot1( Close, “Alert” ) ; end ; end ; if RectangleTop <> 0 and Rectangle = true then begin Plot2( RectangleTop, “Top” ) ; Plot3( RectangleBase, “Base” ) ; end ; if Rectangle = true then begin if Close crosses over RectangleTop then begin LongTarget = RectangleTop + 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; LongPosition = true ; LongPositionCount = LongPositionCount + 1 ; end ; if Close crosses under RectangleBase then begin ShortTarget = RectangleBase - 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; ShortPosition = true ; ShortPositionCount = ShortPositionCount + 1 ; end ; end ; if LongPosition = true then begin if Close > LongTarget then begin LongTargetCount = LongTargetCount + 1 ; LongPosition = false ; end else if Close < RectangleTop - .5 * RectangleRange then LongPosition = false ; Plot4( LongTarget, “Tgt” ) ; end else if ShortPosition = true then begin if Close < ShortTarget then begin ShortTargetCount = ShortTargetCount + 1 ; ShortPosition = false ; end else if Close > RectangleBase + .5 * RectangleRange then ShortPosition = false ; Plot4( ShortTarget, “Tgt” ) ; end ; Indicator: Rectangle-RS {Rectangle definition: See comments in code for strategy “RectangleBreakout”. } inputs: Price( Close ), { price of which the standard deviation is calculated } Length( 90 ), { number of bars used in average true range (ATR) and standard deviation (SD) calculations } nK( 3 ), { number of ATRs to add to average to form Keltner channel } nBB( 2 ), { number of standard deviations used to calculate Bollinger bands } AlertLine( 1 ), { Bollinger band squeeze indicator (BBS_Ind) level at which to issue alerts } TargetPctOfRange( 100 ) ; { percentage of width of rectangle at which to place profit target } variables: ATR( 0 ), SDev( 0 ), BBS_Ind( 0 ), Rectangle( false ), LongPosition( false ), ShortPosition( false ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ), LongTarget( 0 ), LongPositionCount( 0 ), ShortTarget( 0 ), ShortPositionCount( 0 ), LongTargetCount( 0 ), ShortTargetCount( 0 ), LongTgtHitRatio( 0 ), ShortTgtHitRatio( 0 ) ; { Calculate Bollinger band squeeze indicator } ATR = AvgTrueRange( Length ) ; SDev = StandardDev( Price, Length, 1 ) ; if nK <> 0 and ATR <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATR ) ; if BBS_Ind crosses under AlertLine and Rectangle = false and LongPosition = false and ShortPosition = false then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; end ; end ; if RectangleTop <> 0 and Rectangle = true then begin Plot2( RectangleTop, “Top” ) ; Plot3( RectangleBase, “Base” ) ; end ; if Rectangle = true then begin if Close crosses over RectangleTop then begin LongTarget = RectangleTop + 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; LongPosition = true ; LongPositionCount = LongPositionCount + 1 ; end ; if Close crosses under RectangleBase then begin ShortTarget = RectangleBase - 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; ShortPosition = true ; ShortPositionCount = ShortPositionCount + 1 ; end ; end ; if LongPosition = true then begin if Close > LongTarget then begin LongTargetCount = LongTargetCount + 1 ; LongPosition = false ; end else if Close < RectangleTop - .5 * RectangleRange then LongPosition = false ; end else if ShortPosition = true then begin if Close < ShortTarget then begin ShortTargetCount = ShortTargetCount + 1 ; ShortPosition = false ; end else if Close > RectangleBase + .5 * RectangleRange then ShortPosition = false ; end ; if LongPositionCount > 0 then begin LongTgtHitRatio = LongTargetCount / LongPositionCount ; Plot5( LongTgtHitRatio, “LongTgtRatio” ) ; end ; if ShortPositionCount > 0 then begin ShortTgtHitRatio = ShortTargetCount / ShortPositionCount ; Plot6( ShortTgtHitRatio, “ShrtTgtRatio” ) ; end ;
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2018-03-23 10:05:20

안녕하세요 예스스탁입니다. 1 inputs: Length( 90 ), nK( 3 ), nBB( 2 ), AlertLine( 1 ), TargetPctOfRange( 100 ) ; variables: Rectangle( false ), ATRv( 0 ), SDev( 0 ), BBS_Ind( 0 ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ),Price(0); Price = C; if MarketPosition <> 0 then Rectangle = false ; ATRv = atr( Length ) ; SDev = std(Price, Length) ; if nK <> 0 and ATRv <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATRv ) ; if crossdown(BBS_Ind , AlertLine) and Rectangle == false and MarketPosition == 0 then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; end ; end ; if Rectangle == true then begin if Close >= RectangleTop then Buy("b"); else if Close <= RectangleBase then Sell("s"); end ; if MarketPosition == 1 then begin if Close >= RectangleTop + 0.01 * TargetPctOfRange * RectangleRange then ExitLong("LX PT"); if Close <= RectangleTop - .5 * RectangleRange then ExitLong("LX SL"); end else if MarketPosition == -1 then begin if Close <= RectangleBase - 0.01 * TargetPctOfRange * RectangleRange then ExitShort("SX PT"); if Close >= RectangleBase + .5 * RectangleRange then ExitShort("SX SL"); end; 2 inputs: Length( 90 ), nK( 3 ), nBB( 2 ), AlertLine( 1 ), TargetPctOfRange( 100 ) ; variables: ATRv( 0 ), SDev( 0 ), BBS_Ind( 0 ), Rectangle( false ), LongPosition( false ), ShortPosition( false ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ), LongTarget( 0 ), LongPositionCount( 0 ), ShortTarget( 0 ), ShortPositionCount( 0 ), LongTargetCount( 0 ), ShortTargetCount( 0 ),Price(0) ; Price = c; ATRv = atr( Length ) ; SDev = Std( Price, Length) ; if nK <> 0 and ATRv <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATRv ) ; if crossdown(BBS_Ind , AlertLine) and Rectangle == false and LongPosition == false and ShortPosition == false then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; Plot1( Close, "Alert") ; end ; end ; if RectangleTop <> 0 and Rectangle == true then begin Plot2( RectangleTop,"Top" ) ; Plot3( RectangleBase, "Base") ; end ; if Rectangle == true then begin if crossup(Close , RectangleTop) then begin LongTarget = RectangleTop + 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; LongPosition = true ; LongPositionCount = LongPositionCount + 1 ; end ; if crossdown(Close, RectangleBase) then begin ShortTarget = RectangleBase - 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; ShortPosition = true ; ShortPositionCount = ShortPositionCount + 1 ; end ; end ; if LongPosition == true then begin if Close > LongTarget then begin LongTargetCount = LongTargetCount + 1 ; LongPosition = false ; end else if Close < RectangleTop - .5 * RectangleRange then LongPosition = false ; Plot4( LongTarget,"Tgt") ; end else if ShortPosition == true then begin if Close < ShortTarget then begin ShortTargetCount = ShortTargetCount + 1 ; ShortPosition = false ; end else if Close > RectangleBase + .5 * RectangleRange then ShortPosition = false ; Plot4( ShortTarget,"Tgt") ; end ; 3 inputs: Length( 90 ), nK( 3 ), nBB( 2 ), AlertLine( 1 ), TargetPctOfRange( 100 ) ; variables: ATRv( 0 ), SDev( 0 ), BBS_Ind( 0 ), Rectangle( false ), LongPosition( false ), ShortPosition( false ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ), LongTarget( 0 ), LongPositionCount( 0 ), ShortTarget( 0 ), ShortPositionCount( 0 ), LongTargetCount( 0 ), ShortTargetCount( 0 ), LongTgtHitRatio( 0 ), ShortTgtHitRatio( 0 ),Price(0) ; Price = C; ATRv = atr( Length ) ; SDev = std( Price, Length) ; if nK <> 0 and ATRv <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATRv ) ; if crossdown(BBS_Ind, AlertLine) and Rectangle == false and LongPosition == false and ShortPosition == false then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; end ; end ; if RectangleTop <> 0 and Rectangle == true then begin Plot2( RectangleTop, "Top" ) ; Plot3( RectangleBase, "Base" ) ; end ; if Rectangle == true then begin if crossup(Close, RectangleTop) then begin LongTarget = RectangleTop + 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; LongPosition = true ; LongPositionCount = LongPositionCount + 1 ; end ; if crossdown( Close, RectangleBase) then begin ShortTarget = RectangleBase - 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; ShortPosition = true ; ShortPositionCount = ShortPositionCount + 1 ; end ; end ; if LongPosition == true then begin if Close > LongTarget then begin LongTargetCount = LongTargetCount + 1 ; LongPosition = false ; end else if Close < RectangleTop - .5 * RectangleRange then LongPosition = false ; end else if ShortPosition == true then begin if Close < ShortTarget then begin ShortTargetCount = ShortTargetCount + 1 ; ShortPosition = false ; end else if Close > RectangleBase + .5 * RectangleRange then ShortPosition = false ; end ; if LongPositionCount > 0 then begin LongTgtHitRatio = LongTargetCount / LongPositionCount ; Plot5( LongTgtHitRatio, "LongTgtRatio" ) ; end ; if ShortPositionCount > 0 then begin ShortTgtHitRatio = ShortTargetCount / ShortPositionCount ; Plot6( ShortTgtHitRatio, "ShrtTgtRatio" ) ; end ; 즐거운 하루되세요 > 잡다백수 님이 쓴 글입니다. > 제목 : 문의드립니다. > 매번 감사합니다. 1. 기타 코딩 변환 부탁드립니다. inputs: Price( Close ), { price of which the standard deviation is calculated } Length( 90 ), { number of bars used in average true range (ATR) and standard deviation (SD) calculations } nK( 3 ), { number of ATRs to add to average to form Keltner channel } nBB( 2 ), { number of standard deviations used to calculate Bollinger bands } AlertLine( 1 ), { Bollinger band squeeze indicator (BBS_Ind) level at which to issue alerts } TargetPctOfRange( 100 ) ; { percentage of width of rectangle at which to place profit target } variables: Rectangle( false ), ATR( 0 ), SDev( 0 ), BBS_Ind( 0 ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ) ; if MarketPosition <> 0 then Rectangle = false ; { Calculate Bollinger band squeeze indicator } ATR = AvgTrueRange( Length ) ; SDev = StandardDev( Price, Length, 1 ) ; if nK <> 0 and ATR <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATR ) ; if BBS_Ind crosses under AlertLine and Rectangle = false and MarketPosition = 0 then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; end ; end ; if Rectangle = true then begin if Close >= RectangleTop then Buy this bar Close else if Close <= RectangleBase then Sell short this bar at Close ; end ; if MarketPosition = 1 then begin if Close >= RectangleTop + 0.01 * TargetPctOfRange * RectangleRange then Sell( “LX PT” ) this bar at Close ; if Close <= RectangleTop - .5 * RectangleRange then Sell( “LX SL” ) this bar at Close ; end else if MarketPosition = -1 then begin if Close <= RectangleBase - 0.01 * TargetPctOfRange * RectangleRange then BuyToCover( “SX PT” ) this bar at Close ; if Close >= RectangleBase + .5 * RectangleRange then Buy to cover( “SX SL” ) this bar at Close ; end ; Indicator: RectangleEvaluation {Rectangle definition: See comments in code for strategy “RectangleBreakout”. } inputs: Price( Close ), { price of which the standard deviation is calculated } Length( 90 ), { number of bars used in average true range (ATR) and standard deviation (SD) calculations } nK( 3 ), { number of ATRs to add to average to form Keltner channel } nBB( 2 ), { number of standard deviations used to calculate Bollinger bands } AlertLine( 1 ), { Bollinger band squeeze indicator (BBS_Ind) level at which to issue alerts } TargetPctOfRange( 100 ) ; { percentage of width of rectangle at which to place profit target } variables: ATR( 0 ), SDev( 0 ), BBS_Ind( 0 ), Rectangle( false ), LongPosition( false ), ShortPosition( false ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ), LongTarget( 0 ), LongPositionCount( 0 ), ShortTarget( 0 ), ShortPositionCount( 0 ), LongTargetCount( 0 ), ShortTargetCount( 0 ) ; { Calculate Bollinger band squeeze indicator } ATR = AvgTrueRange( Length ) ; SDev = StandardDev( Price, Length, 1 ) ; if nK <> 0 and ATR <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATR ) ; if BBS_Ind crosses under AlertLine and Rectangle = false and LongPosition = false and ShortPosition = false then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; Plot1( Close, “Alert” ) ; end ; end ; if RectangleTop <> 0 and Rectangle = true then begin Plot2( RectangleTop, “Top” ) ; Plot3( RectangleBase, “Base” ) ; end ; if Rectangle = true then begin if Close crosses over RectangleTop then begin LongTarget = RectangleTop + 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; LongPosition = true ; LongPositionCount = LongPositionCount + 1 ; end ; if Close crosses under RectangleBase then begin ShortTarget = RectangleBase - 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; ShortPosition = true ; ShortPositionCount = ShortPositionCount + 1 ; end ; end ; if LongPosition = true then begin if Close > LongTarget then begin LongTargetCount = LongTargetCount + 1 ; LongPosition = false ; end else if Close < RectangleTop - .5 * RectangleRange then LongPosition = false ; Plot4( LongTarget, “Tgt” ) ; end else if ShortPosition = true then begin if Close < ShortTarget then begin ShortTargetCount = ShortTargetCount + 1 ; ShortPosition = false ; end else if Close > RectangleBase + .5 * RectangleRange then ShortPosition = false ; Plot4( ShortTarget, “Tgt” ) ; end ; Indicator: Rectangle-RS {Rectangle definition: See comments in code for strategy “RectangleBreakout”. } inputs: Price( Close ), { price of which the standard deviation is calculated } Length( 90 ), { number of bars used in average true range (ATR) and standard deviation (SD) calculations } nK( 3 ), { number of ATRs to add to average to form Keltner channel } nBB( 2 ), { number of standard deviations used to calculate Bollinger bands } AlertLine( 1 ), { Bollinger band squeeze indicator (BBS_Ind) level at which to issue alerts } TargetPctOfRange( 100 ) ; { percentage of width of rectangle at which to place profit target } variables: ATR( 0 ), SDev( 0 ), BBS_Ind( 0 ), Rectangle( false ), LongPosition( false ), ShortPosition( false ), RectangleTop( 0 ), RectangleBase( 0 ), RectangleRange( 0 ), LongTarget( 0 ), LongPositionCount( 0 ), ShortTarget( 0 ), ShortPositionCount( 0 ), LongTargetCount( 0 ), ShortTargetCount( 0 ), LongTgtHitRatio( 0 ), ShortTgtHitRatio( 0 ) ; { Calculate Bollinger band squeeze indicator } ATR = AvgTrueRange( Length ) ; SDev = StandardDev( Price, Length, 1 ) ; if nK <> 0 and ATR <> 0 then begin BBS_Ind = ( nBB * SDev ) / ( nK * ATR ) ; if BBS_Ind crosses under AlertLine and Rectangle = false and LongPosition = false and ShortPosition = false then begin RectangleTop = Highest( Close, Length ) ; RectangleBase = Lowest( Close, Length ) ; RectangleRange = RectangleTop - RectangleBase ; Rectangle = true ; end ; end ; if RectangleTop <> 0 and Rectangle = true then begin Plot2( RectangleTop, “Top” ) ; Plot3( RectangleBase, “Base” ) ; end ; if Rectangle = true then begin if Close crosses over RectangleTop then begin LongTarget = RectangleTop + 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; LongPosition = true ; LongPositionCount = LongPositionCount + 1 ; end ; if Close crosses under RectangleBase then begin ShortTarget = RectangleBase - 0.01 * TargetPctOfRange * RectangleRange ; Rectangle = false ; ShortPosition = true ; ShortPositionCount = ShortPositionCount + 1 ; end ; end ; if LongPosition = true then begin if Close > LongTarget then begin LongTargetCount = LongTargetCount + 1 ; LongPosition = false ; end else if Close < RectangleTop - .5 * RectangleRange then LongPosition = false ; end else if ShortPosition = true then begin if Close < ShortTarget then begin ShortTargetCount = ShortTargetCount + 1 ; ShortPosition = false ; end else if Close > RectangleBase + .5 * RectangleRange then ShortPosition = false ; end ; if LongPositionCount > 0 then begin LongTgtHitRatio = LongTargetCount / LongPositionCount ; Plot5( LongTgtHitRatio, “LongTgtRatio” ) ; end ; if ShortPositionCount > 0 then begin ShortTgtHitRatio = ShortTargetCount / ShortPositionCount ; Plot6( ShortTgtHitRatio, “ShrtTgtRatio” ) ; end ;