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

plot my trades

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

    plot my trades

    I have decided to create my own indicator to plot my trades. There is sufficient shortcoming that i am going to do it myself.
    I have loaded all my trades in json and am loading the json as objects when state==dataloaded.
    all of this will be historical data and not realtime.
    so, i will need to do the following.
    1. load all the trade components as indicator values.
    what state should i be applying this code? should i want for historical to be loaded ?

    #2
    Hello junkone,

    It sounds like you already have some collection of trades from your json file so loading the information is already done. I believe you are just asking how to display it now is that correct?

    Likely the easiest way would be to use OnBarUpdate and compare the bar time against the trade time to see if you should mark a trade there or not. This is not something you could load into a trade collection like a strategy but you could use the loaded data during processing to mark the chart.


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

    Comment


      #3
      does onBarUpdate expose the start and the end time of the bar? my trade executin time could be inbetween these 2 ,,,.

      Comment


        #4
        Hello junkone,

        That will depend on your series setup, where the script is used and other variables. You could simulate this with IsFirstTickOfBar and Calculate.OnEachTick going forward in realtime (assuming playback mode). You can use TickReplay to add granularity in historical to utilize IsFirstTickOfBar. Alternatively you could use logic to determine what bar that execution belongs to.

        One way to do this with logic would be to take the execution time and compare it to the Time[0], if the execution time was before the close of the bar, but after the close of the prior bar we can determine it should be placed on this bar without having extra granularity.

        Really there are many ways to accomplish this depending on how you want your script to run. If the marks should happen when the script starts, likely doing this from OnBarUpdate with logic would be the most simple. Processing each bar as you progress forward and checking if an execution from your list matches.

        As one other alternative, if you plan to just render this on the chart visually you could just use OnRender methods to find and display this data. The ChartBars object has a method to get a bar index by time, this could be used to pick bars for rendering purposes as you get the Index returned: https://ninjatrader.com/support/help...htsub=baridxby




        I look forward to being of further assistance.
        Last edited by NinjaTrader_Jesse; 10-14-2019, 12:52 PM.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I like the chartbar approach as I can loop thro my trades only once. lets say, I have 365 days loaded as part of my charts. would I have access to all of this@ state dataloaded so I can do my marking instead of onbarupdate?

          Comment


            #6
            Hello junkone,

            Only if you load the data and it is actually there. I am not certain offhand what the method would return for a time thats out of series, you could certainly give that a try and print the index. To verify you have enough data loaded, you could check the Time of bar 0 is far enough back to accommodate the trade data.


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

            Comment


              #7
              for what its worth, i uploaded my code. i have 2 json hard coded and you need to have EurUsd chart for the following 2 dates to see the giant pink circle marking the entry.
              will continue working on it.

              Attached Files

              Comment


                #8
                when i plot text, it sometimes over writes How can i detect if i have empty spaces below or above so i can change my draw text locations?

                Comment


                  #9
                  Hello junkone,

                  There is not really a good solution that I can think of here or anything that would be default/easy to achieve that.

                  One possibility would be to use a counter to count the number of bars since the last text and if it is under a certain amount apply Y offset. There is no specific way to detect the text bounds by just using the drawing overload, you would need to do additional logic to check any objects you drew if you wanted to know its position.

                  Another possibility may be to store just the last drawn text as a variable so that you can check how close its anchors are when you do the next drawing.

                  There is an example of storing text to a variable here: https://ninjatrader.com/support/help...anchor+barsago



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

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by zstheorist, Today, 07:52 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post zstheorist  
                  Started by pmachiraju, 11-01-2023, 04:46 AM
                  8 responses
                  150 views
                  0 likes
                  Last Post rehmans
                  by rehmans
                   
                  Started by mattbsea, Today, 05:44 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post mattbsea  
                  Started by RideMe, 04-07-2024, 04:54 PM
                  6 responses
                  33 views
                  0 likes
                  Last Post RideMe
                  by RideMe
                   
                  Started by tkaboris, Today, 05:13 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post tkaboris  
                  Working...
                  X