## MetaStock Formula for Turtle Trading System

Turtle trading is a most famous trading system; I wrote a series of articles to provide the basic concepts of turtle trading system. In this article, I will give you a few examples on how to apply the turtle systems in your trading by using MetaStock.

One of the most commonly used tools for MetaStock is The Explorer, with this tool traders can filter out securities that do not match any given criteria. The criteria can be defined by writing MetaStock formula as the following example.

According to the turtle trading system, the shorter term entry system based on a 20-days breakout. Traders can easily write a formula for daily charts as follow.

H > Ref(HHV(H, 20), -1) OR L < Ref(LLV(L, 20), -1);

H = Today’s high; L = Today’s low
HHV(H, 20) = Highest value that the high price (H) has reached in the last 20 days.
LLV(L, 20) = Lowest value that the low price (L) has reached in the last 20 days.
Ref(HHV(H, 20), -1) = The highest high price in the last 20 days refer to yesterday.
Ref(LLV(L, 20), -1) = The lowest low price in the last 20 days refer to yesterday.

If traders want a list of securities that match the turtle exit system, 10-days low for long positions and 10-days high for short positions. The formula will be as follow.

L < Ref(LLV(L, 10), -1) OR H > Ref(HHV(H, 10), -1);

These are examples of how to apply trading systems by using MetaStock formula. Besides The Explorer, traders can also write the formula in other tools such as Expert Advisor or Indicator Builder as well.