Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Idea for study to plot an instrument chart sliced in cycles & in dollar change terms

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

    #16
    Hello futurenow,

    Thank you for your reply.

    You'd simply want to draw a line when you reset everything to 0 at the start of the new month. You'd want to ensure the tag name is unique for each one, so in the following example, I'm using both the month and the current bar number in the tag to ensure each is unique and will not be replaced instead of a new line being drawn:

    Code:
     // if it's a different month reset to 0 on the first tick of the new month's first bar
    else if (CurrentMonth != Time[0].Month && IsFirstTickOfBar)
    {
    // reset current month to our new month
    CurrentMonth = Time[0].Month;
    //reset CurrentStartValue to the open of the current month
    CurrentStartValue = Open[0];
    // set open of this month's first bar to 0
    IndOpen[0] = 0;
    [B]Draw.VerticalLine(this, "Month " + Time[0].Month + " " + CurrentBar, Time[0], Brushes.Yellow);[/B]
    }
    I've also noticed that the previous example has some issues with scaling since we've set the plots to Transparent, which makes the autoscaling not work correctly. I've overridden OnCalculateMinMax as well as added the yellow line on the break of each month in the below version of the script so that it scales correctly.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #17
      Hello

      I’m just trying to test this script '
      ExamplePlotNetChangeCandles' with the Strategy Builder, and it works as should when you add a condition like:

      If (IndClose[0] > NumericValue)
      //do something



      But when the condition is in the next form:

      If (IndClose[0] > IndClose[1])
      //do something


      Then the Builder displays the Error message you see in the attached picture “Unhandled exception: An item with the same key has already been added.”

      This Error message is also displayed when for example you use more than 1 condition even if previously the first condition initialy worked as should.

      I think this is first time I see this Error message, so what could be happening in these cases? Because the interesting would be to able work with the script with the Builder.


      As reference, I tried with 2 different PCs and I got the same result, with the same Error message in both cases.


      Thank you!



      Click image for larger version

Name:	ExamplePlotNetChangeCandles - Unhandled exception - An item with the same key has already been added.png
Views:	262
Size:	4.5 KB
ID:	1196777

      Comment


        #18
        Hello futurenow,

        Thank you for your reply.

        The example really isn't intended for live trading or copy/paste purposes, but the issue is with line 64 where it gets the brush from the axis pen. If you change that to use a brush of your chosen color, you won't get the error anymore when trying to compare two instances. For example:

        ShadowColor = Brushes.RoyalBlue;

        Please let us know if we may be of further assistance to you.

        Comment


          #19
          Hello

          Thank you for your last post!


          Now I’m trying to add 2 DataSeries into the code but I can’t get the expected result.

          If you load the script you attached in a previous post of this thread then it loads as should making the process to start from 0 every month, but I’m noticing that when I try to add 2 DataSeries, then the script doesn’t make the process to start from 0 every month even when I try to adapt the code to take into account the fact of adding the 2 extra DataSeries. The plotted lines-on-close start from 0 for the first bar loaded in the chart, but that’s all and now the plots don’t start from 0 for the next months. It is like if for the 2 added DataSeries, the code doesn’t recognize that every month it has to make the plots to start from 0.

          I also noticed that when I modify the 2nd added DataSeries ticker, let’s say changing it from ‘CL 06-22’ to ‘GC 06-22‘, then the line-on-close plotted in the chart for the 1st added DataSeries gets modified with other zig-zags shapes and others Y-axis values in general and I don’t understand why this happens if the idea is that the 2nd added DataSeries needs to be independent of the 1st added DataSeries.

          Bellow I attached the modified script trying to add the 2 DataSeries I described, to see if you could help me to solve this part that I have not been able to get a solution. I have a couple days doing modifications trying to get the desired result that is the script only works with the 2 added DataSeries and consequently skipping the main DataSeries loaded in the chart and that the script works always in the same way regardless of the main instrument/s loaded in the chart, where the only needed function of the chart is to make the added DataSeries match into the time-frame specified in the chart, i.e. that the added DataSeries automatically match with the time-frame selected in the chart, either being intraday or daily+ time-frames like: 5 min, 120 min, 1 day, 1 week, …


          Thank you in advance!


          Attached Files

          Comment


            #20
            Note:

            During these days I’ve made many small modifications and variations of the code and now I just noticed that the 2nd added DataSeries shows values in the Data Box or in the mini Data Box, but it doesn’t plot anything in the chart, so maybe I missed some small detail but the general idea is still there in the code in basically the same form with also what I just wrote here as the main reference.

            Thank you!

            Comment


              #21
              Hello futurenow,

              Thank you for your replies.

              I've been taking a look at this today and it's not really designed to work with multiple secondary series as input. I'm in the process of seeing if I can get it to properly plot from a single secondary series, however, I haven't gotten that working yet. I'll work on this further tomorrow and let you know my findings.

              Thanks in advance; I look forward to assisting you further.

              Comment


                #22
                Hello futurenow,

                Thank you for your patience.

                Took me a bit but I've got an example of using a secondary data series to plot a single secondary instrument series - I'd recommend simply making different versions for different added instruments.

                Please let us know if we may be of further assistance to you.
                Attached Files

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                566 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                548 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X