Access the furthest close price on my chart's AggregationPeriod

Discussion in 'Strategy Building' started by Bayonetta, Sep 14, 2020.

  1. Bayonetta

    Bayonetta

    hey everyone, I'm currently using a 15 min chart and the furthest that I can go in a 15 min bar chart is 6 months back. I try accessing the furthest close price on my chart's AggregationPeriod with the code below but had no luck. Any suggestions in what I'm missing :(

    declare lower;
    input symbol = "NQ";
    def agg = (AggregationPeriod.MONTH)*6;
    plot data = close(period = agg);
     
  2. Did you mean this instead?
    declare lower;
    input symbol = "NQ";
    def agg = AggregationPeriod.MONTH;
    plot data = close(period = agg)[5];
     
  3. Bayonetta

    Bayonetta

    by trial & error apparently I saw that they are not exact in the number of days that they consider 6 months. If you do March 31 to now September 14, there are 7 different months that we access.
     
    Last edited: Sep 14, 2020
  4. Bayonetta

    Bayonetta

  5. Bayonetta

    Bayonetta

    This code worked for the current bar price:


    def isLastBar = !IsNaN(close) and IsNaN(close[-1]);

    plot LastBarSignal = isLastBar;

    LastBarSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);



    but when I try to get the last in my chart it doesn't work:


    def isLastBar = !IsNaN(close) and priceType.LAST from 17520 bars ago);

    plot LastBarSignal = isLastBar;

    LastBarSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);


    any thoughts?
     
  6. If you are desiring to capture the Closing price of the first bar (far left) of your chart, you can reference First(close)! Or you could do something like def FirstClose=if(barnumber() == 1) then close else FirstClose[1];
     
    Bayonetta likes this.