Author

Topic: “Turtle Trading strategy” implementations (Read 577 times)

legendary
Activity: 1554
Merit: 1054
January 08, 2019, 12:47:02 PM
#34
I think liquidity plays an important part in that question. If you have a good amount of capital than having two break positions would be more beneficial in case of double dipping on the trend however if your capital is too small to make a difference than one break would be enough. I know not many people with just couple hundred dollars care about donchian however if that is the case (which is rare but could happen) those people should be strictly one break and it would be enough.

Moreover, when companies with billions of dollars to invest do this they probably do double even triple break points just in case. You need to ask yourself what is the amount of risk you are willing to take, if you are willing to risk all at once than you can go all in, more than likely it will be fine however if you want less risk and less reward double would be better.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
   2. When to open a position
The action of opening a position comes from the generation of a trend breakthrough signal. If the current price breaks through the upper track, it will generate a buy position signal.

I tried using Donchian channel once, but it somehow gave a me lot of false signals so I gave up. I may revisit it in the future, as it showed some promise. It seemed to me that it could be especially good for trend following, which I think this system does very well. A question: How about waiting for 2 consecutive breaks through the upper track? Is such a signal more trustworthy than using just one break through the upper Donchian line?
 

great advise, this strategy is just a framework, in real market enviroment, i think there are still lot of parameter need to be modify.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
4. How to do dynamic stop loss

If the holding position is long positions and the price of the asset falls by 2N based on the last holding position (or adding position), then stop loss for all positions;

If the holding position is short position and the price of the asset has increased by 2N based on the last holding position (or adding position), then the entire position must be closed.

Of course, the user can customize the dynamic stop loss plan, such as a 0.5N drop to start partial closing position, instead of waiting for a 2N decline after a rush to close the position; after all, the impact cost is there.
if my crypto exchange does not have a stop loss function. What should I do then?


almost most of them have the API interface, which means you can connect it through certain programming skills, check this website, fmz.com   it all done the job for you , you just need some programming skills to code your trading ideas if you are interested.
member
Activity: 392
Merit: 66
if my crypto exchange does not have a stop loss function. What should I do then?

There is not much you can do but change the exchange. (Or stay by your computer all the time monitoring the price, which is pretty cumbersome if you ask me) No serious trader would trade without a stop loss. In my opinion trading without a stop loss is a recipe for disaster. The major part of my personal loses originate from the time I didn't care about stop losses, so I didn't use them. Now I regret that deeply.
full member
Activity: 284
Merit: 101
Bounty Manager https://t.me/voki_bounty
4. How to do dynamic stop loss

If the holding position is long positions and the price of the asset falls by 2N based on the last holding position (or adding position), then stop loss for all positions;

If the holding position is short position and the price of the asset has increased by 2N based on the last holding position (or adding position), then the entire position must be closed.

Of course, the user can customize the dynamic stop loss plan, such as a 0.5N drop to start partial closing position, instead of waiting for a 2N decline after a rush to close the position; after all, the impact cost is there.
if my crypto exchange does not have a stop loss function. What should I do then?
member
Activity: 392
Merit: 66
   2. When to open a position
The action of opening a position comes from the generation of a trend breakthrough signal. If the current price breaks through the upper track, it will generate a buy position signal.

I tried using Donchian channel once, but it somehow gave a me lot of false signals so I gave up. I may revisit it in the future, as it showed some promise. It seemed to me that it could be especially good for trend following, which I think this system does very well. A question: How about waiting for 2 consecutive breaks through the upper track? Is such a signal more trustworthy than using just one break through the upper Donchian line?
 
newbie
Activity: 14
Merit: 0
great communication here.
Learn and think a lot.
Posts like this from newbie trader should be not overlooked.
legendary
Activity: 3514
Merit: 1280
English ⬄ Russian Translation Services
In my experience, generally speaking, the simpler the system, the more robust it is. Beginning traders make the mistake of trying to develop a system that is rarely wrong. There is no Holy Grail of systems.
The Holy Grail of trading is inside of you, in terms of knowing yourself and your emotional weakness, and working to trade in a way to minimize harm from your weaknesses

