Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bool to double

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    bool to double


    replaced by post 6.​
    Last edited by SJunior; 06-28-2023, 12:42 AM.

    #2
    Don't you mean == not =?
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Also, I'm not sure that whole "if" construction makes sense, unless HS_LiINE_VERTICAL is a series of bools, and unless it already has a bool state you're comparing with those indicator conditions.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Hello SJunior,

        Thanks for your post.

        QuantKey_Bruce is correct. To compare a plot to another value you would need to use == instead of =.

        What exactly is the bool variable in the code you shared that the error message is referring to?

        Plots created with the AddPlot() method are typically Series<double> values.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          I think, in summary, that the line of code there doesn't make any sense and is mixing together several different ideas. You need to think carefully about what you are trying to compare and to what.
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            QuantKey_Bruce, My knowledge in NT8 programming is very little and I need to add the following situation in the source code, but I have already tried some alternatives, but without success.



            Would it be possible for you to help me write the code, as I already had the help of support that indicated technical documents, but I could not put it into practice in the indicator code.​​



            Change the candlesticks/bars chains, when:

            HS = (d18[0] > 0 && dO18[0] < 0 && d18[0] > d38[0] && dO18[0] < d38[0]);
            color Lime

            LS = (d18[0] < 0 && dO18[0] > 0 && d18[0] < d38[0] && dO18[0] > d38[0]);
            color red

            H = (d18[0] > 0 && dO18[0] < 0 && d18[0] > d38[0] && dO18[0] < d38[0] && d18[0] > d208[0] && dO18[0 ] < d208[0]);
            color cyan

            L = (d18[0] < 0 && dO18[0] > 0 && d18[0] < d38[0] && dO18[0] > d38[0] && d18[0] < d208[0] && dO18[0 ] > d208[0]);
            color magenta


            ================================================== =====


            Below is the complete and working code, but without the candles/bars coloring coding.


            ================================================== ===


            //
            region Using declarations
            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.ComponentModel.DataAnnotations;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Windows;
            using System.Windows.Input;
            using System.Windows.Media;
            using System.Xml.Serialization;
            using NinjaTrader.Cbi;
            using NinjaTrader.Gui;
            using NinjaTrader.Gui.Chart;
            using NinjaTrader.Gui.SuperDom;
            using NinjaTrader.Data;
            using NinjaTrader.NinjaScript;
            using NinjaTrader.Core.FloatingPoint;
            using NinjaTrader.NinjaScript.DrawingTools;
            #endregion

            namespace NinjaTrader.NinjaScript.Indicators.mah_Indicators
            {
            public class Indicators : Indicator
            {
            protected override void OnStateChange()
            {
            if (State == State.SetDefaults)
            {
            Description = "SJunior";
            Name = "SJunior";
            IsSuspendedWhileInactive = true;

            AddPlot(new Stroke(Brushes.LightPink, 4), PlotStyle.Line, "d38");
            AddPlot(new Stroke(Brushes.DarkGreen, 4), PlotStyle.Line, "d208");
            AddPlot(new Stroke(Brushes.Cyan, 1), PlotStyle.Bar, "d18");
            AddPlot(new Stroke(Brushes.Yellow, 1), PlotStyle.Bar, "dO18");
            AddPlot(new Stroke(Brushes.LightCyan, 1), PlotStyle.Line, "osc");
            AddPlot(new Stroke(Brushes.Goldenrod, 1), PlotStyle.Line, "srs");
            AddPlot(new Stroke(Brushes.Goldenrod, 1), PlotStyle.Line, "sri");
            AddPlot(new Stroke(Brushes.Yellow, 1), PlotStyle.Line, "nvel_0");


            }
            }

            protected override void OnBarUpdate()
            {
            if (CurrentBar < 20) return;

            d38[0] = (((SMA(1)[0]-SMA(8)[0])/SMA(8)[0])*100);
            d208[0] = (((SMA(20)[0]-SMA(8)[0])/SMA(8)[0])*100);
            d18[0] = (((SMA(1)[0]-SMA(8)[0])/SMA(8)[0])*100);
            dO18[0] = (((SMA(1)[1]-SMA(8)[0])/SMA(8)[0])*100);
            osc[0] = (d38[0]-d208[0]);
            srs[0] = (((2*StdDev(8)[0])/SMA(8)[0])*100);
            sri[0] = (((-2*StdDev(8)[0])/SMA(8)[0])*100);
            nivel_0[0] = 0;



            if (d208[0] <= 0 && d208[0] < d208[1])
            PlotBrushes[1][0] = Brushes.Green;
            else if (d208[0] >= 0 && d208[0] > d208[1])
            PlotBrushes[1][0] = Brushes.Red;
            else if (d208[0] <= 0 && d208[0] > d208[1])
            PlotBrushes[1][0] = Brushes.Magenta;
            else if (d208[0] >= 0 && d208[0] < d208[1])
            PlotBrushes[1][0] = Brushes.Orange;


            if (osc[0] >= 0 && osc[0] > osc[1])
            PlotBrushes[4][0] = Brushes.Green;
            else if (osc[0] <= 0 && osc[0] < osc[1])
            PlotBrushes[4][0] = Brushes.Red;
            else if (osc[0] >= 0 && osc[0] < osc[1])
            PlotBrushes[4][0] = Brushes.Magenta;
            else if (osc[0] <= 0 && osc[0] > osc[1])
            PlotBrushes[4][0] = Brushes.Orange;



            }

            region Properties

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> d38
            {
            get { return Values[0]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> d208
            {
            get { return Values[1]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> d18
            {
            get { return Values[2]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> dO18
            {
            get { return Values[3]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> osc
            {
            get { return Values[4]; }
            }


            [Browsable(false)]
            [XmlIgnore]
            public Series<double> srs
            {
            get { return Values[5]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> sri
            {
            get { return Values[6]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public Series<double> nivel_0
            {
            get { return Values[7]; }
            }

            [Browsable(false)]
            [XmlIgnore]
            public bool HiE
            {
            get; set;
            }

            [Browsable(false)]
            [XmlIgnore]
            public bool LoE
            {
            get; set;
            }

            [Browsable(false)]
            [XmlIgnore]
            public bool Hi
            {
            get; set;
            }

            [Browsable(false)]
            [XmlIgnore]
            public bool Lo
            {
            get; set;
            }

            #endregion
            }
            }

            region NinjaScript generated code. Neither change nor remove.

            namespace NinjaTrader.NinjaScript.Indicators
            {
            public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
            {
            private mah_Indicators.Indicators[] cacheIndicators;
            public mah_Indicators.Indicators Indicators()
            {
            return Indicators(Input);
            }

            public mah_Indicators.Indicators Indicators(ISeries<double> input)
            {
            if (cacheIndicators != null)
            for (int idx = 0; idx < cacheIndicators.Length; idx++)
            if (cacheIndicators[idx] != null && cacheIndicators[idx].EqualsInput(input))
            return cacheIndicators[idx];
            return CacheIndicator<mah_Indicators.Indicators>(new mah_Indicators.Indicators(), input, ref cacheIndicators);
            }
            }
            }

            namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
            {
            public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
            {
            public Indicators.mah_Indicators.Indicators Indicators()
            {
            return indicator.Indicators(Input);
            }

            public Indicators.mah_Indicators.Indicators Indicators(ISeries<double> input )
            {
            return indicator.Indicators(input);
            }
            }
            }

            namespace NinjaTrader.NinjaScript.Strategies
            {
            public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
            {
            public Indicators.mah_Indicators.Indicators Indicators()
            {
            return indicator.Indicators(Input);
            }

            public Indicators.mah_Indicators.Indicators Indicators(ISeries<double> input )
            {
            return indicator.Indicators(input);
            }
            }
            }

            #endregion​​
            Last edited by SJunior; 06-28-2023, 06:05 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            591 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            553 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X