- This topic has 25 ข้อความตอบกลับ, 9 เสียง, and was last updated 5 years, 1 month มาแล้ว by .
-
กระทู้
-
จาก code ที่ทดลองเขียนเพื่อหา EPS แบบ QoQ และ YoY
โดย code ข้างต้นยอมให้ข้อมูลแต่ละ quater คลาดเคลื่อนได้ไม่เกิน 2%
พบว่ายังมีปัญหา spike อยู่ เนื่องจากข้อมูลมี error มากกว่า 2%
จึงทำการแก้ไข code ให้ใหม่***โดย code ใหม่นี้ จะใช้งานได้ดีเพียงใดขึ้นอยู่กับ
1. ข้อมูล quarter(SQQE) ต้องไม่คลาดเคลื่อน
2. เวลาบันทึกข้อมูล SQQE กับ SQEPS ต้องตรงกัน เช่น
ถ้ามีการเปลี่ยนจาก Q1 เป็น Q2 ต้องมีการเปลี่ยนข้อมูล
SQEPS จาก Q1 เป็น Q2 ภายในวันเดียวกันด้วยเช่นกัน
3. ข้อมูลวันแรกของแต่ละ quarter ต้องมีค่าที่ถูกต้องซึ่งจากการทำสอบเบื้องต้นก็ใช้งานได้ดีพอสมควร
จึงขอนำมาแปะไว้ เผื่อท่านอื่นที่สนใจจะได้นำไปใช้ต่อไป….// Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee Ppppppppppppppppppppppppppppppppppppppppp Sssssssssssssssssssssssssssssssssssssssssssss //
#include_once “C:\SiamQuant\SQ Library\SQ AFL V.1.0.2.0\SQ Include\SQ – Include Data Declaration.afl”
#include_once “C:\SiamQuant\SQ Library\SQ AFL V.1.0.2.0\SQ Include\SQ – Include Data Restriction.afl”// Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee Ppppppppppppppppppppppppppppppppppppppppp Sssssssssssssssssssssssssssssssssssssssssssss //
for( i = 0; i < BarCount; i++ )
{
if( i > 0 )
{
if( SQQE[ i ] == 1 AND SQQE[ i – 1 ] == 4 ) epsQ1[ i ] = SQEPS[ i ];
else epsQ1[ i ] = epsQ1[ i – 1 ];if( SQQE[ i ] == 2 AND SQQE[ i – 1 ] == 1 ) epsQ2[ i ] = SQEPS[ i ] – SQEPS[ i – 1 ] ;
else epsQ2[ i ] = epsQ2[ i – 1 ];if( SQQE[ i ] == 3 AND SQQE[ i – 1 ] == 2 ) epsQ3[ i ] = SQEPS[ i ] – SQEPS[ i – 1 ] ;
else epsQ3[ i ] = epsQ3[ i – 1 ];if( SQQE[ i ] == 4 AND SQQE[ i – 1 ] == 3 ) epsQ4[ i ] = SQEPS[ i ] – SQEPS[ i – 1 ] ;
else epsQ4[ i ] = epsQ4[ i – 1 ];if( SQQE[ i ] == 1 ) epsQ[ i ] = epsQ1[ i ];
if( SQQE[ i ] == 2 ) epsQ[ i ] = epsQ2[ i ];
if( SQQE[ i ] == 3 ) epsQ[ i ] = epsQ3[ i ];
if( SQQE[ i ] == 4 ) epsQ[ i ] = epsQ4[ i ];}
else
{
epsQ1[ i ] = epsQ2[ i ] = epsQ3[ i ] = epsQ4[ i ] = epsQ[ i ] = Null;
}
}eps_ROLL = epsQ1 + epsQ2 + epsQ3 + epsQ4;
eps_ACC = SQEPS;
eps_ANN = ValueWhen( SQQE == 4 AND ( epsQ != Ref( epsQ, -1 ) ), SQEPS );
eps_QoQ = ValueWhen( epsQ != Ref( epsQ, -1 ), ROC( epsQ, 1, True ) );
eps_Q1YoY = ValueWhen( epsQ1 != Ref( epsQ1, -1 ), ROC( epsQ1, 1, True ) );
eps_Q2YoY = ValueWhen( epsQ2 != Ref( epsQ2, -1 ), ROC( epsQ2, 1, True ) );
eps_Q3YoY = ValueWhen( epsQ3 != Ref( epsQ3, -1 ), ROC( epsQ3, 1, True ) );
eps_Q4YoY = ValueWhen( epsQ4 != Ref( epsQ4, -1 ), ROC( epsQ4, 1, True ) );for( i = 0; i < BarCount; i++ ) //Year on Year
{
if( i > 0 )
{
if( eps_Q1YoY[ i ] != eps_Q1YoY[ i – 1 ] ) eps_YoY[ i ] = eps_Q1YoY[ i ];
else
{
if( eps_Q2YoY[ i ] != eps_Q2YoY[ i – 1 ] ) eps_YoY[ i ] = eps_Q2YoY[ i ];
else
{
if( eps_Q3YoY[ i ] != eps_Q3YoY[ i – 1 ] ) eps_YoY[ i ] = eps_Q3YoY[ i ];
else
{
if( eps_Q4YoY[ i ] != eps_Q4YoY[ i – 1 ] ) eps_YoY[ i ] = eps_Q4YoY[ i ];
else eps_YoY[ i ] = eps_YoY[ i – 1 ];
}
}
}
}
else eps_YoY[ i ] = Null;
}_SECTION_BEGIN( “quaterlyEPS” );
ShowEpsQ = ParamToggle( “showquaterlyEPS”, “-|Show”, 1 );
ColorEpsQ = ParamColor( “colorEpsQuarter”, colorRed );
StyleEpsQ = ParamStyle( “styleEpsQuarter”, styleLine, maskAll );
_SECTION_END();_SECTION_BEGIN( “Eps_ROLL” );
ShowEps_ROLL = ParamToggle( “showEps_ROLL”, “-|Show”, 0 );
ColorEps_ROLL = ParamColor( “colorEps_ROLL”, colorViolet );
StyleEps_ROLL = ParamStyle( “styleEps_ROLL”, styleLine, maskAll );
_SECTION_END();_SECTION_BEGIN( “Eps_ANN” );
ShowEps_ANN = ParamToggle( “showEps_ANN”, “-|Show”, 0 );
ColorEps_ANN = ParamColor( “colorEps_ANN”, colorGreen );
StyleEps_ANN = ParamStyle( “styleEps_ANN “, styleLine, maskAll );
_SECTION_END();_SECTION_BEGIN( “Eps_QoQ” );
ShowEps_QoQ = ParamToggle( “showEps_QoQ”, “-|Show”, 0 );
ColorEps_QoQ = ParamColor( “colorEps_QoQ”, colorBlue );
StyleEps_QoQ = ParamStyle( “styleEps_QoQ “, styleDashed, maskAll );
_SECTION_END();_SECTION_BEGIN( “Eps_YoY” );
ShowEps_YoY = ParamToggle( “showEps_YoY”, “-|Show”, 0 );
ColorEps_YoY = ParamColor( “colorEps_YoY”, colorCustom12 );
StyleEps_YoY = ParamStyle( “styleEps_YoY “, styleDashed, maskAll );
_SECTION_END();if( ShowEpsQ ) Plot( epsQ, “QuarterlyEPS (Baht)”, ColorEpsQ, StyleEpsQ );
if( ShowEps_ROLL ) Plot( eps_ROLL, “Eps_ROLL (Baht)”, ColorEps_ROLL, StyleEps_ROLL );
if( ShowEps_ANN ) Plot( eps_ANN, “Eps_ANN (Baht)”, ColorEps_ANN, StyleEps_ANN );
if( ShowEps_QoQ ) Plot( eps_QoQ, “Eps_QoQ (%)”, ColorEps_QoQ, StyleEps_QoQ | styleOwnScale);
if( ShowEps_YoY ) Plot( eps_YoY, “Eps_YoY (%)”, ColorEps_YoY, StyleEps_YoY | styleOwnScale);Title = EncodeColor( colorBlue ) + Name() + ” – ” + Interval( 2 ) + ” ” + Date() + StrFormat( ” \\c16|| ” )
+ “{{VALUES}}”;GraphXSpace = 10;
// Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee Nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn Dddddddddddddddddddddddddddddddddd //
- คุณต้องเข้าสู่ระบบเพื่อตอบกลับกระทู้นี้