Agree with every word said

From my experience, the best strategy long term wise is simply following the trend, i.e. when the price goes up, you buy in, when it starts to slide down you sell out (using stop-losses or otherwise). If you look at historical data, you will see that this strategy would always bring you profits in the long run, even if it could sometimes bring you small losses when you would have to get out from a losing position. And as you get the hang of it, you can proceed to tweak it so as to squeeze more profits from every price movement but not until then
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
I just read this and to be sincere, this is the first time I’m seeing anything called Turtle Strategy. But I’m not really understanding this strategy so I’ will just bookmark this page and come back later to read it and see if I can understand how it works. Already have a strategy, if this seems better, might try it out later. Thanks for sharing.

no problem, glad you like it!
full member
Activity: 491
Merit: 105
I just read this and to be sincere, this is the first time I’m seeing anything called Turtle Strategy. But I’m not really understanding this strategy so I’ will just bookmark this page and come back later to read it and see if I can understand how it works. Already have a strategy, if this seems better, might try it out later. Thanks for sharing.
copper member
Activity: 322
Merit: 15
You can also look into the sort of counter trading this turtle strategy called "turtle soup".
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
It's too complicated for me because I don't learn to trade too deep. So far, I only use a simple strategy which is buying low and sell high, and it's working for me. I will learn the other strategy, but I realize it will need more time to master and now, I don't have much time to learn many things, so I stick with my strategy. At least, that strategy can give me a profit, but I am sure that there are people who can learn more from that Turtle Trading Strategy.


good for you , any method, making profit is the only standard, only truth about trading.
I will suggest you backing up this turtle trading strategy with a chart illustrations if possible this will enable newbie traders to fully grasp and understand the strategy better and encourage interested traders to demo trade and ascertain its workability and verify it here kudos to you for taking your time on this strategy.

thanks a lot , will do that
sr. member
Activity: 2842
Merit: 326
Vave.com - Crypto Casino
It's too complicated for me because I don't learn to trade too deep. So far, I only use a simple strategy which is buying low and sell high, and it's working for me. I will learn the other strategy, but I realize it will need more time to master and now, I don't have much time to learn many things, so I stick with my strategy. At least, that strategy can give me a profit, but I am sure that there are people who can learn more from that Turtle Trading Strategy.


good for you , any method, making profit is the only standard, only truth about trading.
I will suggest you backing up this turtle trading strategy with a chart illustrations if possible this will enable newbie traders to fully grasp and understand the strategy better and encourage interested traders to demo trade and ascertain its workability and verify it here kudos to you for taking your time on this strategy.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
It's too complicated for me because I don't learn to trade too deep. So far, I only use a simple strategy which is buying low and sell high, and it's working for me. I will learn the other strategy, but I realize it will need more time to master and now, I don't have much time to learn many things, so I stick with my strategy. At least, that strategy can give me a profit, but I am sure that there are people who can learn more from that Turtle Trading Strategy.


good for you , any method, making profit is the only standard, only truth about trading.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
I used to hear this strategy when trading forex, the turtle strategy includes a well-known strategy in forex, but I never applied that strategy, can you include images so that I can easily understand it,


https://www.fmz.com/strategy/132298

check here, more info you may interested.

I visited the site, I once used an indicator like that, seems to have to combine it with other indicators, I think you will be stuck with a false signal if you only use that indicator..  Smiley


it's a platform you write your own trading strategy by some easy programming languages, if that situation happened, it must bacause the programming writing part is bad. the main purpose of the platform is for traders to write their own trading bot, also some finished and tested trading bot for them to choose.
sr. member
Activity: 812
Merit: 257
I used to hear this strategy when trading forex, the turtle strategy includes a well-known strategy in forex, but I never applied that strategy, can you include images so that I can easily understand it,


https://www.fmz.com/strategy/132298

check here, more info you may interested.

