<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Custom Indicators: Tracing Techniques]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/2775/" />
	<updated>2012-02-09T12:19:47Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/2775/custom-indicators-tracing-techniques/</id>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/12401/#p12401" />
			<content type="html"><![CDATA[<p>You can use Export-&gt;Indicators from FSB main menu to export a spreadsheet with all bar data and indicator data. You can also use the Command Console to see indicator values for a chosen bar.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2012-02-09T12:19:47Z</updated>
			<id>https://forexsb.com/forum/post/12401/#p12401</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11692/#p11692" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>dr.B wrote:</cite><blockquote><p>Thanks Krog for all this work again <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>I will have to play with this to fully understand it<br />when i look at coding, i tend to follow the logic but the structure or the grammar of it is just eluding me (for now) <br />i will try not to ask for too much of your time, as it seems like you are helping everyone... i like the Gann project you are working on, it looks promising. <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /><br />one question,&nbsp; is it possible to set the a stop loss to an indicator value?&nbsp; what i have in mind is to use Ross Hook value as a sl and add extra few pips for protection</p></blockquote></div><p>Moved to new thread:<br /><a href="http://forexsb.com/forum/topic/2822/using-indicator-as-stop-loss/">http://forexsb.com/forum/topic/2822/usi … stop-loss/</a></p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-12-01T19:02:57Z</updated>
			<id>https://forexsb.com/forum/post/11692/#p11692</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11374/#p11374" />
			<content type="html"><![CDATA[<p>Technique 3: Use Visual Studio</p><p>This is the most detailed way to trace, but it takes the most work and uses Visual Studio. You can download FSB source code from github (see another thread for that). </p><p>Add you custom indicator to the Indicators folder.</p><p>Remove &quot;CustomIndicator = true&quot;.</p><p>Open Solution Explorer, open Indicator Base &gt; Indicator Store.cs</p><p>Add to the method AddOriginalIndicators:<br /></p><div class="codebox"><pre><code>        static void AddOriginalIndicators()
        {
            // add with your indicator&#039;s name and class
            originalIndicators.Add(&quot;ADX 1 krog&#039;s example&quot;, new ADX_1(SlotTypes.NotDefined));
            originalIndicators.Add(&quot;Accelerator Oscillator&quot;, new Accelerator_Oscillator(SlotTypes.NotDefined));</code></pre></div><p>Add your data to the Data folder for your Visual Studio FSB project. Then you can add breakpoints to your indicator and gets lots of advanced tracing functionality from Visual Studio.</p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-11-14T02:13:59Z</updated>
			<id>https://forexsb.com/forum/post/11374/#p11374</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11373/#p11373" />
			<content type="html"><![CDATA[<p>Technique 2: Pop Up Alert Box&nbsp; (post 2 of 2 posts)</p><br /><p>6. flags for crashes<br />Sometimes you get a crash or an error message that is not clear. In this case, it&#039;s helpful to use flags to find what line the error happens. I use the MessageBox technique, with string variable set to &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, etc. If I see MessageBox with &quot;B&quot;, then the error, I know it is some line between &quot;B&quot; and &quot;C&quot;.<br /></p><div class="codebox"><pre><code>            // verify can enter main for loop
            MessageBox.Show(&quot;A&quot;, &quot;Add your title here&quot;, MessageBoxButtons.OK);

            for (int bar = 1; bar &lt; Bars; bar++)
            {
                double trueRange = Math.Max(High[bar], Close[bar - 1]) - Math.Min(Low[bar], Close[bar - 1]);
 
                if (trueRange &lt; Point)
                    trueRange = Point;
                // verify can pass setting trueRange
                MessageBox.Show(&quot;B&quot;, &quot;Add your title here&quot;, MessageBoxButtons.OK); 

                double deltaHigh = High[bar] - High[bar - 1];
                double deltaLow  = Low[bar - 1] - Low[bar];

                // verify can pass setting deltaHigh and deltaLow
                MessageBox.Show(&quot;C&quot;, &quot;Add your title here&quot;, MessageBoxButtons.OK); 

                if (deltaHigh &gt; 0 &amp;&amp; deltaHigh &gt; deltaLow)
                    DIPos[bar] = 100 * deltaHigh / trueRange;
                else
                    DIPos[bar] = 0;
 
                // verify can pass setting DIPos
                MessageBox.Show(&quot;D&quot;, &quot;Add your title here&quot;, MessageBoxButtons.OK); 

                if (deltaLow &gt; 0 &amp;&amp; deltaLow &gt; deltaHigh)
                    DINeg[bar] = 100 * deltaLow / trueRange;
                else
                    DINeg[bar] = 0;

                // verify can pass setting DIPos
                MessageBox.Show(&quot;E&quot;, &quot;Add your title here&quot;, MessageBoxButtons.OK); 

            }

            // If you see F after a few boxes, for loop is probably exiting early
            MessageBox.Show(&quot;F&quot;, &quot;Add your title here&quot;, MessageBoxButtons.OK); </code></pre></div><br /><p>I did not add the if clauses for a bar; usually a bad line will throw an error the first time it&#039;s run. If that does not find it, then you can add the if clauses for greater than.</p><p>if (bar &gt; 1000) {</p><p>Change the bar number to figure out what bar is causing the problem (Or cut off data in Data Horizon).</p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-11-14T02:00:43Z</updated>
			<id>https://forexsb.com/forum/post/11373/#p11373</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11372/#p11372" />
			<content type="html"><![CDATA[<p>Technique 2: Pop Up Alert Box&nbsp; (post 1 of 2 posts)</p><p>Sometimes I want to see more than one value at a time. Or, if the indicator is crashing, I want to see how far it gets. Or, I want to see the trace at one particular bar. In these cases, I use a pop up alert, it&#039;s helpful.</p><p>1. import Alert Box<br />2. create a string to display info<br />3. add MessageBox call<br />4. add if conditions<br />5. run<br />6. flags for crashes</p><br /><p>1. import Alert Box</p><p>At the top of the indicator, look for the lines with &quot;using ...&quot;. They&#039;re usually at the top, under the comments.<br />In ADX, they&#039;re at lines 8 and 9.<br /></p><div class="codebox"><pre><code>using System;
using System.Drawing;</code></pre></div><p>Add the import statement &quot;using System.Windows.Forms;&quot; as:<br /></p><div class="codebox"><pre><code>using System;
using System.Drawing;
using System.Windows.Forms;</code></pre></div><br /><p>2. create a string to display info</p><p>Create a string variable, then set it&#039;s value to whatever you want to see. Most of the variables in the indicator are int, double, bool, or date, so you have to call .ToString().<br />I add a label, makes it easier to read. Example from ADX:<br /></p><div class="codebox"><pre><code>                double deltaHigh = High[bar] - High[bar - 1];
                double deltaLow  = Low[bar - 1] - Low[bar];
                // label, then the value to trace
                string s = &quot;deltaHigh = &quot; + deltaHigh.ToString();</code></pre></div><p>If it is an array, with [], use iBar or bar, in brackets:<br /></p><div class="codebox"><pre><code>                double deltaHigh = High[bar] - High[bar - 1];
                double deltaLow  = Low[bar - 1] - Low[bar];
                // label, then the value to trace
                string s = &quot;High at &quot; + bar.ToString() + &quot; = &quot; + High[bar].ToString();</code></pre></div><p>Example with 2 variables, DIPos and DINeg at each bar:<br /></p><div class="codebox"><pre><code>                if (deltaLow &gt; 0 &amp;&amp; deltaLow &gt; deltaHigh)
                    DINeg[bar] = 100 * deltaLow / trueRange;
                else
                    DINeg[bar] = 0;

                string s = bar.ToString() + &quot;:  DIPos: &quot; + DIPos[bar].ToString() + &quot;; &quot;;
                s += &quot;DINeg: &quot; + DINeg[bar].ToString();
                // will look like:   19011: DIPos: .0034; DINeg: -.0019</code></pre></div><br /><p>3. add MessageBox call<br />Add one line after setting string variable. String variable goes first. <br /></p><div class="codebox"><pre><code>                string s = bar.ToString() + &quot;:  DIPos: &quot; + DIPos[bar].ToString() + &quot;; &quot;;
                s += &quot;DINeg: &quot; + DINeg[bar].ToString();
                MessageBox.Show(s, &quot;Add your own title here&quot;, MessageBoxButtons.OK);</code></pre></div><p>There are other types of MessageBox you can use. I Use .OK because it&#039;s easy.</p><br /><br /><p>4. add if conditions<br />If you add your alert in the main for loop, the alert will popup on each bar. If you have 10,000 bars, it will pop up 10,000 times. It&#039;s better to focus on one bar you want, add an if condition, it only pops up once. This example only shows info on bar 1999.<br /></p><div class="codebox"><pre><code>                string s = bar.ToString() + &quot;:  DIPos: &quot; + DIPos[bar].ToString() + &quot;; &quot;;
                s += &quot;DINeg: &quot; + DINeg[bar].ToString();

        if (bar == 1999)
        {
              MessageBox.Show(s, Add your own title here&quot;, MessageBoxButtons.OK);
        }</code></pre></div><br /><br /><p>5. run<br />When you add your indicator, the Alert boxes will pop up. If you change a parameter, it will pop up. I think there are 3 that will pop up in total.</p><p>If you forgot the if clause in step 4. and don&#039;t want to click OK 30,000 times, I don&#039;t know. I go to Task Manager to close FSB, add the if clause to my indicator, then start over.</p><br /><p>6. flags for crashes<br />In next post</p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-11-14T01:22:33Z</updated>
			<id>https://forexsb.com/forum/post/11372/#p11372</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11364/#p11364" />
			<content type="html"><![CDATA[<p>If you don&#039;t want to copy and paste a Component, or if your Components are already at 6, as:<br /></p><div class="codebox"><pre><code>            // Saving the components
            Component = new IndicatorComp[6];</code></pre></div><p>Then, choose a Component that has .DataType&nbsp; &nbsp;= IndComponentType.IndicatorValue; and set it&#039;s value to adTrace. Choose one that you are not interested in for tracing or debugging.</p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-11-13T18:57:47Z</updated>
			<id>https://forexsb.com/forum/post/11364/#p11364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11362/#p11362" />
			<content type="html"><![CDATA[<p>Technique 1: adTrace and Display in Dynamic Values</p><p>I use a text editor, this is a simple technique for one or more values, and is quick.</p><p>1. create an array to keep the values for each iBar iteration<br />2. set adTrace[iBar] to value<br />3. add or modify a component in the Component = new IndicatorComp[]; section<br />4. run and mouse over bars to see values</p><p>This example uses ADX indicator, renamed and with &quot;CustomIndicator = true&quot;. </p><p>1. create an array to keep the values for each iBar iteration</p><p>At the start of Calculate, you should Reading the Parameters, then Calculation. Usually there are some arrays created. In ADX, it looks like:<br /></p><div class="codebox"><pre><code>            double[] DIPos = new double[Bars];
            double[] DINeg = new double[Bars];

            for (int bar = 1; bar &lt; Bars; bar++)</code></pre></div><p>Be sure you add your array before the &quot;for&quot; line. I call my array &quot;adTrace&quot;, and any more I add 1, like &quot;adTrace1&quot;, &quot;adTrace2&quot;, etc. To add:<br /></p><div class="codebox"><pre><code>            double[] DIPos = new double[Bars];
            double[] DINeg = new double[Bars];
            double[] adTrace = new double[Bars];

            for (int bar = 1; bar &lt; Bars; bar++)</code></pre></div><br /><p>2. set adTrace[iBar] (or adTrace[bar]) to value</p><p>If you have unexpected values, usually one variable at some step is getting an unexpected value. Sometimes it&#039;s not set, so it&#039;s 0; the sign may be wrong; it&#039;s getting the price value from the wrong bar, etc. Many reasons, you just want to check one.<br />In ADX, I see variable &quot;deltaHigh&quot; is used, but not displayed. I want to check deltaHigh is what I expect.</p><p>Find these lines:<br /></p><div class="codebox"><pre><code>                if (trueRange &lt; Point)
                    trueRange = Point;
 
                double deltaHigh = High[bar] - High[bar - 1];
                double deltaLow  = Low[bar - 1] - Low[bar];
 
                if (deltaHigh &gt; 0 &amp;&amp; deltaHigh &gt; deltaLow)
                    DIPos[bar] = 100 * deltaHigh / trueRange;</code></pre></div><p>Add adTrace[bar]:<br /></p><div class="codebox"><pre><code>                if (trueRange &lt; Point)
                    trueRange = Point;
 
                double deltaHigh = High[bar] - High[bar - 1];
                double deltaLow  = Low[bar - 1] - Low[bar];

                adTrace[bar] = deltaHigh;
 
                if (deltaHigh &gt; 0 &amp;&amp; deltaHigh &gt; deltaLow)
                    DIPos[bar] = 100 * deltaHigh / trueRange;</code></pre></div><br /><p>3. add or modify a component in the Component = new IndicatorComp[]; section<br />Put adTrace in a Component, then you can see the trace values on the chart, the same as any other indicator value.<br />Look for this line:<br /></p><div class="codebox"><pre><code>            // Saving the components
            Component = new IndicatorComp[5];</code></pre></div><p>Increase the number in [] by one:<br /></p><div class="codebox"><pre><code>            // Saving the components
            Component = new IndicatorComp[6];</code></pre></div><p>Copy and Paste one of the Component blocks. Change the number in [] to previous step - 1&nbsp; (eg, 6 - 1 = 5)<br /></p><div class="codebox"><pre><code>            Component[0] = new IndicatorComp();
            Component[0].CompName   = &quot;ADX&quot;;
            Component[0].DataType   = IndComponentType.IndicatorValue;
            Component[0].ChartType  = IndChartType.Line;
            Component[0].ChartColor = Color.Blue;
            Component[0].FirstBar   = firstBar;
            Component[0].Value      = ADX;

            //  Copy and Paste Component[0], then change [0] to [5] 
            Component[5] = new IndicatorComp();
            Component[5].CompName   = &quot;ADX&quot;;
            Component[5].DataType   = IndComponentType.IndicatorValue;
            Component[5].ChartType  = IndChartType.Line;
            Component[5].ChartColor = Color.Blue;
            Component[5].FirstBar   = firstBar;
            Component[5].Value      = ADX;</code></pre></div><p>Change the properties as set CompName to &quot;adTrace&quot;, set Value to adTrace, and ChartType to .NoChart:<br /></p><div class="codebox"><pre><code>            Component[5] = new IndicatorComp();
            Component[5].CompName   = &quot;adTrace&quot;;
            Component[5].DataType   = IndComponentType.IndicatorValue;
            Component[5].ChartType  = IndChartType.NoChart;
            Component[5].ChartColor = Color.Blue;
            Component[5].FirstBar   = firstBar;
            Component[5].Value      = adTrace;</code></pre></div><p>(if there is &quot;ShowDynamicInfo&quot;, be sure it is set to &quot;true&quot;)</p><br /><br /><p>4. run and mouse over bars to see values</p><p>Save your file. Recompile Custom Indcators (Ctrl + I&nbsp; &nbsp;or Tools &gt; Custom Indicators &gt; Reload the Custom Indicators).<br />Add your indicator to a strategy.<br />Open the Chart.<br />Mouse over bars, and review Indicator Values on the right.</p><p><a href="http://postimage.org/image/jdb3urpax/"><span class="postimg"><img src="http://s12.postimage.org/jdb3urpax/ad_Trace.jpg" alt="http://s12.postimage.org/jdb3urpax/ad_Trace.jpg" /></span></a><br />(img also attached below)</p><p>Now you can be sure deltaHigh is not always 0; manually calculate the bar&#039;s high - previous bar&#039;s high and verify they match; use common sense it is a reasonable number, like a few pips, not a wild value like 23,342,011.3489348.</p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-11-13T18:46:43Z</updated>
			<id>https://forexsb.com/forum/post/11362/#p11362</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Custom Indicators: Tracing Techniques]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/11361/#p11361" />
			<content type="html"><![CDATA[<p>To code an indicator, you have to be able to &quot;trace&quot;. This means seeing what variables are in the lines of your code. First step, trace values in the calculation to be sure they are correct at each step. This thread is to discuss some tracing techniques. I have a couple, please feel welcome to add your favorites.</p>]]></content>
			<author>
				<name><![CDATA[krog]]></name>
				<uri>https://forexsb.com/forum/user/1692/</uri>
			</author>
			<updated>2011-11-13T18:25:01Z</updated>
			<id>https://forexsb.com/forum/post/11361/#p11361</id>
		</entry>
</feed>
