<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>3 Most Clicked &#8211; The Financial Hacker</title>
	<atom:link href="https://financial-hacker.com/category/most-popular/feed/" rel="self" type="application/rss+xml" />
	<link>https://financial-hacker.com</link>
	<description>A new view on algorithmic trading</description>
	<lastBuildDate>Fri, 13 Oct 2023 08:20:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://financial-hacker.com/wp-content/uploads/2017/07/cropped-mask-32x32.jpg</url>
	<title>3 Most Clicked &#8211; The Financial Hacker</title>
	<link>https://financial-hacker.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Better Strategies 5: A Short-Term Machine Learning System</title>
		<link>https://financial-hacker.com/build-better-strategies-part-5-developing-a-machine-learning-system/</link>
					<comments>https://financial-hacker.com/build-better-strategies-part-5-developing-a-machine-learning-system/#comments</comments>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Fri, 12 Aug 2016 09:42:38 +0000</pubDate>
				<category><![CDATA[3 Most Clicked]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[System Development]]></category>
		<category><![CDATA[Autoencoder]]></category>
		<category><![CDATA[Boltzmann machine]]></category>
		<category><![CDATA[Classification]]></category>
		<category><![CDATA[Confusion matrix]]></category>
		<category><![CDATA[Data mining bias]]></category>
		<category><![CDATA[Deepnet]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[Price action]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Sharpe ratio]]></category>
		<category><![CDATA[Walk forward analysis]]></category>
		<guid isPermaLink="false">http://www.financial-hacker.com/build-better-strategies-part-3-the-development-process-copy/</guid>

					<description><![CDATA[It&#8217;s time for the 5th and final part of the Build Better Strategies series. In part 3 we&#8217;ve discussed the development process of a model-based system, and consequently we&#8217;ll conclude the series with developing a data-mining system. The principles of data mining and machine learning have been the topic of part 4. For our short-term &#8230; <a href="https://financial-hacker.com/build-better-strategies-part-5-developing-a-machine-learning-system/" class="more-link">Continue reading<span class="screen-reader-text"> "Better Strategies 5: A Short-Term Machine Learning System"</span></a>]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s time for the 5th and final part of the <a href="http://www.financial-hacker.com/build-better-strategies/">Build Better Strategies</a> series. In <a href="http://www.financial-hacker.com/build-better-strategies-part-3-the-development-process/" target="_blank" rel="noopener">part 3</a> we&#8217;ve discussed the development process of a model-based system, and consequently we&#8217;ll conclude the series with developing a data-mining system. The principles of data mining and machine learning have been the topic of <a href="http://www.financial-hacker.com/build-better-strategies-part-4-machine-learning/">part 4</a>. For our short-term trading example we&#8217;ll use a <strong>deep learning algorithm</strong>, a stacked autoencoder, but it will work in the same way with many other machine learning algorithms. With today&#8217;s software tools, only about <strong>20 lines of code</strong> are needed for a machine learning strategy. I&#8217;ll try to explain all steps in detail. <span id="more-1872"></span></p>
<p>Our example will be a <strong>research project</strong> &#8211; a machine learning experiment for answering two questions. Does a more complex algorithm &#8211; such as, more neurons and deeper learning &#8211; produce a better prediction? And are short-term price moves predictable by short-term price history? The last question came up due to my scepticism about <strong>price action trading</strong> in the <a href="http://www.financial-hacker.com/build-better-strategies-part-4-machine-learning/" target="_blank" rel="noopener">previous part</a> of this series. I got several emails asking about the &#8220;trading system generators&#8221; or similar price action tools that are praised on some websites. There is no hard evidence that such tools ever produced any profit (except for their vendors) &#8211; but does this mean that they all are garbage? We&#8217;ll see.</p>
<p>Our experiment is simple: We collect information from the last candles of a price curve, feed it in a deep learning neural net, and use it to predict the next candles. My hypothesis is that a few candles don&#8217;t contain any useful predictive information. Of course, a nonpredictive outcome of the experiment won&#8217;t mean that I&#8217;m right, since I could have used wrong parameters or prepared the data badly. But a predictive outcome would be a hint that I&#8217;m wrong and price action trading can indeed be profitable.</p>
<h3>Machine learning strategy development<br />
Step 1: The target variable</h3>
<p>To recap the <a href="http://www.financial-hacker.com/build-better-strategies-part-4-machine-learning/">previous part</a>: a supervised learning algorithm is trained with a set of <strong>features</strong> in order to predict a <strong>target variable</strong>. So the first thing to determine is what this target variable shall be. A popular target, used in most papers, is the sign of the price return at the next bar. Better suited for prediction, since less susceptible to randomness, is the price difference to a more distant <strong>prediction horizon</strong>, like 3 bars from now, or same day next week. Like almost anything in trading systems, the prediction horizon is a compromise between the effects of randomness (less bars are worse) and predictability (less bars are better).</p>
<p>Sometimes you&#8217;re not interested in directly predicting price, but in predicting some other parameter &#8211; such as the current leg of a Zigzag indicator &#8211; that could otherwise only be determined in hindsight. Or you want to know if a certain <strong>market inefficiency</strong> will be present in the next time, especially when you&#8217;re using machine learning not directly for trading, but for filtering trades in a <a href="http://www.financial-hacker.com/build-better-strategies-part-3-the-development-process/" target="_blank" rel="noopener">model-based system</a>. Or you want to predict something entirely different, for instance the probability of a market crash tomorrow. All this is often easier to predict than the popular tomorrow&#8217;s return.</p>
<p>In our price action experiment we&#8217;ll use the return of a short-term price action trade as target variable. Once the target is determined, next step is selecting the features.</p>
<h3>Step 2: The features</h3>
<p>A price curve is the worst case for any machine learning algorithm. Not only does it carry <strong>little signal and mostly noise</strong>, it is also nonstationary and the signal/noise ratio changes all the time. The exact ratio of signal and noise depends on what is meant with &#8220;signal&#8221;, but it is normally too low for any known machine learning algorithm to produce anything useful. So we must derive features from the price curve that contain more signal and less noise. Signal, in that context, is any information that can be used to predict the target, whatever it is. All the rest is noise.</p>
<p>Thus, <strong>selecting the features is critical for success</strong> &#8211; even more critical than deciding which machine learning algorithm you&#8217;re going to use. There are two approaches for selecting features. The first and most common is extracting as much information from the price curve as possible. Since you do not know where the information is hidden, you just generate a wild collection of indicators with a wide range of parameters, and hope that at least a few of them will contain the information that the algorithm needs. This is the approach that you normally find in the literature. The problem of this method: Any machine learning algorithm is easily confused by nonpredictive predictors. So it won&#8217;t do to just throw 150 indicators at it. You need some <strong>preselection algorithm </strong>that determines which of them carry useful information and which can be omitted. Without reducing the features this way to maybe eight or ten, even the deepest learning algorithm won&#8217;t produce anything useful.</p>
<p>The other approach, normally for experiments and research, is using only limited information from the price curve. This is the case here: Since we want to examine price action trading, we only use the last few prices as inputs, and must discard all the rest of the curve. This has the advantage that we don&#8217;t need any preselection algorithm since the number of features is limited anyway. Here are the two simple predictor functions that we use in our experiment (in C):</p>
<pre class="prettyprint">var change(int n)
{
	return scale((priceClose(0) - priceClose(n))/priceClose(0),100)/100;
}

var range(int n)
{
	return scale((HH(n) - LL(n))/priceClose(0),100)/100;
}</pre>
<p>The two functions are supposed to carry the necessary information for price action: per-bar movement and volatility. The <strong>change </strong>function is the difference of the current price to the price of <strong>n</strong> bars before, divided by the current price. The <strong>range</strong> function is the total high-low distance of the last <strong>n</strong> candles, also in divided by the current price. And the <strong>scale</strong> function centers and compresses the values to the <strong>+/-100</strong> range, so we divide them by 100 for getting them normalized to <strong>+/-1</strong>. We remember that normalizing is needed for machine learning algorithms.</p>
<h3>Step 3: Preselecting predictors</h3>
<p>When you have selected a large number of indicators or other signals as features for your algorithm, you must determine which of them is useful and which not. There are many methods for reducing the number of features, for instance:</p>
<ul style="list-style-type: square;">
<li>Determine the correlations between the signals. Remove those with a strong correlation to other signals, since they do not contribute to the information.</li>
<li>Compare the information content of signals directly, with algorithms like information entropy or decision trees.</li>
<li>Determine the information content indirectly by comparing the signals with randomized signals; there are some software libraries for this, such as the R Boruta package.</li>
<li>Use an algorithm like Principal Components Analysis (PCA) for generating a new signal set with reduced dimensionality.</li>
<li>Use genetic optimization for determining the most important signals just by the most profitable results from the prediction process. Great for curve fitting if you want to publish impressive results in a research paper.</li>
</ul>
<p>Reducing the number of features is important for most machine learning algorithms, including shallow neural nets. For deep learning it&#8217;s less important, since deep nets  with many neurons are normally able to process huge feature sets and discard redundant features. For our experiment we do not preselect or preprocess the features, but you can find useful information about this in articles (1), (2), and (3) listed at the end of the page.</p>
<h3>Step 4: Select the machine learning algorithm</h3>
<p>R offers many different ML packages, and any of them offers many different algorithms with many different parameters. Even if you already decided about the method &#8211; here, deep learning &#8211; you have still the choice among different approaches and different R packages. Most are quite new, and you can find not many empirical information that helps your decision. You have to try them all and gain experience with different methods. For our experiment we&#8217;ve choosen the <strong>Deepnet</strong> package, which is probably the simplest and easiest to use deep learning library. This keeps our code short. We&#8217;re using its <strong>Stacked Autoencoder</strong> (<strong>SAE</strong>) algorithm for pre-training the network. Deepnet also offers a <strong>Restricted Boltzmann Machine</strong> (<strong>RBM</strong>) for pre-training, but I could not get good results from it. There are other and more complex deep learning packages for R, so you can spend a lot of time checking out all of them.</p>
<p><em>How</em> pre-training works is easily explained, but <em>why</em> it works is a different matter. As to my knowledge, no one has yet come up with a solid mathematical proof that it works at all. Anyway, imagine a large neural net with many hidden layers:</p>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/deepnet.png"><img fetchpriority="high" decoding="async" class="alignnone wp-image-2026 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/deepnet.png" width="560" height="279" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/deepnet.png 560w, https://financial-hacker.com/wp-content/uploads/2016/10/deepnet-300x149.png 300w" sizes="(max-width: 560px) 85vw, 560px" /></a></p>
<p>Training the net means setting up the connection weights between the neurons. The usual method is error backpropagation. But it turns out that the more hidden layers you have, the worse it works. The backpropagated error terms get smaller and smaller from layer to layer, causing the first layers of the net to learn almost nothing. Which means that the predicted result becomes more and more dependent of the random initial state of the weights. This severely limited the complexity of layer-based neural nets and therefore the tasks that they can solve. At least until 10 years ago.</p>
<p>In 2006 scientists in Toronto first published the idea to pre-train the weights with an unsupervised learning algorithm, a restricted Boltzmann machine. This turned out a revolutionary concept. It boosted the development of artificial intelligence and allowed all sorts of new applications from Go-playing machines to self-driving cars. Meanwhile, several new improvements and algorithms for deep learning have been found. A stacked autoencoder works this way:</p>
<ol>
<li>Select the hidden layer to train; begin with the first hidden layer. Connect its outputs to a temporary output layer that has the same structure as the network&#8217;s input layer.</li>
<li>Feed the network with the training samples, but without the targets. Train it so that the first hidden layer reproduces the input signal &#8211; the features &#8211; at its outputs as exactly as possible. The rest of the network is ignored. During training, apply a &#8216;weight penalty term&#8217; so that as few connection weights as possible are used for reproducing the signal.</li>
<li>Now feed the outputs of the trained hidden layer to the inputs of the next untrained hidden layer, and repeat the training process so that the input signal is now reproduced at the outputs of the next layer.</li>
<li>Repeat this process until all hidden layers are trained. We have now a &#8216;sparse network&#8217; with very few layer connections that can reproduce the input signals.</li>
<li>Now train the network with backpropagation for learning the target variable, using the pre-trained weights of the hidden layers as a starting point.</li>
</ol>
<p>The hope is that the unsupervised pre-training process produces an internal noise-reduced abstraction of the input signals that can then be used for easier learning the target. And this indeed appears to work. No one really knows why, but several theories &#8211; see paper (4) below &#8211; try to explain that phenomenon.</p>
<h3>Step 5: Generate a test data set</h3>
<p>We first need to produce a data set with features and targets so that we can test our prediction process and try out parameters. The features must be based on the same price data as in live trading, and for the target we must simulate a short-term trade. So it makes sense to generate the data not with R, but with our trading platform, which is anyway a lot faster. Here&#8217;s a small <a href="http://www.financial-hacker.com/hackers-tools-zorro-and-r/" target="_blank" rel="noopener">Zorro</a> script for this, <strong>DeepSignals.c</strong>:</p>
<pre class="prettyprint">function run()
{
	StartDate = 20140601; // start two years ago
	BarPeriod = 60; // use 1-hour bars
	LookBack = 100; // needed for scale()

	set(RULES);   // generate signals
	LifeTime = 3; // prediction horizon
	Spread = RollLong = RollShort = Commission = Slippage = 0;
	
	adviseLong(SIGNALS+BALANCED,0,
		change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4));
	enterLong(); 
}
</pre>
<p>We&#8217;re generating 2 years of data with features calculated by our above defined <strong>change </strong>and <strong>range</strong> functions. Our target is the result of a trade with 3 bars life time. Trading costs are set to zero, so in this case the result is equivalent to the sign of the price difference at 3 bars in the future. The <strong>adviseLong</strong> function is described in the <a href="http://manual.zorro-project.com/advisor.htm" target="_blank" rel="noopener">Zorro manual</a>; it is a mighty function that automatically handles training and predicting and allows to use any R-based machine learning algorithm just as if it were a simple indicator.</p>
<p>In our code, the function uses the next trade return as target, and the price changes and ranges of the last 4 bars as features. The <strong>SIGNALS</strong> flag tells it not to train the data, but to export it to a .csv file. The <strong>BALANCED</strong> flag makes sure that we get as many positive as negative returns; this is important for most machine learning algorithms. Run the script in [Train] mode with our usual test asset EUR/USD selected. It generates a spreadsheet file named <strong>DeepSignalsEURUSD_L.csv</strong> that contains the features in the first 8 columns, and the trade return in the last column.</p>
<h3>Step 6: Calibrate the algorithm</h3>
<p>Complex machine learning algorithms have many parameters to adjust. Some of them offer great opportunities to curve-fit the algorithm for publications. Still, we must calibrate parameters since the algorithm rarely works well with its default settings. For this, here&#8217;s an R script that reads the previously created data set and processes it with the deep learning algorithm (<strong>DeepSignal.r</strong>): </p>
<pre class="prettyprint">library('deepnet', quietly = T) 
library('caret', quietly = T)

neural.train = function(model,XY) 
{
  XY &lt;- as.matrix(XY)
  X &lt;- XY[,-ncol(XY)]
  Y &lt;- XY[,ncol(XY)]
  Y &lt;- ifelse(Y &gt; 0,1,0)
  Models[[model]] &lt;&lt;- sae.dnn.train(X,Y,
      hidden = c(50,100,50), 
      activationfun = "tanh", 
      learningrate = 0.5, 
      momentum = 0.5, 
      learningrate_scale = 1.0, 
      output = "sigm", 
      sae_output = "linear", 
      numepochs = 100, 
      batchsize = 100,
      hidden_dropout = 0, 
      visible_dropout = 0)
}

neural.predict = function(model,X) 
{
  if(is.vector(X)) X &lt;- t(X)
  return(nn.predict(Models[[model]],X))
}

neural.init = function()
{
  set.seed(365)
  Models &lt;&lt;- vector("list")
}

TestOOS = function() 
{
  neural.init()
  XY &lt;&lt;- read.csv('C:/Zorro/Data/DeepSignalsEURUSD_L.csv',header = F)
  splits &lt;- nrow(XY)*0.8
  XY.tr &lt;&lt;- head(XY,splits);
  XY.ts &lt;&lt;- tail(XY,-splits)
  neural.train(1,XY.tr)
  X &lt;&lt;- XY.ts[,-ncol(XY.ts)]
  Y &lt;&lt;- XY.ts[,ncol(XY.ts)]
  Y.ob &lt;&lt;- ifelse(Y &gt; 0,1,0)
  Y &lt;&lt;- neural.predict(1,X)
  Y.pr &lt;&lt;- ifelse(Y &gt; 0.5,1,0)
  confusionMatrix(Y.pr,Y.ob)
}</pre>
<p>We&#8217;ve defined three functions <strong>neural.train</strong>, <strong>neural.predict</strong>, and <strong>neural.init</strong> for training, predicting, and initializing the neural net. The function names are not arbitrary, but follow the convention used by Zorro&#8217;s advise(NEURAL,..) function. It doesn&#8217;t matter now, but will matter later when we use the same R script for training and trading the deep learning strategy. A fourth function, <strong>TestOOS</strong>, is used for out-of-sample testing our setup.</p>
<p>The function <strong>neural.init</strong> seeds the R random generator with a fixed value (365 is my personal lucky number). Otherwise we would get a slightly different result any time, since the neural net is initialized with random weights. It also creates a global R list named &#8220;Models&#8221;. Most R variable types don&#8217;t need to be created beforehand, some do (don&#8217;t ask me why). The &#8216;&lt;&lt;-&#8216; operator is for accessing a global variable from within a function.</p>
<p>The function <strong>neural.train</strong> takes as input a model number and the data set to be trained. The model number identifies the trained model in the &#8220;<strong>Models</strong>&#8221; list. A list is not really needed for this test, but we&#8217;ll need it for more complex strategies that train more than one model. The matrix containing the features and target is passed to the function as second parameter. If the <strong>XY</strong> data is not a proper matrix, which frequently happens in R depending on how you generated it, it is converted to one. Then it is split into the features (<strong>X</strong>) and the target (<strong>Y</strong>), and finally the target is converted to <strong>1</strong> for a positive trade outcome and <strong>0</strong> for a negative outcome. </p>
<p>The network parameters are then set up. Some are obvious, others are free to play around with:</p>
<ul style="list-style-type: square;">
<li>The network structure is given by the <strong>hidden</strong> vector:  <strong>c(50,100,50)</strong> defines 3 hidden layers, the first with 50, second with 100, and third with 50 neurons. That&#8217;s the parameter that we&#8217;ll later modify for determining whether deeper is better.</li>
<li>The <strong>activation function </strong>converts the sum of neuron input values to the neuron output; most often used are <strong>sigmoid</strong> that saturates to 0 or 1, or <strong>tanh</strong> that saturates to -1 or +1.</li>
</ul>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2016/08/sigmoid_tanh.png"><img decoding="async" class="alignnone wp-image-2111 " src="http://www.financial-hacker.com/wp-content/uploads/2016/08/sigmoid_tanh.png" width="523" height="197" srcset="https://financial-hacker.com/wp-content/uploads/2016/08/sigmoid_tanh.png 960w, https://financial-hacker.com/wp-content/uploads/2016/08/sigmoid_tanh-300x113.png 300w, https://financial-hacker.com/wp-content/uploads/2016/08/sigmoid_tanh-768x289.png 768w" sizes="(max-width: 523px) 85vw, 523px" /></a></p>
<p>We use <strong>tanh</strong> here since our signals are also in the +/-1 range. The <strong>output</strong> of the network is a sigmoid function since we want a prediction in the 0..1 range. But the <strong>SAE output</strong> must be &#8220;linear&#8221; so that the Stacked Autoencoder can reproduce the analog input signals on the outputs. Recently in fashion came RLUs, Rectified Linear Units, as activation functions for internal layers. RLUs are faster and partially overcome the above mentioned backpropagation problem, but are not supported by deepnet.</p>
<ul style="list-style-type: square;">
<li>The <strong>learning rate</strong> controls the step size for the gradient descent in training; a lower rate means finer steps and possibly more precise prediction, but longer training time.</li>
<li><strong>Momentum</strong> adds a fraction of the previous step to the current one. It prevents the gradient descent from getting stuck at a tiny local minimum or saddle point.</li>
<li>The <strong>learning rate scale</strong> is a multiplication factor for changing the learning rate after each iteration (I am not sure for what this is good, but there may be tasks where a lower learning rate on higher epochs improves the training).</li>
<li>An <strong>epoch</strong> is a training iteration over the entire data set. Training will stop once the number of epochs is reached. More epochs mean better prediction, but longer training.</li>
<li>The <strong>batch size</strong> is a number of random samples &#8211; a <strong>mini batch</strong> &#8211; taken out of the data set for a single training run. Splitting the data into mini batches speeds up training since the weight gradient is then calculated from fewer samples. The higher the batch size, the better is the training, but the more time it will take.</li>
<li>The <strong>dropout</strong> is a number of randomly selected neurons that are disabled during a mini batch. This way the net learns only with a part of its neurons. This seems a strange idea, but can effectively reduce overfitting.</li>
</ul>
<p>All these parameters are common for neural networks. Play around with them and check their effect on the result and the training time. Properly calibrating a neural net is not trivial and might be the topic of another article. The parameters are stored in the model together with the matrix of trained connection weights. So they need not to be given again in the prediction function, <strong>neural.predict</strong>. It takes the model and a vector <strong>X</strong> of features, runs it through the layers, and returns the network output, the predicted target <strong>Y</strong>. Compared with training, prediction is pretty fast since it only needs a couple thousand multiplications. If <strong>X</strong> was a row vector, it is transposed and this way converted to a column vector, otherwise the <strong>nn.predict</strong> function won&#8217;t accept it.</p>
<p>Use RStudio or some similar environment for conveniently working with R. Edit the path to the <strong>.csv</strong> data in the file above, source it, install the required R packages (deepnet, e1071, and caret), then call the <strong>TestOOS</strong> function from the command line. If everything works, it should print something like that:</p>
<pre class="prettyprint">&gt; TestOOS()
begin to train sae ......
training layer 1 autoencoder ...
####loss on step 10000 is : 0.000079
training layer 2 autoencoder ...
####loss on step 10000 is : 0.000085
training layer 3 autoencoder ...
####loss on step 10000 is : 0.000113
sae has been trained.
begin to train deep nn ......
####loss on step 10000 is : 0.123806
deep nn has been trained.
Confusion Matrix and Statistics

          Reference
Prediction    0    1
         0 1231  808
         1  512  934
                                          
               Accuracy : 0.6212          
                 95% CI : (0.6049, 0.6374)
    No Information Rate : 0.5001          
    P-Value [Acc &gt; NIR] : &lt; 2.2e-16       
                                          
                  Kappa : 0.2424          
 Mcnemar's Test P-Value : 4.677e-16       
                                          
            Sensitivity : 0.7063          
            Specificity : 0.5362          
         Pos Pred Value : 0.6037          
         Neg Pred Value : 0.6459          
             Prevalence : 0.5001          
         Detection Rate : 0.3532          
   Detection Prevalence : 0.5851          
      Balanced Accuracy : 0.6212          
                                          
       'Positive' Class : 0               
                                          
&gt; </pre>
<p><strong>TestOOS</strong> reads first our data set from Zorro&#8217;s Data folder. It splits the data in 80% for training (<strong>XY.tr</strong>) and 20% for out-of-sample testing (<strong>XY.ts</strong>). The training set is trained and the result stored in the <strong>Models</strong> list at index 1. The test set is further split in features (<strong>X</strong>) and targets (<strong>Y</strong>). <strong>Y</strong> is converted to binary 0 or 1 and stored in <strong>Y.ob</strong>, our vector of observed targets. We then predict the targets from the test set, convert them again to binary 0 or 1 and store them in <strong>Y.pr</strong>. For comparing the observation with the prediction, we use the <strong>confusionMatrix</strong> function from the caret package.</p>
<p>A confusion matrix of a binary classifier is simply a 2&#215;2 matrix that tells how many 0&#8217;s and how many 1&#8217;s had been predicted wrongly and correctly. A lot of metrics are derived from the matrix and printed in the lines above. The most important at the moment is the <strong>62% prediction accuracy</strong>. This may hint that I bashed price action trading a little prematurely. But of course the 62% might have been just luck. We&#8217;ll see that later when we run a WFO test.</p>
<p>A final advice: R packages are occasionally updated, with the possible consequence that previous R code suddenly might work differently, or not at all. This really happens, so test carefully after any update.</p>
<h3>Step 7: The strategy</h3>
<p>Now that we&#8217;ve tested our algorithm and got some prediction accuracy above 50% with a test data set, we can finally code our machine learning strategy. In fact we&#8217;ve already coded most of it, we just must add a few lines to the above Zorro script that exported the data set. This is the final script for training, testing, and (theoretically) trading the system (<strong>DeepLearn.c</strong>):</p>
<pre class="prettyprint">#include &lt;r.h&gt;

function run()
{
	StartDate = 20140601;
	BarPeriod = 60;	// 1 hour
	LookBack = 100;

	WFOPeriod = 252*24; // 1 year
	DataSplit = 90;
	NumCores = -1;  // use all CPU cores but one

	set(RULES);
	Spread = RollLong = RollShort = Commission = Slippage = 0;
	LifeTime = 3;
	if(Train) Hedge = 2;
	
	if(adviseLong(NEURAL+BALANCED,0,
		change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4)) &gt; 0.5) 
		enterLong();
	if(adviseShort() &gt; 0.5) 
		enterShort();
}</pre>
<p>We&#8217;re using a WFO cycle of one year, split in a 90% training and a 10% out-of-sample test period. You might ask why I have earlier used two year&#8217;s data and a different split, 80/20, for calibrating the network in step 5. This is for using differently composed data for calibrating and for walk forward testing. If we used exactly the same data, the calibration might overfit it and compromise the test. </p>
<p>The selected WFO parameters mean that the system is trained with about 225 days data, followed by a 25 days test or trade period. Thus, in live trading the system would retrain every 25 days, using the prices from the previous 225 days. In the literature you&#8217;ll sometimes find the recommendation to retrain a machine learning system after any trade, or at least any day. But this does not make much sense to me. When you used almost 1 year&#8217;s data for training a system, it can obviously not deteriorate after a single day. Or if it did, and only produced positive test results with daily retraining, I would strongly suspect that the results are artifacts by some coding mistake.</p>
<p>Training a deep network takes really a long time, in our case about 10 minutes for a network with 3 hidden layers and 200 neurons. In live trading this would be done by a second Zorro process that is automatically started by the trading Zorro. In the backtest, the system trains at any WFO cycle. Therefore using multiple cores is recommended for training many cycles in parallel. The <strong>NumCores</strong> variable at <strong>-1</strong> activates all CPU cores but one. Multiple cores are only available in Zorro S, so a complete walk forward test with all WFO cycles can take several hours with the free version.</p>
<p>In the script we now train both long and short trades. For this we have to allow hedging in Training mode, since long and short positions are open at the same time. Entering a position is now dependent on the return value from the <strong>advise</strong> function, which in turn calls either the <strong>neural.train</strong> or the <strong>neural.predict</strong> function from the R script. So we&#8217;re here entering positions when the neural net predicts a result above 0.5. </p>
<p>The R script is now controlled by the Zorro script (for this it must have the same name, <strong>DeepLearn.r</strong>, only with different extension). It is identical to our R script above since we&#8217;re using the same network parameters. Only one additional function is needed for supporting a WFO test:</p>
<pre class="prettyprint">neural.save = function(name)
{
  save(Models,file=name)  
}</pre>
<p>The <strong>neural.save</strong> function stores the <strong>Models</strong> list &#8211; it now contains 2 models for long and for short trades &#8211; after every training run in Zorro&#8217;s Data folder. Since the models are stored for later use, we do not need to train them again for repeated test runs.</p>
<p>This is the WFO equity curve generated with the script above (EUR/USD, without trading costs):</p>
<figure id="attachment_2037" aria-describedby="caption-attachment-2037" style="width: 879px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD.png"><img decoding="async" class="wp-image-2037 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD.png" width="879" height="341" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD.png 879w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-768x298.png 768w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /></a><figcaption id="caption-attachment-2037" class="wp-caption-text">EUR/USD equity curve with 50-100-50 network structure</figcaption></figure>
<p>Although not all WFO cycles get a positive result, it seems that there is some predictive effect. The curve is equivalent to an annual return of 89%, achieved with a 50-100-50 hidden layer structure. We&#8217;ll check in the next step how different network structures affect the result.</p>
<p>Since the <strong>neural.init</strong>, <strong>neural.train</strong>, <strong>neural.predict</strong>, and <strong>neural.save</strong> functions are automatically called by Zorro&#8217;s adviseLong/adviseShort functions, there are no R functions directly called in the Zorro script. Thus the script can remain unchanged when using a different machine learning method. Only the <strong>DeepLearn.r</strong> script must be modified and the neural net, for instance, replaced by a support vector machine. For trading such a machine learning system live on a VPS, make sure that R is also installed on the VPS, the needed R packages are installed, and the path to the R terminal set up in Zorro&#8217;s ini file. Otherwise you&#8217;ll get an error message when starting the strategy.</p>
<h3>Step 8: The experiment</h3>
<p>If our goal had been developing a strategy, the next steps would be the reality check, risk and money management, and preparing for live trading just as described under <a href="http://www.financial-hacker.com/build-better-strategies-part-3-the-development-process/" target="_blank" rel="noopener">model-based strategy development</a>. But for our experiment we&#8217;ll now run a series of tests, with the number of neurons per layer increased from 10 to 100 in 3 steps, and 1, 2, or 3 hidden layers (deepnet does not support more than 3). So we&#8217;re looking into the following 9 network structures: c(10), c(10,10), c(10,10,10), c(30), c(30,30), c(30,30,30), c(100), c(100,100), c(100,100,100). For this experiment you need an afternoon even with a fast PC and in multiple core mode. Here are the results (SR = Sharpe ratio, R2 = slope linearity): </p>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 28px;">
<td style="width: 40px;"> </td>
<td>* 10 neurons</td>
<td>* 30 neurons</td>
<td>* 100 neurons</td>
</tr>
<tr style="height: 28.75px;">
<td style="width: 40px;">1</td>
<td>
<figure id="attachment_2047" aria-describedby="caption-attachment-2047" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-1.png"><img loading="lazy" decoding="async" class="wp-image-2047 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-1-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-1-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-1-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-1.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2047" class="wp-caption-text">SR = 0.55 R2 = 0.00</figcaption></figure>
</td>
<td>
<figure id="attachment_2048" aria-describedby="caption-attachment-2048" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-2.png"><img loading="lazy" decoding="async" class="wp-image-2048 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-2-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-2-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-2-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-2.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2048" class="wp-caption-text">SR = 1.02 R2 = 0.51</figcaption></figure>
</td>
<td>
<figure id="attachment_2049" aria-describedby="caption-attachment-2049" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-3.png"><img loading="lazy" decoding="async" class="wp-image-2049 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-3-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-3-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-3-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-3.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2049" class="wp-caption-text">SR = 1.18 R2 = 0.84</figcaption></figure>
</td>
</tr>
<tr style="height: 28px;">
<td style="width: 40px;">2</td>
<td>
<figure id="attachment_2050" aria-describedby="caption-attachment-2050" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-5.png"><img loading="lazy" decoding="async" class="wp-image-2050 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-5-300x116.png" width="300" height="116" /></a><figcaption id="caption-attachment-2050" class="wp-caption-text">SR = 0.98 R2 = 0.57</figcaption></figure>
</td>
<td>
<figure id="attachment_2052" aria-describedby="caption-attachment-2052" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-6.png"><img loading="lazy" decoding="async" class="wp-image-2052 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-6-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-6-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-6-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-6.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2052" class="wp-caption-text">SR = 1.22 R2 = 0.70</figcaption></figure>
</td>
<td>
<figure id="attachment_2054" aria-describedby="caption-attachment-2054" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-8.png"><img loading="lazy" decoding="async" class="wp-image-2054 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-8-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-8-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-8-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-8.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2054" class="wp-caption-text">SR = 0.84 R2 = 0.60</figcaption></figure>
</td>
</tr>
<tr style="height: 28px;">
<td style="width: 40px;">3</td>
<td>
<figure id="attachment_2051" aria-describedby="caption-attachment-2051" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-4.png"><img loading="lazy" decoding="async" class="wp-image-2051 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-4-300x116.png" width="300" height="116" /></a><figcaption id="caption-attachment-2051" class="wp-caption-text">SR = 1.24 R2 = 0.79</figcaption></figure>
</td>
<td>
<figure id="attachment_2053" aria-describedby="caption-attachment-2053" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-7.png"><img loading="lazy" decoding="async" class="wp-image-2053 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-7-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-7-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-7-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-7.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2053" class="wp-caption-text">SR = 1.28 R2 = 0.87</figcaption></figure>
</td>
<td>
<figure id="attachment_2060" aria-describedby="caption-attachment-2060" style="width: 300px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-9.png"><img loading="lazy" decoding="async" class="wp-image-2060 size-medium" src="http://www.financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-9-300x116.png" width="300" height="116" srcset="https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-9-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-9-768x298.png 768w, https://financial-hacker.com/wp-content/uploads/2016/10/DeepLearn_EURUSD-9.png 879w" sizes="auto, (max-width: 300px) 85vw, 300px" /></a><figcaption id="caption-attachment-2060" class="wp-caption-text">SR = 1.33 R2 = 0.83</figcaption></figure>
</td>
</tr>
</tbody>
</table>
<p>We see that a simple net with only 10 neurons in a single hidden layer won&#8217;t work well for short-term prediction. Network complexity clearly improves the performance, however only up to a certain point. A good result for our system is already achieved with 3 layers x 30 neurons. Even more neurons won&#8217;t help much and sometimes even produce a worse result. This is no real surprise, since for processing only 8 inputs, 300 neurons can likely not do a better job than 100.  </p>
<h3>Conclusion</h3>
<p>Our goal was determining if a few candles can have predictive power and how the results are affected by the complexity of the algorithm. The results seem to suggest that short-term price movements can indeed be predicted sometimes by analyzing the changes and ranges of the last 4 candles. The prediction is not very accurate &#8211; it&#8217;s in the 58%..60% range, and most systems of the test series become unprofitable when trading costs are included. Still, I have to reconsider my opinion about price action trading. The fact that the prediction improves with network complexity is an especially convincing argument for short-term price predictability.</p>
<p>It would be interesting to look into the long-term stability of predictive price patterns. For this we had to run another series of experiments and modify the training period (<strong>WFOPeriod</strong> in the script above) and the 90% IS/OOS split. This takes longer time since we must use more historical data. I have done a few tests and found so far that a year seems to be indeed a good training period. The system deteriorates with periods longer than a few years. Predictive price patterns, at least of EUR/USD, have a limited lifetime.</p>
<p>Where can we go from here? There&#8217;s a plethora of possibilities, for instance:</p>
<ul style="list-style-type: square;">
<li>Use inputs from more candles and process them with far bigger networks with thousands of neurons.</li>
<li>Use <a href="http://www.financial-hacker.com/better-tests-with-oversampling/">oversampling</a> for expanding the training data. Prediction always improves with more training samples.</li>
<li>Compress time series f.i. with spectal analysis and analyze not the candles, but their frequency representation with machine learning methods.</li>
<li>Use inputs from many candles &#8211; such as, 100 &#8211; and pre-process adjacent candles with one-dimensional convolutional network layers.</li>
<li>Use recurrent networks. Especially LSTM could be very interesting for analyzing time series &#8211; and as to my knowledge, they have been rarely used for financial prediction so far.</li>
<li>Use an ensemble of neural networks for prediction, such as Aronson&#8217;s &#8220;oracles&#8221; and &#8220;comitees&#8221;.</li>
</ul>
<h3>Papers / Articles</h3>
<p>(1) <a href="http://home.iitk.ac.in/~ayushmn/mail/pre-train.pdf" target="_blank" rel="noopener">A.S.Sisodiya, Reducing Dimensionality of Data</a> <br />
(2) <a href="http://robotwealth.com/machine-learning-financial-prediction-david-aronson/" target="_blank" rel="noopener">K.Longmore, Machine Learning for Financial Prediction</a> <br />
(3) <a href="https://www.mql5.com/en/articles/2029" target="_blank" rel="noopener">V.Perervenko, Selection of Variables for Machine Learning<br />
(</a>4) <a href="http://jmlr.org/papers/volume11/erhan10a/erhan10a.pdf" target="_blank" rel="noopener">D.Erhan et al, Why Does Pre-training Help Deep Learning?</a></p>
<hr />
<p>I&#8217;ve added the C and R scripts to the 2016 script repository. You need both in Zorro&#8217;s Strategy folder. Zorro version 1.474, and R version 3.2.5 (64 bit) was used for the experiment, but it should also work with other versions. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/build-better-strategies-part-5-developing-a-machine-learning-system/feed/</wfw:commentRss>
			<slash:comments>114</slash:comments>
		
		
			</item>
		<item>
		<title>Binary Options: Scam or Opportunity?</title>
		<link>https://financial-hacker.com/binary-options-scam-or-opportunity/</link>
					<comments>https://financial-hacker.com/binary-options-scam-or-opportunity/#comments</comments>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Sat, 18 Jun 2016 16:40:24 +0000</pubDate>
				<category><![CDATA[3 Most Clicked]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[System Development]]></category>
		<category><![CDATA[Binary options]]></category>
		<category><![CDATA[Broker]]></category>
		<category><![CDATA[Mean Reversion]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[Scam]]></category>
		<guid isPermaLink="false">http://www.financial-hacker.com/?p=1709</guid>

					<description><![CDATA[We&#8217;re recently getting more and more contracts for coding binary option strategies. Which gives us a slightly bad conscience, since those options are widely understood as a scheme to separate naive traders from their money. And their brokers make indeed no good impression at first look. Some are regulated in Cyprus under a fake address, &#8230; <a href="https://financial-hacker.com/binary-options-scam-or-opportunity/" class="more-link">Continue reading<span class="screen-reader-text"> "Binary Options: Scam or Opportunity?"</span></a>]]></description>
										<content:encoded><![CDATA[<p>We&#8217;re recently getting more and more contracts for coding binary option strategies. Which gives us a <strong>slightly bad conscience</strong>, since those options are widely understood as a scheme to separate naive traders from their money. And their brokers make indeed no good impression at first look. Some are regulated in Cyprus under a fake address, others are not regulated at all. They spread <strong>fabricated stories</strong> about huge profits with robots or EAs. They are said to <strong>manipulate their price curves</strong> for preventing you from winning. And if you still do, some <strong>refuse to pay out</strong>, and eventually disappear without a trace (but with your money). That&#8217;s the stories you hear about binary options brokers. Are binary options nothing but scam? Or do they offer a <strong>hidden opportunity</strong> that even their brokers are often not aware of?<span id="more-1709"></span></p>
<p>Binary options, in their most common form, are very different to <a href="http://www.financial-hacker.com/algorithmic-options-trading/" target="_blank" rel="noopener">real options</a>. They are a bet that the price of an asset will rise or fall within a given time frame. If you win the bet, the broker pays your stake multiplied with a <strong>win payout</strong> factor in the 75%..95% range. If you lose, you pay the stake minus a possible <strong>loss payout</strong>. You&#8217;re trading not against the market, but against the broker. The broker needs you to lose, otherwise they would not make any profit. Even if they really pay out your wins, and even if they do not manipulate the price curve, they can still control your profit with their payout factors. So it seems that even if you had a winning system, the broker would just reduce the payout for making sure that you lose in the long run.</p>
<p>However this conclusion is a fallacy. It can in fact be of advantage for the broker to offer a payout that allows you to win, as long as most other traders still lose. A broker has not the freedom of arbitrarily reducing the payout. He&#8217;s competing with other brokers. But why would you want to trade binary options anyway, when you also can trade serious instruments instead? If you wanted a binary outcome, you can also achieve this by opening a <a href="http://www.financial-hacker.com/algorithmic-options-trading-2/" target="_blank" rel="noopener">Put or Call Spread</a> with real options &#8211; and this with a serious broker, much higher payout factors (even &gt; 100% in some cases) and the possibility to sell the options prematurely.</p>
<p>But aside from tax advantages in some countries, there is one single compelling reason that might make a binary options trading experiment worthwhile. Profit and trading cost of a binary option are independent of the time frame. So you can trade on very short time frames, which would be difficult, if not impossible with real options or other financial instruments. You can find a discussion of this problem in the <a href="http://www.financial-hacker.com/is-scalping-irrational/" target="_blank" rel="noopener">Scalping</a> article.</p>
<h3>Binary scalping math</h3>
<p>The required minimum win rate for binary trading can be calculated from the broker&#8217;s win and loss payout:</p>
<p style="text-align: center;">[pmath size=16]W~=~ {1-Pl}/{1+Pw-Pl}[/pmath]</p>
<p><em><strong>W</strong></em> = required win rate for break even<br />
<em><strong>Pl</strong></em> = Loss payout<br />
<em><strong>Pw</strong></em> = Win payout</p>
<p>With 85% win payout and no loss payout, you need a win rate of</p>
<p style="text-align: center;">[pmath size=16]W ~=~ 1/{1.85} ~=~ 54%[/pmath]</p>
<p>54% win rate seem to be manageable on short time frames. The transaction costs of a non-binary, conventional broker would require a much higher win rate, as in the following graph from the <a href="http://www.financial-hacker.com/is-scalping-irrational/" target="_blank" rel="noopener">Scalping</a> article:</p>
<figure id="attachment_524" aria-describedby="caption-attachment-524" style="width: 889px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2015/10/scalp11.png"><img loading="lazy" decoding="async" class="wp-image-524 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2015/10/scalp11.png" width="889" height="513" srcset="https://financial-hacker.com/wp-content/uploads/2015/10/scalp11.png 889w, https://financial-hacker.com/wp-content/uploads/2015/10/scalp11-300x173.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /></a><figcaption id="caption-attachment-524" class="wp-caption-text">Required win rate in percent vs. trade duration (non binary)</figcaption></figure>
<p>You had to win almost 80% of five-minutes trades &#8211; impossible for a trading system under normal conditions unless you enforce that win rate with some tricks, which however won&#8217;t help getting in the profit zone.</p>
<p>So,<strong> smaller trading costs on low time frames</strong> are the obvious benefit of trading binary options. With all the side benefits of low time frames, such as more data for backtests, and shorter drawdown periods in live trading. But how can we take advantage of that? There are three problems to solve.</p>
<h3>Three steps to potential binary profit</h3>
<ol>
<li>Find a strategy with a <strong>win r</strong><strong>ate</strong> that is better than the <em><strong>W</strong></em> determined with the above payout formula. But be aware that prices on small time frames are strongly feed dependent. Normally you won&#8217;t know your binary broker&#8217;s price source (if he has any at all). For being on the safe side, test with different historical price data from different serious brokers (f.i. Oanda or FXCM) and stay some percent points above the minimum <em><strong>W</strong></em>.<br />
 </li>
<li>Find a way to trade automated. Binary brokers often do not want you to do that. Consequently most do not offer a platform or API for automated trading. But they all have a web interface. So you need either a software tool (such as Zorro) that can <strong>send key strokes and mouse clicks</strong> to a website, or some other means to get your trades to the broker.<br />
  </li>
<li>Find a broker that&#8217;s halfway honest. At least one that allows you to <strong>really collect your gains</strong>. All binary brokers make it easy to deposit, but some follow the philosophy: &#8220;If you gave it to me, it&#8217;s mine.&#8221; Make test withdrawals before you deposit large amounts. Keep the account balance small. Check the broker&#8217;s opportunity to <strong>manipulate the price curve</strong>: the more customers they have and the more bets they handle, the more difficult is it to manipulate without attracting unwanted attention. Retrieve as many <strong>information</strong> as possible about your broker: Where are they really located? For some reason, fraudsters seem to be concentrated in Tel Aviv. Check what customers say about that broker &#8211; but be aware: positive statements on trader forums are often planted by the broker himself.</li>
</ol>
<p>All those issues make trading binary options sort of &#8220;messy&#8221;. However it&#8217;s the messy methods that sometimes offer the best opportunities. Ed Thorp made his first millions not with &#8216;serious trading&#8217;, but with a Blackjack strategy and with a method to estimate the value of warrants, both also considered messy and hard to calculate at that time.</p>
<h3>Step 1: The system</h3>
<p>A price curve is no random walk. At least not all of the time. Long time frames are often dominated by <a href="http://www.financial-hacker.com/build-better-strategies-part-2-model-based-systems/" target="_blank" rel="noopener">trend</a>, short time frames by <a href="http://www.financial-hacker.com/build-better-strategies-part-2-model-based-systems/" target="_blank" rel="noopener">mean reversion</a>. When transaction costs do not matter, it&#8217;s not very hard to find a system with &gt; 54% win rate on 5-minutes bars. Here&#8217;s a simple example that exploits the mean reversion tendency of short time frames (script for <a href="http://www.financial-hacker.com/hackers-tools-zorro-and-r/" target="_blank" rel="noopener">Zorro</a>):</p>
<pre class="prettyprint">var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -1;
	
	set(BINARY);
	WinPayout = 85;
	LossPayout = 0;

	set(PARAMETERS);
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	if(NumOpenLong+NumOpenShort == 0) 
	{
		LifeTime = 1;
		if(HH(TimePeriod) - priceClose() &lt; Threshold)
			enterShort();
		else if(priceClose() - LL(TimePeriod) &lt; Threshold)
			enterLong();
	}
}</pre>
<p>In the C code above we defined an individual objective() function that optimizes the system for binary trading. It measures the system performance as the number of winning trades divided by the number of losing trades. Otherwise the optimizer would hunt for the most robust profit factor, which makes no sense for binary trading.</p>
<p>The setup establishes a 5 minutes bar period, which is the time frame of our bets. We use 20 WFO cycles and let the optimizer use all CPU cores but one. This way the training run takes about 5-10 minutes for 5 years data. The BINARY flag activates binary trades, and we&#8217;re simulating a broker with 85% win payout and no loss payout.</p>
<p>We have a mean reverting system that trades whenever the current price is closer than a threshold &#8211; here, 1% of recent volatility &#8211; to its previous High or Low. The time period for determining the High and Low is the only system parameter that we optimize. You could improve the system in many ways, for instance by optimizing also the threshold, by modifying the objective() function so that it prefers systems with more trades, and by applying a filter that prevents trading in non mean-reverting market regimes. Since we bet on the price in 5 minutes, we&#8217;ve set the LifeTime of a trade to one bar. Here&#8217;s the equity curve from a 5 years walk forward test with EUR/USD:</p>
<figure id="attachment_1935" aria-describedby="caption-attachment-1935" style="width: 879px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD.png"><img loading="lazy" decoding="async" class="wp-image-1935 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD.png" width="879" height="341" srcset="https://financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD.png 879w, https://financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-768x298.png 768w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /></a><figcaption id="caption-attachment-1935" class="wp-caption-text">Binary options</figcaption></figure>
<p>The system has about 56% win rate and a notable, although not spectacular positive return. Which is not achieved by the crude mean reversion mechanism, but mostly by amplifying the small entry-exit price differences through binary trading, even though the payout is only 85%. You won&#8217;t get a similar result with conventional trades. The same system not trading binary options, but leveraged forex positions produces a very different equity curve (for testing, comment out the BINARY flag and the Payout settings in the code):</p>
<figure id="attachment_1937" aria-describedby="caption-attachment-1937" style="width: 879px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-1.png"><img loading="lazy" decoding="async" class="wp-image-1937 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-1.png" width="879" height="341" srcset="https://financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-1.png 879w, https://financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-1-300x116.png 300w, https://financial-hacker.com/wp-content/uploads/2016/12/Binary_EURUSD-1-768x298.png 768w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /></a><figcaption id="caption-attachment-1937" class="wp-caption-text">Leveraged Forex</figcaption></figure>
<p>With the same trades we have now only 40% win rate and an overall loss, since all the trade profit is eaten up by spread and commission. </p>
<h3>Step 2: Automatizing</h3>
<p>How do you let your script automatically enter a bet at the right moment? This is a technical issue unrelated to trading, but it comes up whenever you have a broker with a web based platform and no proper connection for automatizing. Here&#8217;s a code snippet for detecting the positions of [Buy] and [Sell] buttons on a website, and automated clicking them:</p>
<pre class="prettyprint">void main()
{
	int BuyX,BuyY,SellX,SellY; // button coordinates

// open the browser	
	printf("\nOpening the broker's website...");
	exec("http://financial-hacker.com/shark.htm",0,1);

// get the position of the Buy button
	printf("\nRight click on [Buy]!");
	while(wait(50)) {
		int button = mouse(&amp;BuyX,&amp;BuyY,window(""));
		if(button &amp; 2) break;
	}
// wait until right mouse key released	
	while(wait(50)) {
		int x,y,button = mouse(&amp;x,&amp;y,0);
		if(!(button &amp; 2)) break;	
	}

// get the position of the Sell button	
	printf("\nRight click on [Sell]!");
	while(wait(50)) {
		int button = mouse(&amp;SellX,&amp;SellY,window(""));
		if(button &amp; 2) break;
	}
// wait until right mouse key released	
	while(wait(50)) {
		int x,y,button = mouse(&amp;x,&amp;y,0);
		if(!(button &amp; 2)) break;	
	}

// send mouse clicks to Buy and Sell	
	printf("\nI will now click on [Buy]!");
	keys("[click %d,%d]",BuyX,BuyY);
	printf("\nI will now click on [Sell]!");
	keys("[click %d,%d]",SellX,SellY);
	printf("\nDone!");
}
</pre>
<p>Start the script, and wait until the broker&#8217;s website pops up in your browser. Then follow the instructions in Zorro&#8217;s message window. Manoever the mouse onto the &#8220;Buy&#8221; button and hit the right mouse key. Then do the same with the &#8220;Sell&#8221; button. The script will store the button positions and then use the <a href="http://manual.zorro-project.com/keys.htm" target="_blank" rel="noopener">keys</a> function to send test clicks to both positions of the active window. For testing purposes I&#8217;ve imitated a typical binary broker&#8217;s trading platform.</p>
<p><a href="http://www.financial-hacker.com/wp-content/uploads/2016/12/sharkio.png"><img loading="lazy" decoding="async" class="alignnone wp-image-1944 size-full aligncenter" src="http://www.financial-hacker.com/wp-content/uploads/2016/12/sharkio.png" width="361" height="409" srcset="https://financial-hacker.com/wp-content/uploads/2016/12/sharkio.png 361w, https://financial-hacker.com/wp-content/uploads/2016/12/sharkio-265x300.png 265w" sizes="auto, (max-width: 361px) 85vw, 361px" /></a></p>
<p>You now only need to glue together your trading script with the button clicking script, and adapt the latter to the website of your broker. This is left as an exercise to the reader. And better use improved versions &#8211; the scripts here are kept simple for demonstration purposes. As long as the script trades, make sure that the browser window stays in the foreground, or else it can not click on the buttons. For the position size, either enter a fixed size for all positions, or let your script click into the size field and send key strokes to set individual sizes.</p>
<h3>Step 3: The broker</h3>
<p>Of course I don&#8217;t want to recommend a particular binary options broker. In the end, they&#8217;re all crooks &#8211; but some are crookier than others. Finding a suited broker is, also, left as an exercise to the reader. Binary broker comparison websites are often &#8211; surprise, surprise &#8211; installed and paid by binary brokers. US citizens are normally not allowed to trade binary options with brokers that are not regulated in the US. Some brokers will accept your deposit nevertheless, but use that as pretext to refuse payout. If you&#8217;re a citizen of Israel, you might not be accepted by many binary brokers since they&#8217;re not allowed to fraud compatriots. </p>
<h3>Conclusion</h3>
<p>It&#8217;s often the &#8220;messy&#8221; and despised trade instruments that can still provide opportunities when they are correctly understood. I&#8217;ve uploaded the two scripts to the 2016 repository. You&#8217;ll need Zorro 1.52 or above for running them. When you now make huge profits with binary options, don&#8217;t forget where the money comes from: Not from the broker, but from his less fortunate customers that maybe just haven&#8217;t read the right blog.</p>
<hr />
<p><strong>Addendum:</strong> From all articles on this blog, this one attracted by far the most spam comments. From them it appears that a new lucrative business has established in the orbit of binary brokers: <strong>recovery fraud</strong>. As soon as you&#8217;ve lost your money, you&#8217;ll receive offers by &#8220;hackers&#8221; or &#8220;law firms&#8221; to recover it, for a fee of course. Where did they get your email from? Naturally from the very broker that bagged your money&#8230;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/binary-options-scam-or-opportunity/feed/</wfw:commentRss>
			<slash:comments>83</slash:comments>
		
		
			</item>
		<item>
		<title>Seventeen Trade Methods That I Don&#8217;t Really Understand</title>
		<link>https://financial-hacker.com/seventeen-popular-trade-strategies-that-i-dont-really-understand/</link>
					<comments>https://financial-hacker.com/seventeen-popular-trade-strategies-that-i-dont-really-understand/#comments</comments>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Thu, 17 Sep 2015 12:09:44 +0000</pubDate>
				<category><![CDATA[3 Most Clicked]]></category>
		<category><![CDATA[Indicators]]></category>
		<category><![CDATA[No Math]]></category>
		<category><![CDATA[Elliott waves]]></category>
		<category><![CDATA[Fibonacci]]></category>
		<category><![CDATA[Gann]]></category>
		<category><![CDATA[Grid trading]]></category>
		<category><![CDATA[Holy Grail]]></category>
		<category><![CDATA[Martingale]]></category>
		<category><![CDATA[Robot]]></category>
		<category><![CDATA[Scam]]></category>
		<category><![CDATA[Superstition]]></category>
		<category><![CDATA[Zulutrade]]></category>
		<guid isPermaLink="false">http://www.financial-hacker.com/?p=94</guid>

					<description><![CDATA[When I started with technical trading, I felt like entering the medieval alchemist scene. A multitude of bizarre trade methods and hundreds of technical indicators and lucky candle patterns promised glimpses into the future, if only of financial assets. I wondered &#8211; if a single one of them would really work, why would you need &#8230; <a href="https://financial-hacker.com/seventeen-popular-trade-strategies-that-i-dont-really-understand/" class="more-link">Continue reading<span class="screen-reader-text"> "Seventeen Trade Methods That I Don&#8217;t Really Understand"</span></a>]]></description>
										<content:encoded><![CDATA[<p>When I started with technical trading, I felt like entering the medieval alchemist scene. A multitude of <strong>bizarre trade methods</strong> and hundreds of technical indicators and lucky candle patterns promised glimpses into the future, if only of financial assets. I wondered &#8211; if a single one of them would really work, why would you need all the rest? And how can you <strong>foretell tomorrow&#8217;s price</strong> by drawing circles, angles, bats or butterflies on a chart? <span id="more-94"></span></p>
<p>There is no real answer, as the inventors of those methods usually forgot to mention &#8211; aside from some vague financial verbiage &#8211; how and why they are supposed to work, and which market pattern or inefficiency they are supposed to exploit. Often the methods are merely recipes to be followed meticulously, like the spells in ancient conjuring books. <strong>Superstition and esotericism</strong> in financial trading are approved by seemingly serious organizations such as the <a href="http://www.mta.org/" target="_blank" rel="noopener">Market Technicians Association</a>, and even trained in their certification programs! Here&#8217;s a certainly non-complete list of ways of trading that I still fail to understand.</p>
<ol>
<li><strong>Staring at Price Curves.</strong> Opening and closing positions manually without a trading system can work. When you have some information about the particular asset that the other traders don&#8217;t have. Or when you got a stroke of luck. Otherwise you can rightfully expect to lose your money at the rate of the transaction costs. In reality it&#8217;s even worse &#8211; private traders lose on average 13 pips per trade, according to FXCM statistics. The human mind can do a lot of things, but it can not identify a market inefficiency by looking at a price curve. Studies have shown that &#8216;expert traders&#8217; can not even distinguish real price curves from meaningless random numbers &#8211; something even a simple computer algorithm has no problem with. And as to luck, it indeed endows about&nbsp;35% of private traders every year with some profit or at least no loss, but it has one problem: it can end anytime.
<p><figure id="attachment_261" aria-describedby="caption-attachment-261" style="width: 686px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2015/09/random.png"><img loading="lazy" decoding="async" class="wp-image-261 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2015/09/random.png" alt="random" width="686" height="301" srcset="https://financial-hacker.com/wp-content/uploads/2015/09/random.png 686w, https://financial-hacker.com/wp-content/uploads/2015/09/random-300x132.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></a><figcaption id="caption-attachment-261" class="wp-caption-text">Which of the two price curves is real?</figcaption></figure></li>
<li><strong>Technical Analysis.</strong>&nbsp;Do traditional &#8216;technical indicators&#8217;, such as MACD, Stochastic, Ichimoku etc., really work? A study by David Aronson, described in his &#8220;Evidence-Based TA&#8221; book, suggests otherwise. None of the studied basic indicators was any better than throwing a coin. However, the study only applied the indicators to the S&amp;P500 index. The <a href="http://www.financial-hacker.com/trend-and-exploiting-it/">trend experiment</a> suggests that this index is the least predictable of the tested asset types, at least for short-term trend following. Also, Aronson only tested the basic indicators, but not complex combinations of them. So it&#8217;s still unknown whether traditional indicators do sometimes work, or not at all. And as long as this is the case, it&#8217;s not clear to me why they are so widely and naively used.</li>
<p>&nbsp;</p>
<li><strong>Elliott Waves.</strong> Ralph Nelson Elliott claimed in his 1938 published book that the prices of financial assets always move up and down in a fractal pattern of five waves. He gave many examples. And indeed you can see all sorts of waves when you stare at curves long enough. Elliott explained his waves with &#8220;mass psychology&#8221;, but was not interested in going into details. Although cycles in price curves are real, they have no reason to appear in series of five, or in any series whatsoever. Lacking any rational background, one should think that there was at least some statistical evidence of Elliott Waves &#8211; but no. No serious research has ever found any sign of them in real price curves, nor of the countless wave variants invented by Elliott&#8217;s many imitators.</li>
<p>&nbsp;</p>
<li><strong>Gann Magic.&nbsp;</strong>In the early 20th century, the trader William Delbert Gann was desperate, as he could not support his family with his trading.
<figure id="attachment_309" aria-describedby="caption-attachment-309" style="width: 248px" class="wp-caption alignright"><img loading="lazy" decoding="async" class="wp-image-309 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2015/09/gann.jpg" alt="gann" width="248" height="248" srcset="https://financial-hacker.com/wp-content/uploads/2015/09/gann.jpg 248w, https://financial-hacker.com/wp-content/uploads/2015/09/gann-150x150.jpg 150w" sizes="auto, (max-width: 248px) 85vw, 248px" /><figcaption id="caption-attachment-309" class="wp-caption-text">Gann&#8217;s Magic Square</figcaption></figure>
<p>But suddenly he discovered the way to success: Planting anecdotes that promoted himself as a genius trader, and selling esoteric trade systems and books. It seems that Gann was the ancestor of all scammers in the trading scene. He did not die rich, though, as in his late years he apparently began to believe in his own methods. He lost at the stock market almost all wealth he accumulated&nbsp;by marketing his methods. I know of no tests that found any value in his magic squares, lines, cycles, pyramids, or angles. But even today, many traders still believe in them, to the great joy of their brokers.</li>
<p>&nbsp;</p>
<li><strong> Astrology.</strong>&nbsp;It&#8217;s widely accepted as a normal trade method and discussed in many trading books. Even Perry Kaufman, in his standard reference of trading systems, published code to calculate the Jupiter-Saturn cycle! Indeed, trading would be a breeze if you could calculate tomorrow&#8217;s prices just from the positions of sun, moon, and planets. But sorry, Perry: Celestial bodies still <a href="http://unendliches.net/english/astrologie.htm" target="_blank" rel="noopener">stubbornly refuse</a> to predict earthly events. No test ever confirmed a correlation of the full moon and the EUR/USD price. Neither was Saturn ever observed dragging down the S&amp;P500 index. And contrary to popular belief, even the sun is not responsible for the change of seasons (it&#8217;s the tilt&nbsp;of the earth axis). As long as we got no <a href="http://unendliches.net/english/weiten.htm" target="_blank" rel="noopener">interstellar</a> stock exchange, trading still happens on earth.</li>
<p>&nbsp;</p>
<li><strong>Rice Candle Patterns.</strong> With names like &#8220;Three Stars in the South&#8221; or &#8220;Concealing Baby Swallow&#8221;, they bring at least some poetry into trading. Candle patterns had been developed in the 18th century by Japanese traders for predicting the local rice markets. And indeed they might have had some value back then. But even today many traders are still squinting at price charts, hoping for a lucky trade when a candle formation matches a bullish pattern in their &#8220;Get Rich with Candle Patterns&#8221; book. The TA-Lib fortunately contains indicators of all those patterns, so I could run quick tests of them with several assets, similar to the <a href="http://www.financial-hacker.com/trend-and-exploiting-it/">trend indicator test</a>. You can imagine the result. &#8211; By the way, new patterns invented by trade book authors&nbsp;&#8211; &#8220;Lizard&#8217;s Day&#8221;, &#8220;Gilligan&#8217;s Island&#8221; etc. &#8211; didn&#8217;t fare any better.</li>
<p>&nbsp;</p>
<li><strong>Fibonacci Numbers.</strong> This simple number series &#8211; 1, 2, 3, 5, 8, 13, etc. &#8211; can be found in some patterns of geometric growth. But there&#8217;s no reason to expect it in the price levels or time periods of financial assets. And indeed, it isn&#8217;t there. As far as I know, no one has ever discovered any price series property related to Fibonacci Numbers, or to Golden Ratios, Golden Squares, or Golden Whatevers derived from them. Nevertheless traders seem to like the word &#8220;Fibonacci&#8221;, maybe because it lets them imagine that they apply serious math. When a system uses Fibonacci Numbers for trade signals, you can safely assume that it would also work, and most likely better, with any other numbers.</li>
<p>&nbsp;</p>
<li><strong>Harmonic Trading Patterns.</strong> By connecting pivot points on the price curve, you can produce funny polygonal figures such as diamonds, butterflies, crabs, or bats. Their shapes predict profitable trade entry points. Or do they? I don&#8217;t know &#8211; I admit I have not yet tested a system based on trade predictions by polygonal figures. I&#8217;m only sure that harmonic trading is profitable for the tool and seminar vendors who promote it.</li>
<p>&nbsp;</p>
<li><strong>Your Trading Style.</strong> In trading books you&#8217;ll often read advices like &#8216;<em>place the stop loss at a distance that suits your trading style</em>&#8216;. This makes you wonder what Your Trading Style might be. Do you trade fast, slow, risky, greedy, or in the style of the Kamikaze? And should this style affect the distance of the stop loss? I think not. Since any parameter in a trade system has an optimal or most robust value, any other value will therefore produce a less than optimal result. If it suits your style to win rather than lose, better select your trade methods and parameters not by style, but by performance.</li>
<p>&nbsp;</p>
<li><strong>Your Trading Plan.</strong>&nbsp;You trade for increasing your fortune in three years from <strong>$5000</strong> to <strong>$500,000</strong>. So you&#8217;ve created a detailed plan by which percentage it has to grow every week. Fortunately, it&#8217;s just 3%. Unfortunately, the markets could not care less about Your Trading Plan. And if you&#8217;re following some system, your wins and losses will often have serial correlation. So when you continue trading after a loss until you reached your weekly goal, usually only your loss will grow. And the initial $5000 will become zero dollars &#8211; not in 3 years, but much faster.</li>
<p>&nbsp;</p>
<li><strong> The Holy Grail.</strong> On any trader forum you&#8217;ll find some lengthy thread about a system with miraculous profits. The thread starter has discovered the ultimate trade method. He feeds the thread periodically with reports of his impressive trade results &#8211; such as, doubling his account every month &#8211; and vague hints about his miracle algorithm and its complex math. His devotees eagerly absorb any droplet of information in their attempts to replicate the trade method &#8211; but alas, some essential ingredient is always missing. Miracles have the nasty habit of disappearing at closer look. The thread will eventually dry out when either the miraculist got broke or when the last follower has realized that he was following a Fata Morgana. If you found a miracle method where this did not happen, please let me know!</li>
<p>&nbsp;</p>
<li><strong>Robots.</strong> They are offered by anonymous vendors on countless websites. And supported by likewise anonymous users that all claim on trader forums that they have earned millions with that particular robot. Theoretically, a <a href="http://www.financial-hacker.com/build-better-strategies-part-3-the-development-process/" target="_blank" rel="noopener">correctly developed and tested</a> robot could indeed work, if algorithmic trading works at all. But apparently none is offered for sale. The simplest way to sell robots is offering a free trial period: When trades are entered at random, about 55% of users will lose during that period and 45% will win. Those will then order the robot &#8211; at least that&#8217;s the vendor&#8217;s hope.More sophisticated robot vendors provide faked trade histories or even faked live trading equity curves, like this one:
<figure id="attachment_322" aria-describedby="caption-attachment-322" style="width: 867px" class="wp-caption alignnone"><a href="http://www.financial-hacker.com/wp-content/uploads/2015/09/work8_bot.png"><img loading="lazy" decoding="async" class="wp-image-322 size-full" src="http://www.financial-hacker.com/wp-content/uploads/2015/09/work8_bot.png" alt="work8_bot" width="867" height="361" srcset="https://financial-hacker.com/wp-content/uploads/2015/09/work8_bot.png 867w, https://financial-hacker.com/wp-content/uploads/2015/09/work8_bot-300x125.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px" /></a><figcaption id="caption-attachment-322" class="wp-caption-text">Typical robot equity curve</figcaption></figure>
<p>Can you see from the above curve when this robot started selling? Hint: It&#8217;s close to the end. How to program a scam robot with an impressive faked equity curve on a verified MyFXBook<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" /> account is explained in <a href="https://www.amazon.com/dp/1546515216" target="_blank" rel="noopener">this book</a> (of course for educational purposes only!). But if you ever encounter a real person who really made&nbsp;money by buying such a robot, please notify me&#8230;</li>
<p>&nbsp;</p>
<li><strong>Book systems.</strong>&nbsp;There are countless books describing countless trade systems &#8211; and certainly not all of them are garbage. But amazingly, many of the described systems survive not even a simple backtest. Their authors often suspect this already. That&#8217;s why some &#8211; for instance, best selling trade book writer Thomas Carr &#8211; warn strongly against testing their systems because &#8220;backtests are useless anyway&#8221;. This is correct &#8211; insofar as a positive backtest does not prove that the system works. But a negative backtest means that the money you paid for the book will be the least of your worries when you really trade one of the praised systems. Almost 90% of all systems from books, forums or websites that I&#8217;ve tested were clear losers &#8211; and this could often be determined in 5 minutes.</li>
<p>&nbsp;</p>
<li><strong>Trade Copy Services.</strong>&nbsp;The best-known is <strong>Zulutrade®</strong>, but many competitors have meanwhile entered this lucrative business. The principle is always the same: Let others place your trades. Follow successful traders and copy their trading. A brilliant idea. If those successful traders really existed. And indeed, you seem to have plenty of choice on the service&#8217;s website. Select some of the Top Traders with 500% profit and impressive equity curve, place an investment, and wait for the money to roll in. After a while you will inevitably find that it rolls in the other direction. One after the other of your selected Top Traders will encounter a nasty drawdown, just after you started following them. And their equity curves now all look like the robot curve above. Damn bad luck! &#8211; Or is anything else behind it?<br />
Behind it is no scam, but simple statistics. Thousands of traders compete for followers on copy services. In the Top Traders list you&#8217;ll only find those who trade risky but had a stroke of luck so far. Because luck does not last, the Top list is changing permanently. A trader&#8217;s survival time in that list is a few weeks, maybe months &#8211; then his fortune takes a dip, and takes all his followers with it. The trader won&#8217;t mind. He just opens a new account under a new name. He has earned considerably more follower commission than he lost with his trading. Tip: Look not into the Top Traders, but into the Top Followers list (if the service dares to publish one). That might tell you something about the chance of keeping your money when copying trades.<br />
<a id="martingale"></a></li>
<p>&nbsp;</p>
<li><strong>Martingale</strong> or <strong>d&#8217;Alembert Methods.</strong> They are used by many trading robots, signal providers, and beginners in roulette: you bet on red or black and double your stake after every loss. Alternatively, you open two new positions for every lost trade. The theory is that a loss increases your win chance the next time. Unfortunately, it won&#8217;t. On the contrary, market inefficiencies can be autocorrelated, so after losing a trade there&#8217;s a good chance that you&#8217;ll also lose the next one. Although martingale systems at first seem to make steady profits &#8211; even when trades are entered at random &#8211; they will encounter a long loss streak sooner or later and wipe out the account.<br />
How long will it take until this happens? Assume that you invest 1% of your capital per trade. After a loss you double your investment: 2%, 4%, 8%, 16%, 32%&#8230; and the sixth loss will empty your account and cause a margin call. With 50% win rate and uncorrelated returns, the probability of 6 consecutive losses is <strong>0.5 <sup>6</sup>&nbsp;= 0.015625</strong>. The probability of this event not happening in n trades is <strong>(1-0.015625) <sup>n</sup></strong>, so the number of trades until the margin call probability exceeds 50% is <strong>log(0.5)/log(1-0.015625) = 44</strong>. With one trade per day, your account will last about 2 months. A higher win rate, like 90%, won&#8217;t help &#8211; the average loss is then normally also 9 times higher, so the account lifetime is still the same 2 months. Investing only 0.1% instead &#8211; $10 per $10,000 capital &#8211; would extend the average account survival time to about 17 months.</li>
<p>&nbsp;</p>
<li><strong>Deadly Accuracy.</strong> A&nbsp;99% win rate is easy &#8211; just use a 5 pips profit target and a 500 pips stop loss distance. You&#8217;ll then probably win the next 99 trades, regardless of your strategy, and will be worshipped as a god on your trader forum. Unfortunately the 100th trade will hit the stop and eat up all profit. Even worse, that fatal trade can happen anytime, even right at the beginning. You can easily identify scammers that use a high win ratio for selling their systems: their published profit curve looks like a straight upwards slope, with any trade winning about the same small amount. They usually disappear when hit by the 100th trade.<br />
<a id="grid"></a></li>
<p>&nbsp;</p>
<li><strong>Grid trading.</strong> Such a system is a special case of using a high win ratio, up to 100%. It opens many trades at a fixed price grid, and takes profit when the price crosses the next grid line. This method can indeed generate a stream of profits for a while when the prices move up and down, but don&#8217;t move too far away from their initial position. Problem is that they eventually do&#8230; How much capital would&nbsp;you need for a grid trader to survive such a price move?<br />
Assume that you have <strong>n</strong> open trades and the price moves by <strong>x</strong> pips, <strong>x</strong> being much larger than the grid size. The move will then increase the balance by x pips and reduce the open trade value by about <strong>n/2 * x</strong> pips, causing an overall equity drawdown of <strong>(n/2-1) * x</strong> pips. On a Forex account with 10 mini lots trade size, 1 $ pip cost, and an average of 20 open trades, a 500 pips (5 cents) price move produces a <strong>9*10*500*1$ = 45,000 $</strong> drawdown. Such moves can occur several times per year.&nbsp;More capital and smaller trade sizes can delay, but not avoid that event.<br />
It&#8217;s easy to tweak grid trading systems for surviving any backtest, so they are often found in trade robots and on trade copy services. There are few exceptions where grid trading can make sense &#8211; for instance when runaway prices are hedged with some method, or when the price movement is limited by external factors such as a price cap.</li>
</ol>
<hr>
<p>Looking at all those methods it seems not really surprising that most traders lose money. But maybe I&#8217;m mistaken &#8211; if you have some solid evidence that one of the above methods does in fact work, please let me know!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/seventeen-popular-trade-strategies-that-i-dont-really-understand/feed/</wfw:commentRss>
			<slash:comments>25</slash:comments>
		
		
			</item>
	</channel>
</rss>
