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

time and sales

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

    time and sales

    hello,

    i'd like to build an indicator,

    - drawing a line (actual candle + some more candles in future) if
    - the traded contracts in time and sales are bigger than 10 e.g.
    - line should be colored, depending on the time and sales color

    (example attached)

    how can this be done?
    thanks for your assistance!
    Attached Files

    #2
    Hello,

    Thank you for the question.

    While there is not a complete sample showing all of what you need, we do have a sample of accessing the level2 orderbook which you could use for the Data you need.



    For drawing lines, you could see the Drawing section in the help guide for all possible options: http://ninjatrader.com/support/helpG...t7/drawing.htm

    For lines specifically: http://ninjatrader.com/support/helpG...7/drawline.htm

    For the conditions, you can utilize the example provided in the Level2 script to see some general conditions and how to utilize them in the logic of the sample. If you do have further questions related to any of these items please feel free to ask.

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

    Comment


      #3
      hi jesse,
      i assume i'll be able to draw a line ( in the meantime)
      but i'm not able to deal with the examples concerning thread 5965.
      isn't there any other solution?
      thanks

      Comment


        #4
        Hello,

        Thank you for the reply.

        Yes, the link provided has an example of the syntax required to draw a line.

        For what you are asking it would require custom scripting, the example provided demonstrates how to access the data you would need for the time and sales. This is a more advanced concept as accessing the level 2 data does require some logic.

        Unfortunately outside of having this developed for you, it would require using logic to get the data needed and then draw the lines accordingly. If you need I can have our business development department follow up with you as well regarding NinaScript programmers.

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

        Comment


          #5
          jesse,

          is my question comparable with this thread 68099?

          Comment


            #6
            Hello,

            I am not sure that would be related. The question you had asked was about plotting lines based on conditions from Time and Sales values which the other thread does not mention.

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

            Comment


              #7
              hi jesse,

              as far as i understand (after reading the information):

              the information if the last trades price is displayed in green or red can't be requested from the datafeed.
              this means i'll have to compare this by myself using a kind of "list"?

              second:
              MarketDataEntArgs example in NT Help is using the expression:
              Print ("Last = " + e.Price + " "+ e.Volume);
              what is the meaning of this expression?

              thanks a lot !

              Comment


                #8
                Hello,

                Yes to create the same effect as the time and sales you would need to do the logic yourself as it is not a data feed item specifically.

                The expression you had provided is simply a print statement, e is the object and the items after the period are properties of that object.

                Print ("Last = " + e.Price + " "+ e.Volume);

                the output of this statement would be similar to:

                Last = 2048 100

                There is a sample created by another support member related to getting the volume of time and sales from an indicator which may assist with your question, I have attached the zip file which you can import.

                Please let me know if I may be of further assistance.
                Attached Files
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  hi jesse,

                  thank you very much for the example.

                  i have started to overwork this one with the following idea:

                  draw a black line if a traded contract is bigger than 4.

                  (i think if i can manage this, i will also be able to move forward step by step with the other conditions than)
                  result:
                  indicator attached.
                  unfortunately it's not fulfilling the second condition.

                  may i ask you to have a look at it?
                  (probably i have missed something or mixed something up due to missing programming knowledge.....)
                  thanks
                  Attached Files

                  Comment


                    #10
                    anybody any idea, how this can be solved?
                    thx

                    Comment


                      #11
                      Hello,

                      Thank you for the post.

                      I only see one issue in the script and its only a general C# syntax problem.

                      You currently have the condition:

                      Code:
                      if ((e.MarketDataType == MarketDataType.Last) == (e.Volume >4));

                      Please note the semi colon at the end of the if statement. This terminates the if statement so any logic it was doing, it is no longer doing that logic.

                      To correct the script, all that is required is to remove the semicolon from the end so the if statement applies to the logic below:


                      Code:
                      if ((e.MarketDataType == MarketDataType.Last) == (e.Volume >4))

                      if statements in C# will be terminated by a semicolon ;
                      They can execute 1 command using no curly braces:

                      Code:
                      if ((e.MarketDataType == MarketDataType.Last) == (e.Volume >4))
                           DrawLine("MyLine",true, 0, e.Price,-5, e.Price, Color.Black, DashStyle.Solid, 1);

                      or multiple using curly braces:

                      Code:
                      if ((e.MarketDataType == MarketDataType.Last) == (e.Volume >4))
                      {
                           DrawLine("MyLine",true, 0, e.Price,-5, e.Price, Color.Black, DashStyle.Solid, 1);
                           DrawLine("MyLineTwo",true, 0, e.Price,-5, e.Price, Color.Red, DashStyle.Solid, 1);
                      }

                      I look forward to being of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        hi jesse,

                        thanks for the information. i have changed the semicolon and
                        i have tried some changes as you suggested concerning the curly braces.

                        unfortunately the result is just one line.

                        what i would like to see is:
                        all lines during a day that match the second condition.

                        any other ideas, how this can be done?

                        Comment


                          #13
                          Hello,

                          Thank you for the reply.

                          To see All lines, you would need to both change the Tag and allow it to run in realtime.

                          because the OnMarketData method is not called historically, this would not show any historical lines at all. Going forward you would.

                          The change needed would only be to the DrawLine statement and its tag:

                          Instead of:

                          Code:
                          DrawLine("MyLine",true, 0, e.Price,-5, e.Price, Color.Black, DashStyle.Solid, 1);
                          You would need a unique tag or:

                          Code:
                          DrawLine("MyLine" + CurrentBar,true, 0, e.Price,-5, e.Price, Color.Black, DashStyle.Solid, 1);
                          This would allow for 1 line per bar, in the case you wanted each tick you could do a even more unique tag like:
                          Code:
                          DrawLine("MyLine" + CurrentBar + e.Price,true, 0, e.Price,-5, e.Price, Color.Black, DashStyle.Solid, 1);
                          This would draw a new line for each new price the logic sees.


                          I look forward to being of further assistance.
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            hi jesse,
                            thank you very much.
                            very good explanation.
                            i'll try to work with it.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by MarianApalaghiei, Today, 10:49 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by love2code2trade, Yesterday, 01:45 PM
                            4 responses
                            28 views
                            0 likes
                            Last Post love2code2trade  
                            Started by funk10101, Today, 09:43 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post funk10101  
                            Started by pkefal, 04-11-2024, 07:39 AM
                            11 responses
                            37 views
                            0 likes
                            Last Post jeronymite  
                            Started by bill2023, Yesterday, 08:51 AM
                            8 responses
                            46 views
                            0 likes
                            Last Post bill2023  
                            Working...
                            X