I visited the site, I once used an indicator like that, seems to have to combine it with other indicators, I think you will be stuck with a false signal if you only use that indicator..  Smiley
hero member
Activity: 2912
Merit: 541
Leading Crypto Sports Betting & Casino Platform
It's too complicated for me because I don't learn to trade too deep. So far, I only use a simple strategy which is buying low and sell high, and it's working for me. I will learn the other strategy, but I realize it will need more time to master and now, I don't have much time to learn many things, so I stick with my strategy. At least, that strategy can give me a profit, but I am sure that there are people who can learn more from that Turtle Trading Strategy.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
I used to hear this strategy when trading forex, the turtle strategy includes a well-known strategy in forex, but I never applied that strategy, can you include images so that I can easily understand it,


https://www.fmz.com/strategy/132298

check here, more info you may interested.
sr. member
Activity: 812
Merit: 257
I used to hear this strategy when trading forex, the turtle strategy includes a well-known strategy in forex, but I never applied that strategy, can you include images so that I can easily understand it,
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
In my experience, generally speaking, the simpler the system, the more robust it is. Beginning traders make the mistake of trying to develop a system that is rarely wrong. There is no Holy Grail of systems.
The Holy Grail of trading is inside of you, in terms of knowing yourself and your emotional weakness, and working to trade in a way to minimize harm from your weaknesses.

You can knock yourself out trying to create a system that is rarely wrong....you start with perhaps a pair of moving averages, then when it shows some promise but is wrong a few times in a row, you add some other indicator...then another and another. The result is, at best a system that has been "curve-fitted" to your test data and is not robust in real trading. The other effect is that your new super 5 layer indicator system
filters out too many trades.

Here's what I mean: Every trader using a mechanical system, which is what the "turtles" used, should know his/her system's "expectancy". If I have 100 trades, 60 of them profitable with an avg profit of
$20...and 40 losing trades with an average loss of $18, my expectancy is (.60 * 20) - (.40 * 18) = $4.80 / trade. The beginner mistake is to add layers of filters to the system to try to raise the expectancy
higher. In doing so, if they succeed it usually results in fewer trades, so even though each trade is more profitable than before the system was modified, they make less money because their new trade selection
parameters are stricter and gives fewer trades.

Example: I have system A detailed above: Expectancy of $4.80 / trade and with those selection parameters I get 100 trades/year....so I make $480

I then tweak system A and manage to raise its expectancy to $7.00 / trade. This new system (B) with stricter selection rules to filter out more losers only
generates 60 trades a year. Even though each trade makes more $, it only makes $420 in the same amount of time that system A made $480

Accept that losing is part of profitable trading. Casino's dont mind losing b/c they know that time is on their side. All they want is more chances to let their
statistical edge work for them and eventually/inevitably make them profitable.

As for what time frames to trade....day trade, swing trade, trend trade...that's where knowing yourself and your risk tolerance and ability to sit tight on a trade is critical. If you find a system that works on a daily chart using a 20 day indicator...but you know you are more risk averse and want a shorter horizon, test the system using the same number of chart bars(20 for the daily example that
I just mentioned) using 20 bars of an hourly/30 min/15 min/5 minute chart as a starting point for your testing.


great point! i totally agree!      traders must have a plan, no matter what kind of trading method. take the risk you can bear, take the risk you can manage. everything else just let it happen.
newbie
Activity: 18
Merit: 7
In my experience, generally speaking, the simpler the system, the more robust it is. Beginning traders make the mistake of trying to develop a system that is rarely wrong. There is no Holy Grail of systems.
The Holy Grail of trading is inside of you, in terms of knowing yourself and your emotional weakness, and working to trade in a way to minimize harm from your weaknesses.

You can knock yourself out trying to create a system that is rarely wrong....you start with perhaps a pair of moving averages, then when it shows some promise but is wrong a few times in a row, you add some other indicator...then another and another. The result is, at best a system that has been "curve-fitted" to your test data and is not robust in real trading. The other effect is that your new super 5 layer indicator system
filters out too many trades.

