Registered User Joined: 11/30/2004 Posts: 33
|
Can I write a pcf in TC for Stoc exp (use any parameter)where SK period is crossing SD period?
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
ehop, One way to write crossover formulas for an Exponential Stochastic where the SK Period <> SD Period would be:
SK xUp SD:
XAVG(STOCx,y) > XAVG(STOCx,z) AND XAVG(STOCx.1.1,y) <= XAVG(STOCx.1.1,z)
SK xDown SD:
XAVG(STOCx,y) < XAVG(STOCx,z) AND XAVG(STOCx.1.1,y) >= XAVG(STOCx.1.1,z)
SK crossing SD (either direction):
SGN(XAVG(STOCx,y) - XAVG(STOCx,z)) <> SGN(XAVG(STOCx.1.1,y) - XAVG(STOCx.1.1,z))
Where:
x = Stochastic Period y = MIN(SK Period, SD Period) z = MAX(SK Period, SD Period)
For example, the following formulas:
SK xUp SD:
XAVG(STOC30,10) > XAVG(STOC30,20) AND XAVG(STOC30.1.1,10) <= XAVG(STOC30.1.1,20)
SK xDown SD:
XAVG(STOC30,10) < XAVG(STOC30,20) AND XAVG(STOC30.1.1,10) >= XAVG(STOC30.1.1,20)
SK crossing SD (either direction):
SGN(XAVG(STOC30,10) - XAVG(STOC30,20)) <> SGN(XAVG(STOC30.1.1,10) - XAVG(STOC30.1.1,20))
Would be correct for both Exponential Stochastic 30,20,10 and Exponential Stochastic 30,10,20.
If the SK Period = SD Period, you will need to expand at least one of the Exponential Moving Average Periods because the XAVG() function cannot be nested in TeleChart's Personal Criteria Formula Language. To give an example, the following is one way to write crossover formulas for an Exponential Stochastic 12,3,3:
SK xUp SD:
XAVG(STOC12,3) > .500488758553275 * (XAVG(STOC12,3) + .5 * (XAVG(STOC12.1.1,3) + .5 * (XAVG(STOC12.1.2,3) + .5 * (XAVG(STOC12.1.3,3) + .5 * (XAVG(STOC12.1.4,3) + .5 * (XAVG(STOC12.1.5,3) + .5 * (XAVG(STOC12.1.6,3) + .5 * (XAVG(STOC12.1.7,3) + .5 * (XAVG(STOC12.1.8,3) + .5 * (XAVG(STOC12.1.9,3))))))))))) AND XAVG(STOC12.1.1,3) <= .500488758553275 * (XAVG(STOC12.1.1,3) + .5 * (XAVG(STOC12.1.2,3) + .5 * (XAVG(STOC12.1.3,3) + .5 * (XAVG(STOC12.1.4,3) + .5 * (XAVG(STOC12.1.5,3) + .5 * (XAVG(STOC12.1.6,3) + .5 * (XAVG(STOC12.1.7,3) + .5 * (XAVG(STOC12.1.8,3) + .5 * (XAVG(STOC12.1.9,3) + .5 * (XAVG(STOC12.1.10,3)))))))))))
SK xDown SD:
XAVG(STOC12,3) < .500488758553275 * (XAVG(STOC12,3) + .5 * (XAVG(STOC12.1.1,3) + .5 * (XAVG(STOC12.1.2,3) + .5 * (XAVG(STOC12.1.3,3) + .5 * (XAVG(STOC12.1.4,3) + .5 * (XAVG(STOC12.1.5,3) + .5 * (XAVG(STOC12.1.6,3) + .5 * (XAVG(STOC12.1.7,3) + .5 * (XAVG(STOC12.1.8,3) + .5 * (XAVG(STOC12.1.9,3))))))))))) AND XAVG(STOC12.1.1,3) >= .500488758553275 * (XAVG(STOC12.1.1,3) + .5 * (XAVG(STOC12.1.2,3) + .5 * (XAVG(STOC12.1.3,3) + .5 * (XAVG(STOC12.1.4,3) + .5 * (XAVG(STOC12.1.5,3) + .5 * (XAVG(STOC12.1.6,3) + .5 * (XAVG(STOC12.1.7,3) + .5 * (XAVG(STOC12.1.8,3) + .5 * (XAVG(STOC12.1.9,3) + .5 * (XAVG(STOC12.1.10,3)))))))))))
SK crossing SD (either direction):
SGN(XAVG(STOC12,3) - .500488758553275 * (XAVG(STOC12,3) + .5 * (XAVG(STOC12.1.1,3) + .5 * (XAVG(STOC12.1.2,3) + .5 * (XAVG(STOC12.1.3,3) + .5 * (XAVG(STOC12.1.4,3) + .5 * (XAVG(STOC12.1.5,3) + .5 * (XAVG(STOC12.1.6,3) + .5 * (XAVG(STOC12.1.7,3) + .5 * (XAVG(STOC12.1.8,3) + .5 * (XAVG(STOC12.1.9,3)))))))))))) <> SGN(XAVG(STOC12.1.1,3) >= .500488758553275 * (XAVG(STOC12.1.1,3) + .5 * (XAVG(STOC12.1.2,3) + .5 * (XAVG(STOC12.1.3,3) + .5 * (XAVG(STOC12.1.4,3) + .5 * (XAVG(STOC12.1.5,3) + .5 * (XAVG(STOC12.1.6,3) + .5 * (XAVG(STOC12.1.7,3) + .5 * (XAVG(STOC12.1.8,3) + .5 * (XAVG(STOC12.1.9,3) + .5 * (XAVG(STOC12.1.10,3))))))))))))
You may wish to review the following:
How to create a Personal Criteria Forumula (PCF) Understanding Stochastics Cascades of Moving Averages Handy PCF example formulas to help you learn the syntax of PCFs! PCF Formula Descriptions
-Bruce Personal Criteria Formulas TC2000 Support Articles
|