<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Candle Color Indicator Edit]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/6080/" />
	<updated>2016-06-05T19:48:46Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/6080/candle-color-indicator-edit/</id>
		<entry>
			<title type="html"><![CDATA[Re: Candle Color Indicator Edit]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/36462/#p36462" />
			<content type="html"><![CDATA[<p>Interesting, i didnt know in FSB only defining long position. I understood now. Thank you footon!</p>]]></content>
			<author>
				<name><![CDATA[santaferes]]></name>
				<uri>https://forexsb.com/forum/user/9103/</uri>
			</author>
			<updated>2016-06-05T19:48:46Z</updated>
			<id>https://forexsb.com/forum/post/36462/#p36462</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Candle Color Indicator Edit]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/36447/#p36447" />
			<content type="html"><![CDATA[<p>You don&#039;t need to do anything, you select it by logic. You define only long condition in FSB, so you want black bar for longt, therefore you choose &quot;Bearish Candle formed&quot;.</p>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2016-06-05T12:09:08Z</updated>
			<id>https://forexsb.com/forum/post/36447/#p36447</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Candle Color Indicator Edit]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/36446/#p36446" />
			<content type="html"><![CDATA[<p>Hi friends,</p><p>I am trying to edit Candle Color indicator. I only need to make buy/sell signals just opposite of the default. In default bullish candle giving buy (long) signal, bearish candle giving sell (short) signal. I need just opposite, bullish candle gives sell signal and bearish candle gives buy signal. How can i do it by editing this indicator code? Actually i did it but somehow lost how i did it and can not find again after all trials. Can somebody tell it me please.</p><div class="codebox"><pre><code>//==============================================================
// Forex Strategy Builder
// Copyright © Miroslav Popov. All rights reserved.
//==============================================================
// THIS CODE IS PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
//==============================================================

using System;
using System.Drawing;
using ForexStrategyBuilder.Infrastructure.Entities;
using ForexStrategyBuilder.Infrastructure.Enums;
using ForexStrategyBuilder.Infrastructure.Interfaces;

namespace ForexStrategyBuilder.Indicators.Custom
{
    public class CandleColor : Indicator
    {
        public CandleColor()
        {
            IndicatorName = &quot;Candle Color&quot;;
            PossibleSlots = SlotTypes.OpenFilter | SlotTypes.CloseFilter;

            IndicatorAuthor = &quot;Miroslav Popov&quot;;
            IndicatorVersion = &quot;1.1&quot;;
            IndicatorDescription = &quot;Detects bullish and bearish candles.&quot;;
        }

        public override void Initialize(SlotTypes slotType)
        {
            SlotType = slotType;

            // The ComboBox parameters
            IndParam.ListParam[0].Caption = &quot;Logic&quot;;
            IndParam.ListParam[0].ItemList = new[]
            {
                &quot;Bullish Candle formed&quot;,
                &quot;Bearish Candle formed&quot;
            };
            IndParam.ListParam[0].Index = 0;
            IndParam.ListParam[0].Text = IndParam.ListParam[0].ItemList[IndParam.ListParam[0].Index];
            IndParam.ListParam[0].Enabled = true;
            IndParam.ListParam[0].ToolTip = &quot;Gives a signal when a candle is formed.&quot;;

            IndParam.ListParam[1].Caption = &quot;Base price&quot;;
            IndParam.ListParam[1].ItemList = new[]{&quot;Bar range&quot;};
            IndParam.ListParam[1].Index = 0;
            IndParam.ListParam[1].Text = IndParam.ListParam[1].ItemList[IndParam.ListParam[1].Index];
            IndParam.ListParam[1].Enabled = true;
            IndParam.ListParam[1].ToolTip = &quot;The indicator uses the bar range.&quot;;

            // The NumericUpDown parameters
            IndParam.NumParam[0].Caption = &quot;Min body height [pips]&quot;;
            IndParam.NumParam[0].Value = 5;
            IndParam.NumParam[0].Min = 1;
            IndParam.NumParam[0].Max = 200;
            IndParam.NumParam[0].Enabled = true;
            IndParam.NumParam[0].ToolTip = &quot;Minimum required body height in pips.&quot;;

            IndParam.NumParam[1].Caption = &quot;Consecutive candles&quot;;
            IndParam.NumParam[1].Value = 1;
            IndParam.NumParam[1].Min = 1;
            IndParam.NumParam[1].Max = 10;
            IndParam.NumParam[1].Enabled = true;
            IndParam.NumParam[1].ToolTip = &quot;Gives a signal if there are consecutive candles.&quot;;

            // The CheckBox parameters
            IndParam.CheckParam[0].Caption = &quot;Use previous bar value&quot;;
            IndParam.CheckParam[0].Enabled = true;
            IndParam.CheckParam[0].ToolTip = &quot;Use the indicator value from the previous bar.&quot;;
        }

        public override void Calculate(IDataSet dataSet)
        {
            DataSet = dataSet;

            // Reading the parameters
            var minHeight   = (int) IndParam.NumParam[0].Value;
            var consecutive = (int) IndParam.NumParam[1].Value;
            int previous = IndParam.CheckParam[0].Checked ? 1 : 0;

            int firstBar = 2 + consecutive + previous;

            var whiteCandles = new int[Bars];
            var blackCandles = new int[Bars];
            var pipVal = dataSet.Properties.Pip*minHeight;
            for (int b = 1 + previous; b &lt; Bars; b++)
            {
                if (Close[b - previous] - Open[b - previous] &gt;= pipVal)
                    whiteCandles[b] = whiteCandles[b - 1] + 1;
                if (Open[b - previous] - Close[b - previous] &gt;= pipVal)
                    blackCandles[b] = blackCandles[b - 1] + 1;
            }

            // Saving the components
            Component = new IndicatorComp[2];

            Component[0] = new IndicatorComp
            {
                ChartType = IndChartType.NoChart,
                FirstBar = firstBar,
                Value = new double[Bars]
            };

            Component[1] = new IndicatorComp
            {
                ChartType = IndChartType.NoChart,
                FirstBar = firstBar,
                Value = new double[Bars]
            };

            // Sets the Component&#039;s type
            if (SlotType == SlotTypes.OpenFilter)
            {
                Component[0].DataType = IndComponentType.AllowOpenLong;
                Component[0].CompName = &quot;Is long entry allowed&quot;;
                Component[1].DataType = IndComponentType.AllowOpenShort;
                Component[1].CompName = &quot;Is short entry allowed&quot;;
            }
            else if (SlotType == SlotTypes.CloseFilter)
            {
                Component[0].DataType = IndComponentType.ForceCloseLong;
                Component[0].CompName = &quot;Close out long position&quot;;
                Component[1].DataType = IndComponentType.ForceCloseShort;
                Component[1].CompName = &quot;Close out short position&quot;;
            }

            if(IndParam.ListParam[0].Text == &quot;Bullish Candle formed&quot;)
                for (int b = firstBar; b &lt; Bars; b++)
                {
                    Component[0].Value[b] = whiteCandles[b] &gt;= consecutive ? 1 : 0;
                    Component[1].Value[b] = blackCandles[b] &gt;= consecutive ? 1 : 0;
                }
            else if(IndParam.ListParam[0].Text == &quot;Bearish Candle formed&quot;)
                for (int b = firstBar; b &lt; Bars; b++)
                {
                    Component[1].Value[b] = whiteCandles[b] &gt;= consecutive ? 1 : 0;
                    Component[0].Value[b] = blackCandles[b] &gt;= consecutive ? 1 : 0;
                }
        }

        public override void SetDescription()
        {
            var consecutive = (int) IndParam.NumParam[1].Value;
            string white = consecutive == 1
                ? &quot;a bullish candle is formed&quot;
                : consecutive + &quot; bullish candles are formed&quot;;
            string black = consecutive == 1
                ? &quot;a bearish candle is formed&quot;
                : consecutive + &quot; bearish candles are formed&quot;;

            switch (IndParam.ListParam[0].Text)
            {
                case &quot;Bullish Candle formed&quot;:
                    EntryFilterLongDescription  = white;
                    EntryFilterShortDescription = black;
                    ExitFilterLongDescription   = white;
                    ExitFilterShortDescription  = black;
                    break;

                case &quot;Bearish Candle formed&quot;:
                    EntryFilterLongDescription  = black;
                    EntryFilterShortDescription = white;
                    ExitFilterLongDescription   = black;
                    ExitFilterShortDescription  = white;
                    break;
            }
        }
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[santaferes]]></name>
				<uri>https://forexsb.com/forum/user/9103/</uri>
			</author>
			<updated>2016-06-05T11:38:30Z</updated>
			<id>https://forexsb.com/forum/post/36446/#p36446</id>
		</entry>
</feed>
