Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

newbie question

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

    newbie question

    for example i have this script,

    if (Open[0] < Low[period])
    {
    upwardbreak = Low[period];
    }

    if the condition is not met, how do i say "do nothing"? Or I don't have to write a script for "do nothing"?

    The reason why I ask this is because the script is suppose to "do something" when a certain condition is met. If you look at the attached chart, that green square, to me, is some number plucked from somewhere! BTW script is also attached.
    Attached Files
    Last edited by kaywai; 01-21-2010, 11:21 AM.

    #2
    kaywai, depends on your script and logic - if you do not change the value (condition not met) it would keep the assigned one.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      To do nothing, just don't code anything and it won't do anything.

      What your code is doing right now is setting variables to highs and lows. Then you are drawing the dots on every single bar. Even if no new high/low is set, it is still drawing the dots with the old values. You need to place them inside the if-statement if you don't want them to draw.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Josh, I understand what you are saying but not quite sure how to achieve that end? Would you mind helping? The script is attached to the initial posting

        Comment


          #5
          Like this -
          Code:
           
           
          if ((Open[0] < Low[period]))
             {
              upwardbreak = Low[period];
              DrawSquare("tag1", true, 0, upwardbreak, Color.Green);
             }
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Bertrand, It certainly looks a lot better now!

            Question I have now is how do i give instructions so that if either of the conditions is not met, the square doesn't print at all?

            Comment


              #7
              Use bool variables. Only when both bool variables are true do you draw the dot, otherwise don't draw.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                guys, would you mind giving some pointers on how to begin with bool? tried something along the lines of:-

                private BoolSeries myBoolSeries;
                myBoolSeries = new BoolSeries(this);

                myBoolSeries.Set(Open[0] < Low[period] ? true : false);

                got stuck after that...

                Comment


                  #9
                  kaywai,

                  No need to go to a BoolSeries. A simple bool would do.

                  In Variables region you can go:
                  Code:
                  private bool condition1 = false;
                  private bool condition2 = false;
                  Then in your OnBarUpdate():
                  Code:
                  if (Open[0] < Low[period])
                  {
                       condition1 = true;
                  }
                  else
                  {
                       condition1 = false;
                  }
                  
                  if (some other condition)
                  {
                       condition2 = true;
                  }
                  else
                  {
                       condition2 = false;
                  }
                  
                  if (condition1 == true && condition2 == true)
                  {
                       DrawSquare(...);
                       DrawSquare(the other square...);
                  }
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank you very much for your help Josh!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by muratb35, Today, 03:36 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post muratb35  
                    Started by fernlicht, Today, 02:16 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post fernlicht  
                    Started by fernlicht, 04-12-2021, 06:01 PM
                    1 response
                    29 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Started by memonolog, Today, 02:10 AM
                    3 responses
                    10 views
                    0 likes
                    Last Post memonolog  
                    Started by orenytz, Today, 12:25 AM
                    0 responses
                    10 views
                    0 likes
                    Last Post orenytz
                    by orenytz
                     
                    Working...
                    X