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

Assigning the value of Open[0] to Low[0] when Low[0] is zero

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

    Assigning the value of Open[0] to Low[0] when Low[0] is zero

    Hello!
    I am trying to save the value of Low[0] from Open[0] when the bar has no wick below, that means when Low[0] is equal zero.

    I have done the following:

    HTML Code:
     if(Open[0] < Close[0])
     {
       if(Open[0] - Low[0] == 0)
       {
          Low[0] = Open[0]
       }
     }
    The problem here is that I am having an error message that I can not assign Low[0] to Open[0] since they are protected.

    How to assign the value of the low here to the open when there is no wick at the bottom of the candle?

    Many thanks in advance.
    Last edited by Stanfillirenfro; 07-12-2023, 01:29 PM.

    #2
    Hello Stanfillirenfro,

    You will need to declare your own variable.

    private double myValue;

    if (Open[0] - Low[0] == 0)
    {
    myValue = Open[0];
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Many thanks NinjaTrader_ChelseaB for your reply.

      This is not solving my problem really. The idea is not to save the value Low[0] in myValue for example, but to assign directly the value of Open[0] to Low[0].
      If I have the following code for example:
      HTML Code:
       if(Low[0] > Low[1])
       {
       }
      this would work only for bars with wick at the bottom.
      Another way to solve the problem would be:
      HTML Code:
       if((Low[0] > Low[1]) || (Open[0] == Low[0] && Open[1] == Low[1]  && Low[0] > Low[1]))
       {
       }​
      This code would take into consideration the bars with wick as well as bars without wick. But if I have to do it for many bars, this would make the code very heavy.

      Could you please advise me a way to come around?

      Thanks in advance.

      Comment


        #4
        Originally posted by Stanfillirenfro View Post
        The idea is not to save the value Low[0] in myValue for example, but to assign directly the value of Open[0] to Low[0].
        You want to do this?

        Low[0] = Open[0];

        You can't do that.

        Comment


          #5
          Hello bltdavid,

          thanks for your reply.

          You are right, I can't do that. It is exactly the reason why I am looking for solution(s).

          Comment


            #6
            Well, you'll need to assign it to some other variable, like in post 2.

            Whatever solution you choose, it will be some variation on the
            'assign it to some other variable' idea.

            If you need something more specific than post #2, you'd probably
            need to post a lot more code.

            -=o=-

            Also, sorry, your initial explanation is a bit odd.

            For ex, your statement,

            "when Low[0] is equal zero"

            makes no sense to me.

            How come?
            Because Low[0] is lowest price of the current candlestick -- and it
            is practically guaranteed that that price is most likely, probably
            almost never, ever ever EVER equal to zero.

            Comment


              #7
              Hello Stanfillirenfro,

              Data Series are read-only (as they provide the actual market information) and cannot be assigned a value.

              However, you can have your own series and assign that value, then use that custom series instead of the Low for your calculations.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello NinjaTrader_ChelseaB, hello bltdavid I am sorry I could not reply sooner due to a bit of hiatus.

                Also, sorry, your initial explanation is a bit odd.

                For ex, your statement,

                "when Low[0] is equal zero"

                makes no sense to me.​
                Yes bltdavid , I agree with you. I should have said it otherwise.

                Please could you have a look on the attached picture? The bar#4 has no bottom wick. I have tried the folllowing code:
                Code:
                 {
                   if(Low[1] > Low[2] && Low[2] > low[3] && Low[3] > Low[4] && Low[4] > Low[5])
                   {
                     Buys[1] = Low[1];
                   }
                 }
                With this code, I can not have my arrow/dot or whatever. But with the following code:
                HTML Code:
                 {
                   if((Low[1] > Low[2] || (Open[1] == Low[1] && Open[2] == Low[2] && Low[1] > Low[2])) && (Low[2] > low[3] || (Open[2] == Low[12 && Open[3] == Low[3] && Low[2] > Low[3])) && (Low[3] > Low[4]  || (Open[3] == Low[3] && Open[4] == Low[4] && Low[3] > Low[4])) && (Low[4] > Low[5] || (Open[4] == Low[4] && Open[5] == Low[5] && Low[4] > Low[5])))
                   {
                     Buys[1] = Low[1];
                   }
                 }​
                This code gives me an arrow.
                So from the first code to the second, I have to write huge amount of code, and it is what I am trying to avoid.
                I have also declared my own variable as suggested by NinjaTrader_ChelseaB in post#2, but I am still failling to overcome the problem:
                HTML Code:
                 if(Open[0] < Close[0])
                  {
                     if(Open[0] - Low[0] == 0)
                     {
                       maValeur1 = Open[0];
                       Low[0]    = maValeur1;
                     }
                   }​
                Again, I have the same error as in post#1.
                As I wrote previously, I am looking a way to assign a value to the Low when there is no wick at the bottom of the candle.

                I would appreciate any help.
                Attached Files
                Last edited by Stanfillirenfro; 07-18-2023, 02:28 PM.

                Comment


                  #9
                  Originally posted by Stanfillirenfro View Post
                  As I wrote previously, I am looking a way to assign a value to the Low when there is no wick at the bottom of the candle.
                  Why do you keep saying that?
                  What 'Low' are you talking about?

                  "..assign a value to Low..", sorry, that still makes no sense.

                  You cannot assign values to the Low data series.

                  Same as before, this code is illegal,

                  Low[0] = maValeur1;

                  You cannot assign values to the Low data series.

                  I thought we were past this.

                  -=o=-

                  Are you trying to determine the height in ticks of the candlestick's
                  lower wick? The wick heights have to be calculated via logic, their
                  is no builtin data series for this. When this lower wick height is zero,
                  why are you wanting to overwrite the value in Low[0]?

                  Perhaps you should start completely over and describe exactly what
                  it is you're looking for, and exactly what you're wanting to do after you
                  find it.

                  Comment


                    #10
                    Hello Stanfillirenfro,

                    Unfortunately, NinjaTrader does not allow you change the data series information. This is the information received from the connected provider and processed by the bars type.

                    You cannot set the Low.

                    You can use your own custom series. You can draw or plot your own lines or render your own candles on top. But you cannot change the chart bars.

                    Code:
                    private Series<double> myCustomLow;
                    
                    In State.DataLoaded
                    myCustomLow = new Series<double>(this);
                    
                    In OnBarUpdate:
                    if(Open[0] < Close[0])
                    {
                    if(Open[0] - Low[0] == 0)
                    {
                    maValeur1 = Open[0];
                    myCustomLow[0] = maValeur1;
                    }
                    }​​
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Many thanks bltdavid for your reply!

                      Many thanks NinjaTrader_ChelseaB for your advice!

                      bltdavid , no, I do not try to determine the height in ticks of the candlestick's lower wick. No! Otherwise the logic would be something like:
                      HTML Code:
                      (Open[0] - Low[0])/TickSize;
                      for a bullish candle. It is not what I am looking for.

                      Looking at the code of NinjaTrader_ChelseaB, I am realizing that my costum value was a double and not a Series<double>. I will explore this way and give you my feedback in the coming hours.

                      Thank you all again.

                      Comment


                        #12
                        Hi Stanfillirenfro, I made the indicator for you. Hope it helps OpenNoWick.zip

                        Comment


                          #13
                          Many thanks JustinaM for your help and sorry for the delay to respond.

                          Actually, this is the way I wanted to avoid because it is making the code heavy. For example, if I have 20 bars and I have to compare each one to the rest, it would be very heavy for the code.

                          Many thanks anyway.

                          Comment


                            #14
                            Hi Stanfillirenfro you are welcome I'm very new at coding thanks for letting me know. I will be working on that!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Segwin, 05-07-2018, 02:15 PM
                            14 responses
                            1,789 views
                            0 likes
                            Last Post aligator  
                            Started by Jimmyk, 01-26-2018, 05:19 AM
                            6 responses
                            837 views
                            0 likes
                            Last Post emuns
                            by emuns
                             
                            Started by jxs_xrj, 01-12-2020, 09:49 AM
                            6 responses
                            3,294 views
                            1 like
                            Last Post jgualdronc  
                            Started by Touch-Ups, Today, 10:36 AM
                            0 responses
                            13 views
                            0 likes
                            Last Post Touch-Ups  
                            Started by geddyisodin, 04-25-2024, 05:20 AM
                            11 responses
                            63 views
                            0 likes
                            Last Post halgo_boulder  
                            Working...
                            X