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

programming code

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

    programming code

    i would like to add a condition into my strategy, it didn't work
    this is my if condition
    if
    (
    BarColor = Color.Green
    )
    {
    DrawArrowUp("my up arrow" + CurrentBar, 0, Low[0] + (-4*TickSize), Color.Green);
    // draws a up arrow with the color of green at High[0]
    }

    it kept on saying error
    what 's the right code for my logic

    #2
    C# operators

    Hi peterhxu7,

    The operator for logical equivalence (does this equal that?) is two equal signs. One equal sign is an assignment operator. So:

    Code:
    if (BarColor == Color.Green)
    {
    // Do whatever
    }
    Hope that helps.

    These references are worth looking at:

    NT7 online Help: http://www.ninjatrader.com/support/h...nt7/index.html
    C# reference: http://msdn.microsoft.com/en-us/library/kx37x362.aspx

    Cheers.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    Comment


      #3
      Thanks for the assist jeronymite - can you please check into using two equal signs for this condition Peter and let us know if it resolves your compile issue?
      BertrandNinjaTrader Customer Service

      Comment


        #4
        thanks jeronymite. it did compile . but it didn't show any Green Up Arrows on the chart. what's the problem now?

        Comment


          #5
          Check decoumentation

          Hi Peter,

          First, it's worth getting into the habit of checking the documentation on the feature you are trying to use as a starting point for any issue with something you may not be familiar with.

          In this case, the NT7 Online Help (previously provided as a link) shows the syntax for the DrawArrowUp method as follows:

          Code:
          DrawArrowUp(string tag, bool autoScale, int barsAgo, double y, Color color)
          DrawArrowUp(string tag, bool autoScale, DateTime time, double y, Color color)
          Here is your specific invocation of that method:

          Code:
          DrawArrowUp("my up arrow" + CurrentBar, 0, Low[0] + (-4*TickSize), Color.Green);
          The parameters in your code do not match in number and type with the formal syntax.

          I recommend you try something like:

          Code:
          DrawArrowUp("My Up Arrow", true, 0, Low[0] + (-4*TickSize), Color.Green) ;
          // This matches up with this correct form of syntax ...
          DrawArrowUp(string tag, bool autoScale, int barsAgo, double y, Color color)
          Hope that helps.

          Do try to make the avaliable documentation for NT and C# your best friends and use them as the first port of call. You will develop your NinjaScript and C# programming capabilities much more quickly that way.

          Cheers.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,403 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X