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

Need help coming up with a solution

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

    Need help coming up with a solution

    I want create a Sentiment indicator for day trading, that uses a set number of stocks and compares them with each other. But I want to upload the list of stocks from a File, do not really care about the extension. The reason for this is that the list may change from Broker to broker. I want to put it into an array in order to work with them. This is to use it in an automatic strategy or another indicator

    Any Help out there available?

    #2
    Hello Yandychang,

    Thank you for your post.

    You can take a look at our reference sample for reading from a file at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3476

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello

      Thanks for your help. Do i need to " Add( instruments, period types, index)" all of the symbols from the txt Files? If yes, can it be done from a For cycle in the initialize method? Or would i need to do them one by one, it would deffeat the purpose of the txt file

      Comment


        #4
        Originally posted by Yandychang View Post
        Thanks for your help. Do i need to " Add( instruments, period types, index)" all of the symbols from the txt Files? If yes, can it be done from a For cycle in the initialize method? Or would i need to do them one by one, it would deffeat the purpose of the txt file
        You can use a for loop.

        Comment


          #5
          Hello Yandychang,

          Thank you for your response.

          You can use a for loop as Koganam responded. However, depending on the number of instruments to be added this could take some time to process.

          Comment


            #6
            Hello

            I need a few of them, because I want to compare their price to the beginning of the day. and it needs to be statistically significant. So, let me see If I got it right, I only Load the File once on FirstBarOfSession. then, I do a loop and Add all the instruments to a DataSeries. Now, is That's During initialize. ? Would that bring me any problems when running the script.?

            Comment


              #7
              Originally posted by Yandychang View Post
              I need a few of them, because I want to compare their price to the beginning of the day. and it needs to be statistically significant. So, let me see If I got it right, I only Load the File once on FirstBarOfSession. then, I do a loop and Add all the instruments to a DataSeries. Now, is That's During initialize. ? Would that bring me any problems when running the script.?
              No. You load your list by Add()ing them on first application to the chart, when the Initialize() method is called.

              Comment


                #8
                Hello

                Got it to open the txt file... but Right after it starts the while loop... at the level of the String[] Split is throws an exception... I created the attached TXT file. it does not seem to be reading the Characters into a full string... I copied the code from the sample you sent me to... but might have I made a mistake. Can you see an error?
                Attached Files

                Comment


                  #9
                  Originally posted by Yandychang View Post
                  Got it to open the txt file... but Right after it starts the while loop... at the level of the String[] Split is throws an exception... I created the attached TXT file. it does not seem to be reading the Characters into a full string... I copied the code from the sample you sent me to... but might have I made a mistake. Can you see an error?
                  Your while statement is a null statement, so your Line object is null after the while loop is parsed. Remove the semi-colon that terminates the statement, making it null.

                  Comment


                    #10
                    OK

                    Thank you very, its seems to be debugged, the entire Initialize Method runs well. I appreciate your help. I have been trying to write this for a long time now... Thank you...

                    Comment


                      #11
                      Hello

                      Guys Im having to Debug my OnBarUpdate Method. It seems to work Up to the point Highlightted in blue and attached is the error I get, Apparently I get a result out of range specifically on bar 20... any errors you might see?
                      Attached Files

                      Comment


                        #12
                        Originally posted by Yandychang View Post
                        Guys Im having to Debug my OnBarUpdate Method. It seems to work Up to the point Highlightted in blue and attached is the error I get, Apparently I get a result out of range specifically on bar 20... any errors you might see?
                        Your for loops do not make sensible statements. 'For "a" starting at 1, while "a" is less than 1' makes no logical sense. It is not possible, so the statements are never executed to create any escapes. "a" can never be less than 1, if "a" starts at 1.

                        Comment


                          #13
                          Hello

                          I fixed the 1 and changed it to a zero, the other value in the loop i, is less than i... i returns the amount of symbols I have on the file i read, the actual value is 55... I think I found where My error is... I need to do a CurrentBar for All my BarArrays... I did an
                          (if Currentbars[a]< BarsRequired Return) inside a loop for my 55 instruments, then I come up with the issue i'm having now... it seems like my BarsArray[1] does not receive values . Because its CurrentBars[0] Value is always -1, while BarsArray[0] CurrentBars[0] value changes up to 1640s. so it constantly loops and returns at BarsArray[1]. I am actually running the indicator and everytime a new bar forms it gives me my Print Message I put to debug it. when I try to pull up the instrument that gives me the CurrentBars[]=-1 the chart is blank,so maybe the error is not on the programming side, maybe is from the data feed...
                          Attached Files

                          Comment


                            #14
                            Originally posted by Yandychang View Post
                            I fixed the 1 and changed it to a zero, the other value in the loop i, is less than i... i returns the amount of symbols I have on the file i read, the actual value is 55... I think I found where My error is... I need to do a CurrentBar for All my BarArrays... I did an
                            (if Currentbars[a]< BarsRequired Return) inside a loop for my 55 instruments, then I come up with the issue i'm having now... it seems like my BarsArray[1] does not receive values . Because its CurrentBars[0] Value is always -1, while BarsArray[0] CurrentBars[0] value changes up to 1640s. so it constantly loops and returns at BarsArray[1]. I am actually running the indicator and everytime a new bar forms it gives me my Print Message I put to debug it. when I try to pull up the instrument that gives me the CurrentBars[]=-1 the chart is blank,so maybe the error is not on the programming side, maybe is from the data feed...
                            Your first step would be to rem out your loop for adding instruments, add a few instruments manually, then run the indicator and see if your escape loop works correctly.

                            Comment


                              #15
                              Hello Yandychang,

                              Thank you for your response.

                              Do you receive data on the DD chart without the strategy applied? What instrument are you attempting to add that uses the NIA future for CQG?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by geddyisodin, Today, 05:20 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post geddyisodin  
                              Started by JonesJoker, 04-22-2024, 12:23 PM
                              6 responses
                              32 views
                              0 likes
                              Last Post JonesJoker  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              12 responses
                              3,239 views
                              0 likes
                              Last Post Leafcutter  
                              Started by AveryFlynn, Today, 04:57 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post AveryFlynn  
                              Started by RubenCazorla, 08-30-2022, 06:36 AM
                              3 responses
                              79 views
                              0 likes
                              Last Post PaulMohn  
                              Working...
                              X