Here's what I mean: Every trader using a mechanical system, which is what the "turtles" used, should know his/her system's "expectancy". If I have 100 trades, 60 of them profitable with an avg profit of
$20...and 40 losing trades with an average loss of $18, my expectancy is (.60 * 20) - (.40 * 18) = $4.80 / trade. The beginner mistake is to add layers of filters to the system to try to raise the expectancy
higher. In doing so, if they succeed it usually results in fewer trades, so even though each trade is more profitable than before the system was modified, they make less money because their new trade selection
parameters are stricter and gives fewer trades.

Example: I have system A detailed above: Expectancy of $4.80 / trade and with those selection parameters I get 100 trades/year....so I make $480

I then tweak system A and manage to raise its expectancy to $7.00 / trade. This new system (B) with stricter selection rules to filter out more losers only
generates 60 trades a year. Even though each trade makes more $, it only makes $420 in the same amount of time that system A made $480

Accept that losing is part of profitable trading. Casino's dont mind losing b/c they know that time is on their side. All they want is more chances to let their
statistical edge work for them and eventually/inevitably make them profitable.

As for what time frames to trade....day trade, swing trade, trend trade...that's where knowing yourself and your risk tolerance and ability to sit tight on a trade is critical. If you find a system that works on a daily chart using a 20 day indicator...but you know you are more risk averse and want a shorter horizon, test the system using the same number of chart bars(20 for the daily example that
I just mentioned) using 20 bars of an hourly/30 min/15 min/5 minute chart as a starting point for your testing.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
normal retail trader like most of us, even with the most advanced computing equipment, you still need solve the algorithm level of software issues. therefore, financial engineering is a systemic work. but it really just for pros?

i don't think so, we can't deal with the sub-minutes level of ticker date. but above a higher level of time period, such as 4-hour daily weekly and so on. with some traditional technical analysis, you will have a bigger change to be profitable.

what i trying to say is that at this "kind of level" of quantitative trading. we don't expected to be a rocket scientist, but at least we can take advantage the disciplinary management of computer to executed a reasonable and profitable trading strategy, which brings the next advantage of automated trading, we can backtest it as long, multi-variety and cross-variety as we want. it's impossible to do it by manual trading. also, after some backtest to prove a profitable trading strategy, the capital management method become more realistic, otherwise you just guess the trading results link to your capital management.  
newbie
Activity: 14
Merit: 0
surely it needs learning to understand and use this kind of strategy.
do you think it's better for day trader or long-term hodler?
how to modify this strategy to my own?
newbie
Activity: 18
Merit: 7
I have many years of experience in trading both in the CBOT bond pit and by computer, as well as designing profitable systems and backtesting. There is nothing magic about Dennis' system or Donchian Channels.
They did what anyone willing to work can do: Find a repeatable method that has a positive expectancy, apply aggressive money management rules to it, and trade it faithfully and consistently.

They picked people that they thought had personalities that would allow them to stick to the rules, which is critical for any "system".

Where things break down, and the problem with trading an otherwise profitable system that you havent developed yourself (with incorporated knowledge of yourself and your risk tolerance)
is that your brain won't let you follow ALL the rules, ALL the time.

For the vast majority of people, trading a system that someone else has developed is usually a fools game. It might be profitable on paper, and for the person that developed it, but if its
style and rules aren't compatible with your particular brand of "fear and greed" (which we all have), you're very likely to lose money.
legendary
Activity: 1512
Merit: 1041
I know this piece is more about "what" trutle trading strategy is instead of how it started but I can't really go beyond that part. First of all these people were given a method that would probably yield them profits unless something unthinkable happens. Hence they were suppose to follow an order and make money with that strict line given to them.

