<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — MQL and nested if statements]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/6476/" />
	<updated>2017-01-26T20:04:38Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/6476/mql-and-nested-if-statements/</id>
		<entry>
			<title type="html"><![CDATA[Re: MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41189/#p41189" />
			<content type="html"><![CDATA[<p>This has been like a masterclass, lessons learnt and chart-art finally corresponds to what I had in mind. Thank you, Miroslav!</p>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2017-01-26T20:04:38Z</updated>
			<id>https://forexsb.com/forum/post/41189/#p41189</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41181/#p41181" />
			<content type="html"><![CDATA[<p>The only reason I touch MQL is to make FSB working with MT. <br />However, not the programming language is the problem but the MT API (the functions they provide for working with the orders and the environment)</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2017-01-26T11:25:20Z</updated>
			<id>https://forexsb.com/forum/post/41181/#p41181</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41180/#p41180" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>footon wrote:</cite><blockquote><p>Do I have to assign empty value or null to <strong>IndComponentType_OpenLongPrice</strong> and <strong>IndComponentType_OpenShortPrice</strong> if those if statements are not satisified?</p></blockquote></div><p>You have to. Other option is to set the array to zero at the beginning with: ArrayInitialize(Component[1].Value,0);</p><p>In MQL when you create an array, it occupies memory with the corresponding size. However it doesn&#039;t initialize it. As a result, if there are any old numbers there left from other arrays or whatever variables, they will appear in your new array and will cause bugs.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2017-01-26T11:21:31Z</updated>
			<id>https://forexsb.com/forum/post/41180/#p41180</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41179/#p41179" />
			<content type="html"><![CDATA[<p>Will try this in the evening and post the code if my art is not accepted by the audience (metaquotes art critics <img src="https://forexsb.com/forum/img/smilies/wink.png" width="15" height="15" alt="wink" /> )</p>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2017-01-26T11:14:53Z</updated>
			<id>https://forexsb.com/forum/post/41179/#p41179</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41177/#p41177" />
			<content type="html"><![CDATA[<p><img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Experience with mql has made me prepare for the worst, that&#039;s why my approach seems to base on the negative side.</p><p>What I&#039;m seeing - indi uses around 50 bars and the first value calculated from that point gets dragged into current bar. Why?</p><p>[url]<span class="postimg"><img src="http://s30.postimg.org/omz1laqv5/bal.jpg" alt="http://s30.postimg.org/omz1laqv5/bal.jpg" /></span>[/url]</p><br /><br /><p>Do I have to assign empty value or null to <strong>IndComponentType_OpenLongPrice</strong> and <strong>IndComponentType_OpenShortPrice</strong> if those if statements are not satisified?</p><p>Like this:</p><div class="codebox"><pre><code>                                      if (nosignal[bar] != 1)
                        {
                            if (Data.Open[bar] &lt; value[bar])
                            {
                                Component[1].Value[bar] = value[bar];
                            }
                            else if (Data.Open[bar] &gt; value[bar])
                            {
                                Component[2].Value[bar] = value[bar];
                            }
                        }
                                                 else if (nosignal[bar] == 1)
                                                 {
                            Component[1].Value[bar] =  0;
                            Component[2].Value[bar] = 0;
                         }</code></pre></div><p>I remember now it is not the first time I get entry price or entry allowance values dragged to next bars, even though it shouldn&#039;t do it.</p>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2017-01-26T11:12:42Z</updated>
			<id>https://forexsb.com/forum/post/41177/#p41177</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41167/#p41167" />
			<content type="html"><![CDATA[<p>The problem must not be in the &quot;if&quot; statements. </p><p>Please post the full code. </p><p>...</p><p>Because I&#039;m an absolute programming maniac, I must say that the problem may be other.<br />The programming is an art. We have to be positive and dedicated to make it as good as possible and to expect positive results.</p><p>By looking at that line:<br /></p><div class="codebox"><pre><code>if (nosignal[bar] != 1) //take only first signal</code></pre></div><p> <br />I see a double negation. It is difficult to expect good results when we approach with a negativism <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" />.</p><p>So I would write this in that way:<br /><strong>nosignal</strong> can be <strong>signal</strong> or isSignalAllowed, or signalBar... where I can store values that allow the entry.<br />The &quot;!=&quot; may be replaced with &quot;==&quot; (of course if the logic allows)<br />These make the line looking as:</p><div class="codebox"><pre><code>    if (signal[bar] == 0)</code></pre></div><p>With the positive approach we will find the programming easier and will have more fun.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2017-01-26T07:13:45Z</updated>
			<id>https://forexsb.com/forum/post/41167/#p41167</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[MQL and nested if statements]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/41162/#p41162" />
			<content type="html"><![CDATA[<p>I&#039;ve nested 2 if-statements into 1. No matter what I do, I get entry values taken from 2 days back...</p><p>It can&#039;t be normal, can it? Because current indi value is correct, therefore when condition is satisfied, it should mark the same indi value as the entry price. But no, MT shows value, which was correct 2 days ago!</p><p>A non-working example:<br /></p><div class="codebox"><pre><code>if (ListParam[0].Text == &quot;Continous entry&quot;) //entry condition
                    {
                        if (nosignal[bar] != 1) //take only first signal
                        {
                            if (Data.Open[bar] &lt; value[bar]) //if open price below indi value, set up long
                            {
                                Component[1].Value[bar] = value[bar]; //long entry value
                            }
                            else if (Data.Open[bar] &gt; value[bar]) //if open price above indi value, set up short
                            {
                                Component[2].Value[bar] = value[bar]; //short entry value
                            }
                        }
                    }</code></pre></div><br /><p>And this example below works as I get the correct/current numbers on dash.</p><div class="codebox"><pre><code>if (ListParam[0].Text == &quot;Continous entry&quot;)
                    {
                        Component[1].Value[bar] = value[bar];
                            
                    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2017-01-25T21:19:25Z</updated>
			<id>https://forexsb.com/forum/post/41162/#p41162</id>
		</entry>
</feed>
