Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Bogus 'if' statement

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

    Bogus 'if' statement

    the if statement [in red font] below is not valid. does anyone see the problem? the statement is made simple for testing reasons.

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    ///<summary>
    /// just a few simple test statements
    ///</summary>
    [Description("just a few simple test statements")]
    publicclass TEST2 : Strategy
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    double profit;
    double profit_tot;
    double hao;
    #endregion
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose = true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    hao=Open[0];
    DrawDot("My dot" + CurrentBar, true, 0, High[0]+2*TickSize, Color.Red);
    profit=Open[0]-Open[1];
    if(true)
    {
    profit=Open[0]-Open[1];
    }
    Else if(true)
    {
    profit=Open[1]-Open[0];
    }
    }

    #region Properties
    #endregion
    }
    }

    #2
    correction

    the last bracket in red font in the original submission should not have been red

    Comment


      #3
      Else should be lower case.

      The if-else statement in C# allows you to control the flow of your program based on whether a certain condition is true or false. The basic logic behind an if-else statement is as follows.....

      Comment


        #4
        many thanks again Sledge.

        many thanks again Sledge, that fixed it.
        much appreciated.....you guys are a great resource.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X