{"id":1018,"date":"2024-11-15T14:21:17","date_gmt":"2024-11-15T14:21:17","guid":{"rendered":"https:\/\/algobuilderx.press\/?p=1018"},"modified":"2024-11-15T14:21:17","modified_gmt":"2024-11-15T14:21:17","slug":"how-to-use-negative-values-in-algobuilderx","status":"publish","type":"post","link":"https:\/\/news.algobuilderx.com\/?p=1018","title":{"rendered":"How to Use Negative Values in AlgoBuilderX"},"content":{"rendered":"\n<p>In this tutorial, we\u2019ll explore how to use <strong>negative values<\/strong> in AlgoBuilderX, a feature that can be applied across various blocks to manage conditions effectively. For this article, we\u2019ll focus specifically on an example using the <strong>Condition<\/strong> block, where we\u2019ll set up a rule to close trades when the account\u2019s net unrealized Profit &amp; Loss reaches -100\u20ac. We\u2019ll use the<strong> Account Profit<\/strong> parameter in the Condition block and go over how to select the <strong>right operator<\/strong> to achieve the desired outcome.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-create-a-condition-to-monitor-net-profit-loss\">Step 1: Create a Condition to Monitor Net Profit\/Loss<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add the Condition Block<\/strong><br>Start by adding a <strong>Condition<\/strong> block to your workspace.<\/li>\n\n\n\n<li><strong>Select Account and Profit<\/strong><br>Within the Condition block, choose <strong>Account<\/strong> and then <strong>Profit<\/strong> as the parameter. This profit refers to the <strong>Unrealized Net<\/strong> value in cTrader, representing the account\u2019s unrealized profit or loss, including expenses such as commissions and swaps. It can therefore be either a positive or a negative number.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"876\" height=\"357\" src=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_5OQo06I2XU-1.png\" alt=\"\" class=\"wp-image-1022\" srcset=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_5OQo06I2XU-1.png 876w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_5OQo06I2XU-1-300x122.png 300w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_5OQo06I2XU-1-768x313.png 768w\" sizes=\"(max-width: 876px) 100vw, 876px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-set-the-negative-reference-value\">Step 2: Set the Negative Reference Value<\/h3>\n\n\n\n<p>We want to monitor when the unrealized profit drops to -100\u20ac, so we select <strong>Values<\/strong> as the comparison operator on the right of the Condition block and enter <strong>-100<\/strong> as the reference value.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"843\" height=\"350\" src=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_8OMmQjlXE2-1.png\" alt=\"\" class=\"wp-image-1023\" srcset=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_8OMmQjlXE2-1.png 843w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_8OMmQjlXE2-1-300x125.png 300w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_8OMmQjlXE2-1-768x319.png 768w\" sizes=\"(max-width: 843px) 100vw, 843px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-understanding-operators-with-negative-numbers\">Step 3: Understanding Operators with Negative Numbers<\/h3>\n\n\n\n<p>The \u201c<strong>More than<\/strong>\u201d and \u201c<strong>Less than<\/strong>\u201d operators work differently with negative numbers, so it\u2019s important to choose the correct operator to get the desired behavior.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>More than (&gt;):<\/strong> If we set \u201cMore than -100,\u201d the condition is met when the unrealized profit is greater than -100, meaning it includes values <strong>from -99 up to zero and all positive values<\/strong>. This is <strong>not<\/strong> what we want to identify losses.<\/li>\n\n\n\n<li><strong>Less than (&lt;):<\/strong> To monitor when the unrealized profit falls to -100 or lower, we select the <strong>Less than<\/strong> operator. This allows us to identify values <strong>more negative than -100, such as -101, -102, etc.<\/strong>, indicating that losses are increasing.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Example Explained:<\/strong> With a negative value and the \u201cLess than\u201d operator, we\u2019re identifying numbers more negative than -100. Conversely, with \u201cMore than,\u201d we monitor values approaching zero, i.e., less negative than -100.<\/p>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/negative-values-1.png\" alt=\"\" class=\"wp-image-1024\" srcset=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/negative-values-1.png 800w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/negative-values-1-300x113.png 300w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/negative-values-1-768x288.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-choose-the-less-than-operator-in-the-condition-block\">Step 4: Choose the &#8220;Less than&#8221; Operator in the Condition Block<\/h3>\n\n\n\n<p>Now that we\u2019ve understood how the operators work with negative values, it\u2019s time to apply this knowledge to our Condition block. To ensure that the condition activates when the account\u2019s Profit &amp; Loss reaches or goes below -100\u20ac, we must select the <strong>\u201cLess than\u201d<\/strong> operator. This ensures that the condition triggers not only at -100\u20ac but also for any value more negative, such as -101\u20ac, -102\u20ac, and beyond.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"831\" height=\"366\" src=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/image-1-1.png\" alt=\"\" class=\"wp-image-1025\" srcset=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/image-1-1.png 831w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/image-1-1-300x132.png 300w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/image-1-1-768x338.png 768w\" sizes=\"(max-width: 831px) 100vw, 831px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-5-complete-the-condition-to-close-trades\">Step 5: Complete the Condition to Close Trades<\/h3>\n\n\n\n<p>After setting <strong>Account &#8211; Profit &lt; -100<\/strong>, link this block to a <strong>Close Trades<\/strong> block. This way, when unrealized profit falls below -100, the condition is met, and the Close Trades block will be activated, closing all active trades.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"533\" src=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_pMwbKvXycY-1-1024x533.png\" alt=\"\" class=\"wp-image-1026\" srcset=\"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_pMwbKvXycY-1-1024x533.png 1024w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_pMwbKvXycY-1-300x156.png 300w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_pMwbKvXycY-1-768x400.png 768w, https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/chrome_pMwbKvXycY-1.png 1052w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"summary\">Summary<\/h3>\n\n\n\n<p>Using negative values in the Condition block requires a clear understanding of how operators work with negative numbers. Be sure to select the <strong>Less than<\/strong> operator if you want to monitor increasing losses, as in the example of this tutorial. With this approach, you can automate account loss control on AlgoBuilderX and close positions upon reaching a set threshold.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we\u2019ll explore how to use negative values in AlgoBuilderX, a feature that can be applied across various blocks to manage conditions effectively. For this article, we\u2019ll focus specifically on an example using the Condition block, where we\u2019ll set up a rule to close trades when the account\u2019s net unrealized Profit &amp; Loss [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":1027,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","inline_featured_image":false,"footnotes":""},"categories":[19],"tags":[101,102,103,104,105,32],"class_list":["post-1018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-equity","tag-how-to","tag-loss","tag-negative-values","tag-profit","tag-tutorial"],"featured_image_src":"https:\/\/news.algobuilderx.com\/wp-content\/uploads\/2024\/11\/featuredimage-1.png","author_info":{"display_name":"Matteo","author_link":"https:\/\/news.algobuilderx.com\/author\/matteo"},"_links":{"self":[{"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=\/wp\/v2\/posts\/1018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1018"}],"version-history":[{"count":0,"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=\/wp\/v2\/posts\/1018\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=\/wp\/v2\/media\/1027"}],"wp:attachment":[{"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/news.algobuilderx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}