Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

test moving average Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
stockscience
Posted : Friday, March 9, 2018 12:02:16 PM
Registered User
Joined: 6/26/2011
Posts: 128

I am interested in a pcf for testing moving averages by computing

the net gain loss (over 500 periods) of a system that buys when the heiken ashi open is above the moving average

and selling when heiken ashi open is below the moving average.

Bruce_L
Posted : Friday, March 9, 2018 12:34:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

TC2000 does not have any built in backtesting features and I do not know of any way to write such a formula.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
stockscience
Posted : Friday, March 9, 2018 12:39:23 PM
Registered User
Joined: 6/26/2011
Posts: 128

Thank you.

stockscience
Posted : Friday, March 9, 2018 1:00:53 PM
Registered User
Joined: 6/26/2011
Posts: 128

Oh. I am wondering if it may be possible to get it by computing the average

buying prices versus the  average selling prices.

Bruce_L
Posted : Friday, March 9, 2018 1:08:23 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

What is the period and average type of the moving average? Is that moving average applied to the HA Open, the HA Close or something else?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
stockscience
Posted : Friday, March 9, 2018 1:12:42 PM
Registered User
Joined: 6/26/2011
Posts: 128

For example, it would be avgc10, where c is normal (not HA) close.

Bruce_L
Posted : Friday, March 9, 2018 1:52:07 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

The moving average crossing up through the HA open.

SUM(IIF(XUP(AVGC10, (XAVGO3.1 + XAVGH3.1 + XAVGL3.1 + XAVGC3.1) / 4), C, 0), 489) / CountTrue(XUP(AVGC10, (XAVGO3.1 + XAVGH3.1 + XAVGL3.1 + XAVGC3.1) / 4), 489)

The moving average crossing down through the HA open.

SUM(IIF(XDOWN(AVGC10, (XAVGO3.1 + XAVGH3.1 + XAVGL3.1 + XAVGC3.1) / 4), C, 0), 489) / CountTrue(XDOWN(AVGC10, (XAVGO3.1 + XAVGH3.1 + XAVGL3.1 + XAVGC3.1) / 4), 489)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
stockscience
Posted : Friday, March 9, 2018 2:07:18 PM
Registered User
Joined: 6/26/2011
Posts: 128

Thank you.  I am only interested in comparing to the value of

the moving average at the beginning of the period (i.e C.0=O.0)  - it seems that the above

may occur intraperiod(?).

Bruce_L
Posted : Friday, March 9, 2018 2:16:41 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

No, it is only testing at the crossups and crossdowns. Why do you think otherwise?

If you change all instances of 489 to something lower (that matches) you can see the points at which the averages change.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
stockscience
Posted : Friday, March 9, 2018 3:06:25 PM
Registered User
Joined: 6/26/2011
Posts: 128

The formula looks correct. But it is updating more often than I expected (count increasing).

How can I send you an example? 

Bruce_L
Posted : Friday, March 9, 2018 3:18:45 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Keep in mind if you change the period to something lower, the value will change both when a new price gets added and when an older price that is no longer in the period gets dropped.

Please send it to my attention at:

support@tc2000.com



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
stockscience
Posted : Friday, March 9, 2018 4:09:12 PM
Registered User
Joined: 6/26/2011
Posts: 128

Thank you. Actually it looks good now...  There were simply more crossovers than

I had expected to see. But a minor problem occurs when there is a tie between the ha open

and moving average.  I would only want  to count  such ties as having the previous sign.

(otherwise a bounce produces a buy and sell - but one certainly can live with that).

Bruce_L
Posted : Friday, March 9, 2018 4:40:12 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Well the numbers probably aren't actually tied in the literal sense if you take it out to enough digits.

Not sure if we would want to try to figure out a way to count stuff that is just close as a "tie". We would need to add a lookback of some sort to see which side the tie should be on and make sure it actually does count the cross it eventually "unties". That would reduce the number of bars we could check.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.