커뮤니티
ts식을 예스랭귀지로 변환 부탁해요
2009-07-07 13:32:37
785
글번호 23294
Input: FastMA(9),SlowMA(26),MacdMA(4), NCOs(4), NBars(50), Trailbar(6);
Vars: MVal(0), MAvg(0), MDif(0), Counter(0), TotalBars(0), HighestHi(0), LowestLo(0);
Array: CO[2,50](0);
MVal = MACD(Close,FastMA,SlowMA);
MAvg = XAverage(MACD(Close,FastMA,SlowMA),MacdMA);
MDif = MVal - MAvg;
{ Store the MACD Cross information in the CO array }
If MDif Crosses Over 0 OR MDIF Crosses Under 0 Then Begin
For counter = 0 to 49 Begin
CO[ 0 , 50 - Counter ] = CO[ 0 , 49 - Counter ];
CO[ 1 , 50 - Counter ] = CO[ 1 , 49 - Counter ];
CO[ 2 , 50 - Counter ] = CO[ 2 , 49 - Counter ];
End;
CO[ 0 , 0 ] = BarNumber;
CO[ 1, 0 ] = High;
CO[ 2, 0 ] = Low;
End;
{ Find the Highest High and the Lowest Low of the cross over and under bars }
HighestHi = -1;
LowestLo = 9999;
For counter = 0 to NCOs-1 Begin
If CO[ 1 , counter ] > HighestHi then
HighestHi = CO[ 1 , counter ];
If CO[ 2 , counter ] < LowestLo then
LowestLo = CO[ 2 , counter ];
End;
{ If the last N crosses occured in the last 50 bars, then place the buy and sell orders }
Totalbars = BarNumber - CO[ 0 , NCOs - 1];
If TotalBars < NBars then Begin
Buy at HighestHi + Average(TrueRange,4)*.5 stop;
Sell at LowestLo - Average(TrueRange,4)*.5 stop;
End;
{ Trailing stop orders }
ExitLong next bar at Lowest( Low , TrailBar ) Stop;
ExitShort next bar at Highest( High , TrailBar ) Stop;
답변 1
예스스탁 예스스탁 답변
2009-07-07 18:46:29
안녕하세요
예스스탁입니다.
Input: FastMA(9),SlowMA(26),MacdMA(4), NCOs(4), NBars(50), Trailbar(6);
Vars: MVal(0), MAvg(0), MDif(0), Counter(0), TotalBars(0), HighestHi(0), LowestLo(0);
Array: CO[2,50](0);
MVal = MACD(FastMA,SlowMA);
MAvg = Ema(MACD(FastMA,SlowMA),MacdMA);
MDif = MVal - MAvg;
#{ Store the MACD Cross information in the CO array }
If crossup(MDif, 0) OR CrossDown(MDIF, 0) Then Begin
For counter = 0 to 49 Begin
CO[ 0 , 50 - Counter ] = CO[ 0 , 49 - Counter ];
CO[ 1 , 50 - Counter ] = CO[ 1 , 49 - Counter ];
CO[ 2 , 50 - Counter ] = CO[ 2 , 49 - Counter ];
End;
CO[ 0 , 0 ] = index;
CO[ 1, 0 ] = High;
CO[ 2, 0 ] = Low;
End;
#{ Find the Highest High and the Lowest Low of the cross over and under bars }
HighestHi = -1;
LowestLo = 999999999;
For counter = 0 to NCOs-1 Begin
If CO[ 1 , counter ] > HighestHi then
HighestHi = CO[ 1 , counter ];
If CO[ 2 , counter ] < LowestLo then
LowestLo = CO[ 2 , counter ];
End;
#{ If the last N crosses occured in the last 50 bars, then place the buy and sell orders }
Totalbars = index - CO[ 0 , NCOs - 1];
If TotalBars < NBars then Begin
Buy("B",AtStop,HighestHi + Average(TrueRange,4)*0.5);
Sell("S",AtStop,LowestLo - Average(TrueRange,4)*0.5);
End;
#{ Trailing stop orders }
ExitLong("LX",AtStop,Lowest( Low , TrailBar ));
ExitShort("SX",AtStop,Highest( High , TrailBar ));
즐거운 하루되세요
> 날으는여우 님이 쓴 글입니다.
> 제목 : ts식을 예스랭귀지로 변환 부탁해요
> Input: FastMA(9),SlowMA(26),MacdMA(4), NCOs(4), NBars(50), Trailbar(6);
Vars: MVal(0), MAvg(0), MDif(0), Counter(0), TotalBars(0), HighestHi(0), LowestLo(0);
Array: CO[2,50](0);
MVal = MACD(Close,FastMA,SlowMA);
MAvg = XAverage(MACD(Close,FastMA,SlowMA),MacdMA);
MDif = MVal - MAvg;
{ Store the MACD Cross information in the CO array }
If MDif Crosses Over 0 OR MDIF Crosses Under 0 Then Begin
For counter = 0 to 49 Begin
CO[ 0 , 50 - Counter ] = CO[ 0 , 49 - Counter ];
CO[ 1 , 50 - Counter ] = CO[ 1 , 49 - Counter ];
CO[ 2 , 50 - Counter ] = CO[ 2 , 49 - Counter ];
End;
CO[ 0 , 0 ] = BarNumber;
CO[ 1, 0 ] = High;
CO[ 2, 0 ] = Low;
End;
{ Find the Highest High and the Lowest Low of the cross over and under bars }
HighestHi = -1;
LowestLo = 9999;
For counter = 0 to NCOs-1 Begin
If CO[ 1 , counter ] > HighestHi then
HighestHi = CO[ 1 , counter ];
If CO[ 2 , counter ] < LowestLo then
LowestLo = CO[ 2 , counter ];
End;
{ If the last N crosses occured in the last 50 bars, then place the buy and sell orders }
Totalbars = BarNumber - CO[ 0 , NCOs - 1];
If TotalBars < NBars then Begin
Buy at HighestHi + Average(TrueRange,4)*.5 stop;
Sell at LowestLo - Average(TrueRange,4)*.5 stop;
End;
{ Trailing stop orders }
ExitLong next bar at Lowest( Low , TrailBar ) Stop;
ExitShort next bar at Highest( High , TrailBar ) Stop;
다음글
이전글