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

Copy and Paste an Image

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

    Copy and Paste an Image

    I have a script that creates a histogram of volume within the last bar of data. I know how to position and scale it in the chart window. When a new bar opens, the old histogram is wiped out and a new one starts building.

    Is it possible to copy an image of an existing graphic (histogram in this case) from one area within the chart, and paste it into a different area? If I could do this, I could display histograms for 5 or 6 bars on a chart.

    #2
    Hi HNWtrader,

    Unfortunately, I cannot offer support for that type of procedure.

    You likely will need to override the Plot() method, but again, unfortunately that is outside the scope of support I can offer.
    TimNinjaTrader Customer Service

    Comment


      #3
      There is a better alternative to accomplish what I want to do. If I can save the volume information for a bar so that it will not be destroyed when the new bar begins, I can draw the "old" histogram in a new location.

      My script is a modification of the NinjaScript Indicator "Volume Profile" The information I need seems to reside in a "thing" (sorry, I have not yet grasped the correct terminology for this language) called VolumeInfo, which (in language I do understand) is an array of cumulative tick data that I re-initialize at the start of a new bar using
      if(FirstTickOfBar) volumeInfo = new SortedDictionary<double, VolumeInfoItem>();
      and which gets updated on new ticks at a line in the original code
      if (!volumeInfo.ContainsKey(price))
      volumeInfo.Add(price, new VolumeInfoItem());
      The length of the array appears to be "volumeInfo.Count", which can increase as new data arrives, and the elements of the array are price, and the accumulated three volumes volumeInfoItem.up, volumeInfoItem.down, and volumeInfoItem.neutral obtained by incrementing VolumeInfoItem() at each new tick.

      What I think I need is to create a copy of VolumeInfo after each update so that it is still available after a new bar starts.

      What I do not know is how to create the array that is a copy of VolumeInfo.

      Hope somebody can help
      Last edited by HNWtrader; 06-03-2010, 12:54 PM.

      Comment


        #4
        Hi HNWtrader,

        It sounds like you want to create/modify an array list, which, unfortunately, is outside the scope of support I can offer.
        TimNinjaTrader Customer Service

        Comment


          #5
          And here I thought there would be some elegant way to just clone an existing array.
          I think I can do it element by element... I will give it a try.

          Comment


            #6
            It turns out there is a simple way to copy the array. In the original code you find

            #region Variables
            internal class VolumeInfoItem
            {
            public double up = 0;
            public double down = 0;
            public double neutral = 0;
            .
            .
            .
            private SortedDictionary<double, VolumeInfoItem>
            volumeInfo = new SortedDictionary<double, VolumeInfoItem>();


            #endregion
            One or more lines need to be added here to make it

            #region Variables
            internal class VolumeInfoItem
            {
            public double up = 0;
            public double down = 0;
            public double neutral = 0;
            .
            .
            .
            private SortedDictionary<double, VolumeInfoItem>
            volumeInfo = new SortedDictionary<double, VolumeInfoItem>();
            private SortedDictionary<double, VolumeInfoItem>
            volumeInfo2 = new SortedDictionary<double, VolumeInfoItem>();
            private SortedDictionary<double, VolumeInfoItem>
            volumeInfo3 = new SortedDictionary<double, VolumeInfoItem>();
            private SortedDictionary<double, VolumeInfoItem>
            volumeInfo4 = new SortedDictionary<double, VolumeInfoItem>();


            #endregion
            Then in OnBarUpdate() you need something like the following to shift the array data from one array to another and then initialize a new array

            protected override void OnBarUpdate()
            .
            .
            if(FirstTickOfBar)
            {
            volumeInfo4 = volumeInfo3;
            volumeInfo3 = volumeInfo2;
            volumeInfo2 = volumeInfo;

            volumeInfo = new SortedDictionary<double, VolumeInfoItem>();
            }

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            3 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            238 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            384 views
            1 like
            Last Post Gavini
            by Gavini
             
            Started by oviejo, Today, 12:28 AM
            0 responses
            4 views
            0 likes
            Last Post oviejo
            by oviejo
             
            Started by pechtri, 06-22-2023, 02:31 AM
            10 responses
            125 views
            0 likes
            Last Post Leeroy_Jenkins  
            Working...
            X