Lets take a look at the candidates, a black jack master is a guy who can read cards and numbers to do card counting to beat the house and gain house edge, with that in mind he needs to perfect his skills and strictly follow the card counting rules, perfect for this type of job, dungeons and dragons DM is a guy who writes these kinds of amazing stories and lines and make others follow the path without really going above or below the game limits, perfect again, air force pilot drives a plane that's multi-million sometimes goes into hundreds of millions of dollars worth, he needs to know his plane so well that even what could go wrong needs to be in his mind, amazing candidate, former pianist is someone who mastered piano on which keys do what and what you click gives what sound and memorize the notes and songs and so forth, again amazing.

Basically they picked candidates that worked all their lives on perfecting something that needs to be followed stirctly just like trading, they knew who they were hiring and not people who are emotional about stuff.
legendary
Activity: 3080
Merit: 1353
Great info,but I think that this is way too technical and most of the newbie traders won't understand how it works.Somebody has to simplify it.It would be great if someone creates a trading bot around this strategy.
I might be interested in asquiring such bot. Grin

Exactly, even a mid level trader would be lost be lost with some of the technical aspect of this trading strategy. But yes I agree that if a bot would be created (maybe the OP can hire someone), then it will be much easier for a casual trader to understand and take advantage of this method. I'm not saying its bad, but traders mostly don't want complex trading methods. They just want it to be simply and yet effective so a bot will be a good "nice to haves".
member
Activity: 67
Merit: 24
Quote
way too technical
This is one of the most basic strategies ever, created in 1970s. You are in an industry where you are playing against some of the best mathematicians, developers and financists. I think you need to get a little bit technical to stand a chance.
hero member
Activity: 3150
Merit: 937
Great info,but I think that this is way too technical and most of the newbie traders won't understand how it works.Somebody has to simplify it.It would be great if someone creates a trading bot around this strategy.
I might be interested in asquiring such bot. Grin
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
Do you have backtests results for different coins with this?

https://www.fmz.com/strategy/132298


overhere, some more backtest results
member
Activity: 67
Merit: 24
Do you have backtests results for different coins with this?
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
no one cares? Cry
Of course someone has read your post and to be honest, I'm not aware of this kind of strategy. Everyone has already some trading strategy that works so they don't want to overly complicate things on their end. Personally though, I need to read more and understand how I can apply it, however, I'm not into trading right now because of the market conditions, but maybe I will give it a try.


thanks a lot
sr. member
Activity: 2618
Merit: 439
no one cares? Cry
Of course someone has read your post and to be honest, I'm not aware of this kind of strategy. Everyone has already some trading strategy that works so they don't want to overly complicate things on their end. Personally though, I need to read more and understand how I can apply it, however, I'm not into trading right now because of the market conditions, but maybe I will give it a try.
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
no one cares? Cry
member
Activity: 111
Merit: 13
Perseverance pays... a lot!
“Turtle Trading strategy” implementations

    Background

In 1994, Covel picked up an issue ofFinancial World and skimmed through an article titled "Wall Street's TopPlayers." Amongst famous investors like George Soros and Julian Robertson,Covel noticed a name he did not recognize at 25th on the list: R. Jerry Parker,who stated that he was trained as a "Turtle" by Richard Dennis(another name Covel did not recognize). Parker was the only investor in the tophundred advertised as being "trained," and as an investor himself,Covel found this story intriguing.

    Synopsis

Richard Dennis made over $200 million as a trader. After having a debate with his partner, William Eckhardt, about whether trading is learnable or an inborn talent, they proposed an experiment where they would spend two weeks training novices in the science of trading and then give them each $1 million to invest. The inspiration came from a trip Dennis took to a turtle-breeding farm in Singapore, stating, "We are going to grow traders just like they grow turtles."

Although each of the 1,000 applicants went through a rigorous application process designed to test their intelligence, ability to manage risk and mathematical skills, the makeup of the chosen Turtles differed greatly; they included a Czechoslovakian-born blackjack master, a Dungeons and Dragons game designer, an evangelical accountant, a Harvard MBA, a U.S. Air Force pilot and a former pianist. The Turtles would go on to gross over $150 million in four years.

    Trading rules:

