커뮤니티

문의드립니다.

프로필 이미지
잡다백수
2018-03-19 09:36:57
181
글번호 117493
답변완료
매번 감사합니다. 1. 기타 코딩 변환 부탁드립니다. using elsystem; using elsystem.collections ; using elsystem.drawingobjects ; using elsystem.drawing ; inputs: int Iterations( 3 ); variables: Vector BarData ( NULL ), // Bar DTP Vector Segments ( NULL ); // of Rounds of Pairs method void CreateTL ( DTPoint Begin_DTP, DTPoint End_DTP ) variables: TrendLine New_TL ; begin New_TL = TrendLine.Create( Begin_DTP, End_DTP ) ; New_TL.ExtLeft = false ; New_TL.ExtRight = false ; New_TL.Persist = true ; New_TL.Color = Color.Aquamarine ; DrawingObjects.Add( New_TL ) ; end ; method void LoadBarDataVector () begin if BarData <> NULL then BarData.Push_Back( DTPoint.Create( BarDateTime, Close ) astype DTPoint ) ; end ; method DTPoint BisectPairs ( Vector DTPPair ) variables: DTPoint BegDTP, DTPoint EndDTP, DTPoint MidDTP, int BarDataStartIndex, int BarDataEndIndex, int BarDataCnt, int HighDiffIndex, double HighDiff, int Count, double TL_Val ; begin HighDiffIndex = 0 ; HighDiff = -999999 ; BegDTP = DTPPair.Items[0] astype DTPoint ; EndDTP = DTPPair.Items[1] astype DTPoint ; for Count = 0 to BarData.Count - 1 begin if (BarData.Items[Count] astype DTPoint).DateTimeOfBar = BegDTP.DateTimeOfBar then BarDataStartIndex = Count ; if (BarData.Items[Count] astype DTPoint).DateTimeOfBar = EndDTP.DateTimeOfBar then BarDataEndIndex = Count ; end ; BarDataCnt = BarDataEndIndex - BarDataStartIndex ; if BarDataCnt = 0 then BarDataCnt +=1 ; for Count = BarDataStartIndex to BarDataEndIndex begin // Find TL Value TL_Val = (BarData.Items[BarDataStartIndex] astype DTPoint).Price astype double + (( BarData.Items[BarDataEndIndex] astype DTPoint). Price astype double - (BarData.Items[BarDataStartIndex] astype DTPoint). Price astype double ) * ( ( Count ) / BarDataCnt ) ; if AbsValue( TL_Val - (BarData.Items[Count] astype DTPoint). Price astype double ) > HighDiff then begin HighDiff = AbsValue( TL_Val - (BarData.Items[Count] astype DTPoint).Price astype double ) ; HighDiffIndex = Count ; end ; end ; MidDTP = BarData.Items[HighDiffIndex] astype DTPoint ; return MidDTP ; end; method void fndDiffBisect( ) variables: Vector RecursRound, Vector NewRound, Vector NewPairR, Vector NewPairL, int Count, bool OKToUse, DTPoint BegDTP, DTPoint EndDTP, DTPoint MidDTP ; begin NewRound = new Vector ; RecursRound = new Vector ; OKToUse = false ; RecursRound = segments.Items[Segments.Count -1] astype Vector ; for Count = 0 to RecursRound.Count -1 begin begin MidDTP = BisectPairs( RecursRound.Items[Count] astype Vector ) ; NewPairL = new Vector ; NewPairL.Push_Back( (RecursRound.Items[Count] astype Vector).Items[0] astype DTPoint ) ; NewPairL.Push_Back( MidDTP astype DTPoint ) ; NewRound.Push_Back( NewPairL astype Vector ) ; NewPairR = new Vector ; NewPairR.Push_Back( MidDTP astype DTPoint ) ; NewPairR.Push_Back( (RecursRound.Items[Count] astype Vector).Items[1] astype DTPoint ) ; NewRound.Push_Back( NewPairR astype Vector ) ; end ; end ; Segments.push_back( NewRound ) ; end ; method void SeedSegmentsVector() variables: Vector RecursRound, Vector Pair ; begin Pair = new Vector ; RecursRound = new Vector ; Pair.Push_Back( BarData.Items[0] astype DTPoint ) ; Pair.Push_Back( BarData.Items[BarData.Count -1] astype DTPoint ) ; RecursRound.Push_Back( Pair astype Vector ) ; Segments.Push_Back( RecursRound astype Vector ) ; end ; method void DrawAllTLs( ) variables: Vector RecursRound, Vector Pair, int Count ; begin Pair = new Vector ; RecursRound = new Vector ; RecursRound = Segments.Items[Segments.Count -1] astype vector ; Print( "TLStart" ) ; for Count = 0 to RecursRound.Count -1 begin Pair = RecursRound.Items[Count] astype Vector ; CreateTL( Pair.Items[0] astype DTPoint, Pair.Items[1] astype DTPoint ); end ; end ; once begin ClearPrintLog ; BarData = new Vector ; Segments = new Vector ; end ; if BarStatus( DataNum + 1 ) = 2 then LoadBarDataVector () ; once ( LastBarOnChartEx ) begin SeedSegmentsVector( ) ; For Value1 = 1 to Iterations begin fndDiffBisect( ) ; end ; DrawAllTLs( ) ; end ;
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2018-03-19 16:39:57

