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

i am trying to identify a green Heikin ashi

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

    i am trying to identify a green Heikin ashi

    hi im new to coding on C#
    i am trying to identify a green Heikin ashi candle stick in my strategy but a error keeps showing up whenever i try to compile, here is the code , how do i fix it ? i dont know what is wrong

    basically if close > open then draw dot

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if ((Open[0] + High[0] + Low[0] + Close[0]) / 4) > ((Open[1] + Close[1]) / 2 );

    {
    DrawDot("My dot" + CurrentBar, false, 0, Low[0] + -10 * TickSize, Color.Blue);
    }
    }

    #2
    Originally posted by maaz1598 View Post
    hi im new to coding on C#
    i am trying to identify a green Heikin ashi candle stick in my strategy but a error keeps showing up whenever i try to compile, here is the code , how do i fix it ? i dont know what is wrong

    basically if close > open then draw dot

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if ((Open[0] + High[0] + Low[0] + Close[0]) / 4) > ((Open[1] + Close[1]) / 2 );

    {
    DrawDot("My dot" + CurrentBar, false, 0, Low[0] + -10 * TickSize, Color.Blue);
    }
    }
    What is the text of the error?

    Comment


      #3
      Hello maaz1598,


      I notice that your code needed an open parenthesis a the beginning of your condition and a closing parenthesis at the end of your condition. I have included the corrected code below.


      Code:
      [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2][COLOR=#0000FF]if[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2](((Open[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]] + High[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + Low[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + Close[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]) /[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]4[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) > ((Open[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]) /[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]));[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]
      [/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]  {[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]  DrawDot([/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800000]"My dot"[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]+ CurrentBar,[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]false[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2],[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2], Low[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + -[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]* TickSize, Color.Blue);[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2]  }[/SIZE][/FONT][/LEFT][/FONT][LEFT][/LEFT][/COLOR][LEFT][/LEFT]
      Shawn B.NinjaTrader Customer Service

      Comment


        #4
        it writes (invalid expression "]") x2 and (syntax error "] expected")

        even after i adjusted code (shawnB)

        if (((Open[0] + High[0] + Low[0] + Close[0]) / 4) > ((Open[1] + Close[1]) / 2 ));

        Comment


          #5
          Originally posted by maaz1598 View Post
          it writes (invalid expression "]") x2 and (syntax error "] expected")

          even after i adjusted code (shawnB)

          if (((Open[0] + High[0] + Low[0] + Close[0]) / 4) > ((Open[1] + Close[1]) / 2 ));
          oww never mind, my bad, i used "[" instead of "}"

          Comment


            #6
            Originally posted by maaz1598 View Post
            oww never mind, my bad, i used "[" instead of "}"
            nope spoke to soon that wasn't the issue

            Comment


              #7
              Hello maaz1598,

              Could you please reply with your script attached, so that I may investigate this behavior further?

              You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.

              You could post the script to your forum reply, or send an email to platformsupport [at] ninjatrader [dot] com with the script as an attachment. In the email please include a link to this forum thread.
              Shawn B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by maaz1598 View Post
                nope spoke to soon that wasn't the issue
                Same error? Or something else?

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Stanfillirenfro, Yesterday, 09:19 AM
                7 responses
                51 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by TraderCro, 04-12-2024, 11:36 AM
                4 responses
                69 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Mindset, Yesterday, 02:04 AM
                1 response
                15 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by agclub, 04-21-2024, 08:57 PM
                4 responses
                18 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Irukandji, Today, 04:58 AM
                0 responses
                4 views
                0 likes
                Last Post Irukandji  
                Working...
                X