In the capture of trend signals, the Turtle Trading Law uses a very important technical indicator, the Donchian channel. This channel is very similar to the familiar Bollinger Bands, but it is somewhat different in terms of specific calculations.

Richard Donchian invented this indicator. It consists of three curves of different colors. The indicator uses the highest price within the period (usually 20, some platform system settings can be changed, some can not be set) And the lowest price to show the volatility of the market price, when the channel is narrow, it means that the market volatility is small, otherwise the channel width means that the market volatility is relatively large.

When the price breaks through the upper track of the channel, it is a possible buy signal; on the contrary, it is a possible sell signal when breaking the lower track.

The calculation methods of the Donchian channel are as follows:

        Upper rail = Max (highest, n), the highest value of the highest price of n days

        Lower rail = Min (lowest price, n), the minimum value of the lowest price of n days

        Middle rail = (upper rail + lower rail)/2

Within the framework of multi-factor analysis in the financial sector, this strategy predicts the price trend after the breakthrough is based on the validity hypothesis of the momentum factor. Of course, the effectiveness of this factor has indeed been rigorously verified and complemented by the Fama-French three-factor model and is widely used in financial markets.

Of course, we can optimize and use more reasonable trend-breaking indicators.

So, since the momentum factor is a factor that has been publicly and widely used, then why can the Turtle Trading Law stand out from the crowd? The answer is simple. The Turtle Trading Rules define a set of very strict rules for position control and stop-loss. Let's take a look at each one.

    1. The basic unit of the position N

The principle of the Turtle Rule is to define a small unit (Unit) so that the expected value fluctuation of the position corresponds to 1% of the total net assets. In other words, if you buy the assets of this small unit, the market value of the position on that day will not change by more than 1% of the total net assets.

So how do you define this small unit? How do you estimate the value fluctuations that this small unit can bring? First, in predicting the value volatility of this small unit (this value volatility is called N), the Turtle Strategy uses a method of statistically averaging historical price volatility. The specific calculation formula is as follows:

        TrueRange = Max(High−Low, High−PreClose, PreClose−Low)

        N = (the sum of the N values ​​of the previous 19 days + the TrueRange at the time) / 20

Among them, High indicates the highest price of the day, Low indicates the lowest price of the day, and PreClose indicates the closing price of the previous day. We can see from the definition that the value of N can indeed properly express the recent fluctuations in the price of the asset.

Thus, a Unit should be calculated like this:

        Unit = (1%*Total_net)/N, Total_net is the total net asset value

It can be seen that the price volatility of a Unit's assets = 1% of the total net assets

    2. When to open a position

The action of opening a position comes from the generation of a trend breakthrough signal. If the current price breaks through the upper track, it will generate a buy position signal. If the current price falls below the lower track, it will generate a short position signal (the cryptocurrency market is supported by the short sale!)

Initial build size = 1 Unit

    3. When is the adding position?

If the holding position is long positions and the price of the asset has increased by 0.5N based on the last holding position (or adding position), then add a unit of long position;

If the holding position is short position and the price of the asset has dropped by 0.5N based on the last position (or adding position), then add a unit of short position.

We have seen that the Turtle Strategy is actually a strategy of chasing up and down.

    4. How to do dynamic stop loss

If the holding position is long positions and the price of the asset falls by 2N based on the last holding position (or adding position), then stop loss for all positions;

If the holding position is short position and the price of the asset has increased by 2N based on the last holding position (or adding position), then the entire position must be closed.

Of course, the user can customize the dynamic stop loss plan, such as a 0.5N drop to start partial closing position, instead of waiting for a 2N decline after a rush to close the position; after all, the impact cost is there.

    5. How to make a profit, can you customize the dynamic take profit?

In the Turtle Rule, the Take Profit signal is generated like this:

If the holding position is long positions and the current asset price falls below the lower track of the 10th Donchian channel, all position closed;

If the holding position is short position and the current asset price rises above the upper track of the 10th Donchian channel, all position closed.

Of course, users can customize the dynamic take profit plan, such as when the total net assets / initial net assets > 1.5, just take the profit.

    Advantage