안녕하세요 예스스탁입니다. 올려주신 내용은 사용해본 경험이 없는 언어라 수식변경이 가능하지 않습니다. 즐거운 하루되세요 > 잡다백수 님이 쓴 글입니다. > 제목 : 문의드립니다. > 매번 감사합니다. 1. 기타 코딩 변환 부탁드립니다. using elsystem; using elsystem.collections ; using elsystem.drawingobjects ; using elsystem.drawing ; inputs: int Iterations( 3 ); variables: Vector BarData ( NULL ), // Bar DTP Vector Segments ( NULL ); // of Rounds of Pairs method void CreateTL ( DTPoint Begin_DTP, DTPoint End_DTP ) variables: TrendLine New_TL ; begin New_TL = TrendLine.Create( Begin_DTP, End_DTP ) ; New_TL.ExtLeft = false ; New_TL.ExtRight = false ; New_TL.Persist = true ; New_TL.Color = Color.Aquamarine ; DrawingObjects.Add( New_TL ) ; end ; method void LoadBarDataVector () begin if BarData <> NULL then BarData.Push_Back( DTPoint.Create( BarDateTime, Close ) astype DTPoint ) ; end ; method DTPoint BisectPairs ( Vector DTPPair ) variables: DTPoint BegDTP, DTPoint EndDTP, DTPoint MidDTP, int BarDataStartIndex, int BarDataEndIndex, int BarDataCnt, int HighDiffIndex, double HighDiff, int Count, double TL_Val ; begin HighDiffIndex = 0 ; HighDiff = -999999 ; BegDTP = DTPPair.Items[0] astype DTPoint ; EndDTP = DTPPair.Items[1] astype DTPoint ; for Count = 0 to BarData.Count - 1 begin if (BarData.Items[Count] astype DTPoint).DateTimeOfBar = BegDTP.DateTimeOfBar then BarDataStartIndex = Count ; if (BarData.Items[Count] astype DTPoint).DateTimeOfBar = EndDTP.DateTimeOfBar then BarDataEndIndex = Count ; end ; BarDataCnt = BarDataEndIndex - BarDataStartIndex ; if BarDataCnt = 0 then BarDataCnt +=1 ; for Count = BarDataStartIndex to BarDataEndIndex begin // Find TL Value TL_Val = (BarData.Items[BarDataStartIndex] astype DTPoint).Price astype double + (( BarData.Items[BarDataEndIndex] astype DTPoint). Price astype double - (BarData.Items[BarDataStartIndex] astype DTPoint). Price astype double ) * ( ( Count ) / BarDataCnt ) ; if AbsValue( TL_Val - (BarData.Items[Count] astype DTPoint). Price astype double ) > HighDiff then begin HighDiff = AbsValue( TL_Val - (BarData.Items[Count] astype DTPoint).Price astype double ) ; HighDiffIndex = Count ; end ; end ; MidDTP = BarData.Items[HighDiffIndex] astype DTPoint ; return MidDTP ; end; method void fndDiffBisect( ) variables: Vector RecursRound, Vector NewRound, Vector NewPairR, Vector NewPairL, int Count, bool OKToUse, DTPoint BegDTP, DTPoint EndDTP, DTPoint MidDTP ; begin NewRound = new Vector ; RecursRound = new Vector ; OKToUse = false ; RecursRound = segments.Items[Segments.Count -1] astype Vector ; for Count = 0 to RecursRound.Count -1 begin begin MidDTP = BisectPairs( RecursRound.Items[Count] astype Vector ) ; NewPairL = new Vector ; NewPairL.Push_Back( (RecursRound.Items[Count] astype Vector).Items[0] astype DTPoint ) ; NewPairL.Push_Back( MidDTP astype DTPoint ) ; NewRound.Push_Back( NewPairL astype Vector ) ; NewPairR = new Vector ; NewPairR.Push_Back( MidDTP astype DTPoint ) ; NewPairR.Push_Back( (RecursRound.Items[Count] astype Vector).Items[1] astype DTPoint ) ; NewRound.Push_Back( NewPairR astype Vector ) ; end ; end ; Segments.push_back( NewRound ) ; end ; method void SeedSegmentsVector() variables: Vector RecursRound, Vector Pair ; begin Pair = new Vector ; RecursRound = new Vector ; Pair.Push_Back( BarData.Items[0] astype DTPoint ) ; Pair.Push_Back( BarData.Items[BarData.Count -1] astype DTPoint ) ; RecursRound.Push_Back( Pair astype Vector ) ; Segments.Push_Back( RecursRound astype Vector ) ; end ; method void DrawAllTLs( ) variables: Vector RecursRound, Vector Pair, int Count ; begin Pair = new Vector ; RecursRound = new Vector ; RecursRound = Segments.Items[Segments.Count -1] astype vector ; Print( "TLStart" ) ; for Count = 0 to RecursRound.Count -1 begin Pair = RecursRound.Items[Count] astype Vector ; CreateTL( Pair.Items[0] astype DTPoint, Pair.Items[1] astype DTPoint ); end ; end ; once begin ClearPrintLog ; BarData = new Vector ; Segments = new Vector ; end ; if BarStatus( DataNum + 1 ) = 2 then LoadBarDataVector () ; once ( LastBarOnChartEx ) begin SeedSegmentsVector( ) ; For Value1 = 1 to Iterations begin fndDiffBisect( ) ; end ; DrawAllTLs( ) ; end ;