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

Loop Logic and Dataseries

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

    Loop Logic and Dataseries

    Okay, I got it.
    Last edited by stockgoblin; 03-25-2013, 04:44 PM.

    #2
    Hello stockgoblin,

    I am happy to assist you with this but I need a little bit more context.

    Could you post the full loop you use to check this value. I will do some testing here on my end and I'll be able to give you a better response.


    Thanks.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ok, I got it
      Last edited by stockgoblin; 03-25-2013, 04:44 PM.

      Comment


        #4
        Hello stockgoblin,

        Thanks for the code.

        So I've put this in an indicator and run it. I also added some print statements so I can see the values the conditions are based on. I notice that the draw does not always happen but I am not sure when it is suppose to happen.


        Currently the code reads as this:

        Calculate the difference (subtraction) of the close of the current bar and the close of the last bar. Take this difference and set myDataseries[0] to this value.

        Then loop over the current amount of bars from 0 up to 255.

        During this loop, if the difference of the close of the current bar and close of the previous bar are equal to the difference value stored in the current iteration of myDataSeries then draw a line from 1 bar ago at the close price of 1 bar ago to the current bar at the current close (continuing because it is extended).

        This can happen many times during that loop. This means there are going to be a lot of drawn lines.

        Also, this will always draw on the first iteration of the loop. myDataSeries[0] == myDataSeries[0]. This will happen only once in that 256 iteration loop for every bar.


        I don't quite understand what you are asking for when you say " all instances of parallel lines that are made from adjacent bar closes."

        Does this mean that you would like to draw this line if the close of the previous bar is the same as the close of the current bar?

        Or that you would like to draw this line if the close of the current bar is the same as the close as the 2 previous bars?


        Just as a tip, you have the following code in your Initialize() function:
        Code:
        for (int i = 0; i < 256; ++i) 
        {
            myDataSeries = new DataSeries(this, MaximumBarsLookBack.Infinite);
        }
        This code overwrites the myDataSeries variable 256 times without actually changing anything. It basically causes your script to load slowly without any benefit that I can see.

        Please let me know and I will continue to assist.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok, I got it.
          Last edited by stockgoblin; 03-25-2013, 04:44 PM. Reason: replace picture

          Comment


            #6
            Ok, I got it.

            Maybe this programming stuff isn't impossible to learn.

            live logic & long prosper
            Last edited by stockgoblin; 03-25-2013, 04:43 PM.

            Comment


              #7
              Hello stockgoblin,

              Thanks for the update. I'm glad you have what you are looking for.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by RubenCazorla, 08-30-2022, 06:36 AM
              3 responses
              77 views
              0 likes
              Last Post PaulMohn  
              Started by f.saeidi, Yesterday, 12:14 PM
              9 responses
              23 views
              0 likes
              Last Post f.saeidi  
              Started by Tim-c, Today, 03:54 AM
              0 responses
              3 views
              0 likes
              Last Post Tim-c
              by Tim-c
               
              Started by FrancisMorro, Today, 03:24 AM
              0 responses
              4 views
              0 likes
              Last Post FrancisMorro  
              Started by Segwin, 05-07-2018, 02:15 PM
              10 responses
              1,772 views
              0 likes
              Last Post Leafcutter  
              Working...
              X