The biggest advantage of the Turtle Trading Law is to help us establish an effective method of controlling the size of the position.

    Disadvantage

The turtle trading system has a common problem with the trend tracking strategy, which is the withdrawal of floating profit. The floating profit that is chasing up is likely to be spit out due to a sudden drop. It is very strong in the big trend, and it is not perform very well in the shock market.

Enough talk, let’s make it happen!

    M language

After 6 years of development, it has absorbed feedback from hundreds of thousands of users. It is a mature and stable model development platform. M language is the most widely used programmatic model development platform in China.

The M language advocates the building block programming concept, which encapsulates complex algorithms into individual functions and adopts the construction mode of “small syntax, large function”. Although the grammar is simple, it can also support logical and complex financial applications with a special programmatic data structure and a rich financial statistical function library.

The function library of the M language is updated frequently, and new functions can be added at any time according to the new requirements of the customer to support the new ideas and new applications of the programmer.

The FMZ Quant not only realized the interpreter of the grammar of M language, but also enhanced its ability to mix programming with high-level language such as JavaScript.

For example:

Code:
// here you can call any API function from FMZ Quant
scope.TEST = function(obj) {
    return obj.val * 100;
}
Closing price: C;

The closing price is magnified 100 times: TEST(C);

The previous closing price is magnified 100 times: TEST(REF(C, 1)); // The mouse moves to the backtest K line and the variable value is displayed.





(*backtest
start: 2018-06-01 00:00:00
end: 2018-11-21 00:00:00
period: 1d
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES","balance":500000,"minfee":0,"fee":[0,0]}]
*)

// this demonstration mainly uses the Turtle Trading Rules to demonstrate the method of writing "position management, maximum position control and other fund management".
// only the demonstration key content statement is annotated, other statements please consult customer service
//This model is only used to demonstrate the use of this strategy, and enters the market accordingly, at your own risk.
Code:
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));// True volatility
ATR:MA(TR,26); // Find a simple moving average of the true amplitude in 26 cycles, shown in the figure
ZOOM:=IFELSE(ISCONTRACT('@Futures_(?!CTP).*'), CLOSE, 1); // Compatible with cryptocurrency futures as margin
LOT:=((MONEYTOT*0.01*ZOOM)/(UNIT*ATR))*ZOOM;// Calculate the number of one hand based on 1% of equity
TC..IFELSE(ISCONTRACT('@Futures.*'), INTPART(LOT), LOT); // Compatible futures and spot ISCONTRACT starts with @ to indicate matching exchange name, support
MTC..4*TC; // Total position
HH^^HV(H,20); // Attached to the main image display
LL^^LV(L,20); // Attached to the main image display
CROSSUP(C,HH)&&ISLASTBK=0&&ISLASTSK=0&&BARPOS>=26,BK(TC);// The latest price exceeds the highest value of 20 cycles, the first time to buy long, the quality is TC hands
CROSSDOWN(C,LL)&&ISLASTBK=0&&ISLASTSK=0,SK(TC); // The latest price fell below the lowest value of 20 cycles, the first time to sell short, the quality is TC hands
C>=BKPRICE+0.5*ATR&&BKVOLC<=SKPRICE-0.5*ATR&&SKVOLC<=(BKPRICE-2*ATR)&&BKVOL>0,SP(BKVOL);// The latest price is less than the opening price minus 2 times of ATR, stop loss and close position
C>=(SKPRICE+2*ATR)&&SKVOL>0,BP(SKVOL); // The latest price is greater than the opening price plus 2 times of ATR, stop loss and close position
CROSSUP(H,HV(H,10))&&SKVOL>0,BP(SKVOL);// The highest price up-cross the highest price of 10 cycles, closing the position
CROSSDOWN(L,LV(L,10))&&BKVOL>0,SP(BKVOL); // The lowest price down-cross the lowest price of 10 cycles, closing position
TRADE_AGAIN(10);

article originally from fmz.com
Jump to: