For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Question Ichimoku? #218


  • administrators

    From Issue #218


    hI,

    I am checking Ichimoku, but i don´t know if the values are well calculated because I always got that chikou_span is Nan.

    cerebro = bt.Cerebro(runonce=False,oldsync=True)
    

    Chikou Span
    Closing price
    Shifted 26 periods back

    self.l.senkou_span_b = senkou_span_b(-self.p.senkou_lead)
    self.l.chikou_span = self.data.close(self.p.chikou)
    

    Should self.p.chikou have negative sign?

    self.l.chikou_span = self.data.close(-self.p.chikou)
    

    if i change runonce=False by runonce=True, i get the values of self.l.chikou_span

    Rgds,
    JJ


  • administrators

    Should self.p.chikou have negative sign?

    self.l.senkou_span_b = senkou_span_b(-self.p.senkou_lead)
    self.l.chikou_span = self.data.close(self.p.chikou)`
    

    No. The value is being shiftef back. The negative signs fetches values from the past, hence the negative sign, to the current point

    I am checking Ichimoku, but i don´t know if the values are well calculated because I always got that chikou_span is Nan.

    The test suite for Ichimoku running with runonce=True shows that all values are being calculated (can also be seen in the plot below)

    You are using oldsync=True. This may be the cause. The setting was left there several versions ago in case the new data feed synchronization mechanism would show flaws. But after some maturing time it seems robust.

    • Any reason to still use it?

    The plot (directly from a test run)

    0_1481299935750_upload-d7ee971a-be3b-421a-87c2-004118930ff2



  • Hi, i am combining Pivot Point and Ichimoku, but i calculate Pivot Point values using yesterday values.
    h = self.data.high(-1) # previous high
    l = self.data.low(-1) # previous low
    c = self.data.close(-1) # previous close

    I only get to run backtrader succesfully with oldsync=True, i am going to check today removing oldsync=True and i will attach the result.

    Rgds,
    JJ



  • Hi,

    I have removed oldsync=True and the code is running well.
    I have problems with the values of Ichimoku

    **Option 1: chikou_span is null

    cerebro = bt.Cerebro(runonce=False)**
    
    Indicators:
    timestamp;close;tenkan_sen;kijun_sen;senkou_span_a;senkou_span_b;chikou_span
    2016-03-18T00:00:00;360.4990;370.2505;376.3850;366.1344;375.2500;nan
    2016-03-19T00:00:00;360.7980;370.2505;376.3850;367.8300;375.2500;nan
    

    .................
    **Option 2: last values of chikou_span are null

    cerebro = bt.Cerebro(runonce=True)**
    Indicators:
    timestamp;close;tenkan_sen;kijun_sen;senkou_span_a;senkou_span_b;chikou_span
    2016-03-18T00:00:00;360.4990;370.2505;376.3850;366.1344;375.2500;376.1200
    2016-03-19T00:00:00;360.7980;370.2505;376.3850;367.8300;375.2500;376.9500
    2016-03-20T00:00:00;366.4550;368.4880;376.3850;369.9017;375.2500;381.0000
    ..........................
    **2016-11-15T00:00:00;666.0500;648.5165;625.2225;570.4360;547.6300;nan
    2016-11-16T00:00:00;689.9590;662.5165;639.0005;570.5160;547.6300;nan
    2016-11-17T00:00:00;694.9780;664.0115;647.9950;582.7977;558.6650;nan
    2016-11-18T00:00:00;703.9540;669.2405;653.2240;582.8400;558.6650;nan
    2016-11-19T00:00:00;705.7700;671.5115;656.9350;582.8400;560.5360;nan
    2016-11-20T00:00:00;687.0000;671.5115;657.5200;582.9435;562.0265;nan
    2016-11-21T00:00:00;699.0000;671.5115;659.6250;591.4380;573.2385;nan
    2016-11-22T00:00:00;708.5000;679.0650;659.6250;596.6875;577.7985;nan
    2016-11-23T00:00:00;700.9900;684.4885;659.6250;597.0648;577.7985;nan
    2016-11-24T00:00:00;702.2690;685.8980;659.6250;605.4462;585.1735;nan
    2016-11-25T00:00:00;698.3480;692.5000;659.6250;606.3302;585.2385;nan
    2016-11-26T00:00:00;694.5990;692.5000;659.6250;610.9455;585.2385;nan
    2016-11-27T00:00:00;696.0090;692.5000;659.6250;619.5390;593.4080;nan
    2016-11-28T00:00:00;694.5000;691.7550;659.6250;620.8195;593.4080;nan
    2016-11-29T00:00:00;693.3490;697.5765;660.2450;624.1425;596.4385;nan
    2016-11-30T00:00:00;702.5100;699.3600;668.1770;625.1950;596.4385;nan
    2016-12-01T00:00:00;710.4000;698.8850;669.9950;626.1900;596.4385;nan
    2016-12-02T00:00:00;724.9900;710.6100;682.0165;630.3900;596.4385;nan
    2016-12-03T00:00:00;713.4000;710.6100;682.0165;630.3900;596.4385;nan
    2016-12-04T00:00:00;724.5000;710.6100;682.0165;630.3900;596.4385;nan
    2016-12-05T00:00:00;708.9950;712.0500;682.0165;630.3925;596.4385;nan
    2016-12-06T00:00:00;716.0420;712.5000;682.0165;630.3925;596.4385;nan
    2016-12-07T00:00:00;722.9880;712.9310;682.0165;630.3925;596.4385;nan
    2016-12-08T00:00:00;728.0940;712.9310;682.0165;629.8525;600.7580;nan
    2016-12-09T00:00:00;732.0950;717.6280;689.5700;633.8185;601.1995;nan
    2016-12-10T00:00:00;735.1100;719.0350;695.0285;635.1047;603.2600;364.6966
    
    data = bt.feeds.GenericCSVData(          dataname=inputfile,
                            dtformat='%m/%d/%y',datetime=1,time=2,open=4,high=5,low=6,close=7,
                                volume=8,openinterest=9)  
    

    Data:

    Id,Date,Time,Type,Open,High,Low,Last,Volume,Open Interest
    X,01/01/16,00:00:00,Trade,397.80410,399.00000,394.00000,398.01514,1096.15766947,0
    X,01/02/16,00:00:00,Trade,398.48990,401.30000,396.10100,398.40000,2389.74983727,0
    X,01/03/16,00:00:00,Trade,398.40000,399.54000,389.10000,390.11100,3183.77541474,0
    X,01/04/16,00:00:00,Trade,389.89001,401.54099,389.10000,400.17986,4565.96768848,0
    X,01/05/16,00:00:00,Trade,400.02765,404.00000,398.71010,401.93992,4811.5375661,0
    X,01/06/16,00:00:00,Trade,401.91000,402.88668,397.09000,400.03001,2855.16860685,0
    X,01/07/16,00:00:00,Trade,400.03001,420.00000,399.00001,418.18670,9410.57613466,0
    X,01/08/16,00:00:00,Trade,418.06760,425.99998,411.11000,415.32000,6987.74556783,0
    X,01/09/16,00:00:00,Trade,415.30000,418.44178,409.45853,415.11000,2811.11644289,0
    X,01/10/16,00:00:00,Trade,415.11001,415.78001,404.25978,409.78000,2827.82390239,0
    X,01/11/16,00:00:00,Trade,409.78990,414.99000,408.42450,413.79000,4208.90366388,0
    X,01/12/16,00:00:00,Trade,413.81000,415.50000,411.00098,414.00000,4297.48269612,0
    X,01/13/16,00:00:00,Trade,413.69270,414.50000,389.69000,396.98000,7661.98296916,0
    X,01/14/16,00:00:00,Trade,396.98000,400.99900,392.45170,400.22649,4011.91149506,0
    X,01/15/16,00:00:00,Trade,400.20000,400.98000,347.38168,362.81000,16455.988689,0
    X,01/16/16,00:00:00,Trade,361.08000,363.29000,324.50000,349.29000,19616.1152043,0
    X,01/17/16,00:00:00,Trade,349.41000,361.89999,348.72010,356.40990,7795.61448764,0
    X,01/18/16,00:00:00,Trade,356.40990,358.50000,344.61001,356.20000,6430.67023176,0
    X,01/19/16,00:00:00,Trade,356.20011,358.30000,347.00000,348.61000,5181.60736564,0
    X,01/20/16,00:00:00,Trade,348.81090,385.00000,345.00000,378.25000,11994.3177951,0
    X,01/21/16,00:00:00,Trade,384.00000,393.30000,373.52000,377.48900,11081.0208615,0
    X,01/22/16,00:00:00,Trade,377.48900,381.77777,351.94767,354.54310,9291.31222397,0
    X,01/23/16,00:00:00,Trade,354.87414,368.42000,347.23000,362.28436,8289.87846111,0
    X,01/24/16,00:00:00,Trade,361.40335,375.80000,355.30000,375.25000,6867.78182809,0
    X,01/25/16,00:00:00,Trade,375.25000,376.71533,358.98500,362.63000,6894.01348893,0
    X,01/26/16,00:00:00,Trade,361.73303,369.56999,361.25000,364.69662,4919.80469083,0
    X,01/27/16,00:00:00,Trade,364.69663,366.99000,361.99000,363.83764,3001.22922115,0
    X,01/28/16,00:00:00,Trade,364.00000,366.27009,347.84000,350.96858,6000.17102469,0
    X,01/29/16,00:00:00,Trade,350.96858,357.00000,333.97866,350.00000,7673.1293277,0
    X,01/30/16,00:00:00,Trade,350.00000,353.95000,343.21300,349.99950,3299.72602735,0
    X,01/31/16,00:00:00,Trade,349.99950,351.99000,347.55900,350.38000,1726.48968412,0
    X,02/01/16,00:00:00,Trade,350.54899,350.75990,340.40001,342.76855,5355.59397933,0
    X,02/02/16,00:00:00,Trade,342.76820,344.99000,339.91100,342.80000,4796.27708556,0
    X,02/03/16,00:00:00,Trade,342.89999,344.21819,333.33300,336.39715,4701.14133059,0
    X,02/04/16,00:00:00,Trade,336.23210,346.47000,332.91100,344.91000,6070.96316889,0
    X,02/05/16,00:00:00,Trade,345.60000,351.00000,343.19783,346.52068,6400.27035321,0
    X,02/06/16,00:00:00,Trade,346.52068,347.19447,330.22000,336.31465,4977.15371927,0
    X,02/07/16,00:00:00,Trade,336.31465,341.77135,334.45090,335.49000,3488.0215186,0
    X,02/08/16,00:00:00,Trade,335.01000,340.00000,330.04223,332.31954,5070.27157873,0
    X,02/09/16,00:00:00,Trade,332.59510,336.50000,330.45000,332.99267,7041.4705894,0
    X,02/10/16,00:00:00,Trade,332.99266,343.25000,330.84379,336.55000,9580.82914836,0
    X,02/11/16,00:00:00,Trade,337.02000,340.63063,329.00000,329.00010,8045.75447894,0
    X,02/12/16,00:00:00,Trade,329.00010,339.90000,327.45688,337.56800,8586.78832146,0
    X,02/13/16,00:00:00,Trade,337.50001,347.00000,337.08085,345.49417,6521.97895511,0
    X,02/14/16,00:00:00,Trade,345.49418,357.09009,343.86304,355.80000,6827.31320601,0
    X,02/15/16,00:00:00,Trade,355.25817,364.46999,352.15000,359.02999,7065.26846362,0
    X,02/16/16,00:00:00,Trade,359.02998,367.22281,353.02721,365.64000,6374.23560372,0
    X,02/17/16,00:00:00,Trade,365.25001,376.41100,362.21100,376.40000,8079.48951061,0
    X,02/18/16,00:00:00,Trade,376.40000,382.59689,370.50000,377.99990,7541.03138694,0
    X,02/19/16,00:00:00,Trade,377.88900,379.75000,371.67000,375.25994,5317.25535199,0
    X,02/20/16,00:00:00,Trade,374.47011,397.87100,374.40000,395.18000,7479.3917998,0
    X,02/21/16,00:00:00,Trade,395.01000,400.00000,380.00000,385.33000,11292.9590965,0
    X,02/22/16,00:00:00,Trade,385.90000,394.89990,377.11100,393.99001,9592.95444759,0
    X,02/23/16,00:00:00,Trade,393.99001,395.60000,376.63729,379.33233,8555.14687993,0
    X,02/24/16,00:00:00,Trade,379.33232,384.99000,373.12200,384.64988,6227.82140706,0
    X,02/25/16,00:00:00,Trade,384.64988,387.98000,378.10000,383.20000,5662.16177998,0
    X,02/26/16,00:00:00,Trade,383.19999,388.68000,378.50001,386.19795,5508.64553257,0
    X,02/27/16,00:00:00,Trade,386.19999,397.48845,385.51100,392.72100,4574.07482724,0
    X,02/28/16,00:00:00,Trade,392.57000,395.40000,383.15022,393.99990,3677.77096421,0
    X,02/29/16,00:00:00,Trade,394.64997,399.99000,388.90000,398.40000,4884.02000274,0
    X,03/01/16,00:00:00,Trade,398.40000,399.83300,391.78000,397.70000,5988.07051192,0
    X,03/02/16,00:00:00,Trade,396.31200,397.96000,392.22000,393.89000,5335.85871958,0
    X,03/03/16,00:00:00,Trade,393.96800,394.94600,381.59710,381.61000,10733.1884421,0
    X,03/04/16,00:00:00,Trade,381.61000,387.49900,379.03100,379.66500,7788.22130749,0
    X,03/05/16,00:00:00,Trade,379.21200,379.21200,352.78000,362.30000,15073.4025369,0
    X,03/06/16,00:00:00,Trade,362.27000,371.88000,354.00000,370.00000,9085.44992301,0
    X,03/07/16,00:00:00,Trade,370.00000,374.58000,363.43000,373.00000,8375.12270496,0
    X,03/08/16,00:00:00,Trade,374.18900,376.00000,369.73000,372.10000,8246.96242986,0
    X,03/09/16,00:00:00,Trade,372.10000,375.99000,371.07900,373.27000,5913.3187262,0
    X,03/10/16,00:00:00,Trade,373.24000,381.00000,371.40000,371.40100,8840.52189813,0
    X,03/11/16,00:00:00,Trade,371.99900,381.50000,371.40000,377.18900,6932.42917518,0
    X,03/12/16,00:00:00,Trade,376.57100,377.97500,363.20500,365.07300,7894.28417006,0
    X,03/13/16,00:00:00,Trade,365.07400,372.00000,365.00000,367.98700,5192.47372824,0
    X,03/14/16,00:00:00,Trade,367.12100,373.56700,366.64100,371.72000,8177.22056151,0
    X,03/15/16,00:00:00,Trade,371.72000,376.04900,371.01000,374.63000,8254.08912053,0
    X,03/16/16,00:00:00,Trade,374.45000,375.99000,371.31100,372.90900,6908.04496528,0
    X,03/17/16,00:00:00,Trade,372.50000,375.00000,370.13000,372.20500,9032.13676796,0
    X,03/18/16,00:00:00,Trade,372.20400,373.07600,359.00100,360.49900,10248.5868975,0
    X,03/19/16,00:00:00,Trade,360.00100,365.49400,359.58000,360.79800,5151.63538982,0
    X,03/20/16,00:00:00,Trade,360.79800,367.77000,360.10700,366.45500,3700.93652302,0
    X,03/21/16,00:00:00,Trade,367.19600,367.30400,361.61500,366.99000,5385.35531127,0
    X,03/22/16,00:00:00,Trade,366.36500,372.90000,365.94200,371.52000,5961.13141604,0
    X,03/23/16,00:00:00,Trade,371.71000,372.99000,369.76900,372.98300,4386.24775743,0
    X,03/24/16,00:00:00,Trade,372.98900,375.00000,370.50000,372.69000,6890.77965768,0
    X,03/25/16,00:00:00,Trade,372.11100,374.21000,370.27500,372.92500,4303.70746272,0
    X,03/26/16,00:00:00,Trade,373.30000,375.50000,372.33000,373.78000,3532.46165339,0
    X,03/27/16,00:00:00,Trade,373.76400,385.99100,373.00200,383.51100,3896.2785285,0
    X,03/28/16,00:00:00,Trade,383.51100,384.70800,376.04300,376.60000,5234.2917685,0
    X,03/29/16,00:00:00,Trade,376.60000,379.78900,364.00000,368.38400,5503.48582505,0
    X,03/30/16,00:00:00,Trade,368.38200,369.99900,362.00000,365.00000,6129.215654,0
    X,03/31/16,00:00:00,Trade,365.44100,369.50000,364.00000,366.76000,7659.63642932,0
    X,04/01/16,00:00:00,Trade,366.76000,369.85900,365.56700,367.20100,4844.95984408,0
    X,04/02/16,00:00:00,Trade,367.03000,372.20000,366.50000,369.57900,2956.30810063,0
    X,04/03/16,00:00:00,Trade,369.95000,371.00000,367.56200,369.68200,1908.25141393,0
    X,04/04/16,00:00:00,Trade,369.68200,370.99000,366.32300,368.99800,5157.47767832,0
    X,04/05/16,00:00:00,Trade,368.99900,372.54000,368.30000,371.20000,5801.42650475,0
    X,04/06/16,00:00:00,Trade,371.68000,373.99000,370.25500,371.40000,5844.51963303,0
    X,04/07/16,00:00:00,Trade,371.40000,372.99000,367.41000,371.79000,5568.37467658,0
    X,04/08/16,00:00:00,Trade,371.80000,374.47000,370.73100,371.33900,4822.72122456,0
    X,04/09/16,00:00:00,Trade,371.33800,371.53700,364.30000,367.89800,4344.91206841,0
    X,04/10/16,00:00:00,Trade,367.78900,371.98000,366.75100,370.59900,3869.40712435,0
    X,04/11/16,00:00:00,Trade,370.22100,371.26900,368.39700,370.34600,4926.56259518,0
    X,04/12/16,00:00:00,Trade,370.38300,375.88900,370.00000,375.00000,5580.20251467,0
    X,04/13/16,00:00:00,Trade,375.00000,377.00000,372.37800,376.12000,7151.58023934,0
    X,04/14/16,00:00:00,Trade,376.00000,377.49900,374.76100,376.95000,3967.79007622,0
    X,04/15/16,00:00:00,Trade,376.95000,381.67000,376.48700,381.00000,5247.34111797,0
    X,04/16/16,00:00:00,Trade,381.00000,384.27100,379.36400,381.10800,2699.54680668,0
    X,04/17/16,00:00:00,Trade,381.04900,381.86300,375.30800,377.01000,2261.99189254,0
    X,04/18/16,00:00:00,Trade,377.14800,380.89000,375.25500,377.71900,4145.18155892,0
    X,04/19/16,00:00:00,Trade,377.71900,379.00000,376.49800,377.99900,3294.09390648,0
    X,04/20/16,00:00:00,Trade,378.01000,391.69600,377.51000,390.59900,6492.51071722,0
    X,04/21/16,00:00:00,Trade,390.11800,397.00000,388.12000,395.99900,5789.23616361,0
    X,04/22/16,00:00:00,Trade,396.00000,399.90000,392.70000,397.90000,4263.70912929,0
    X,04/23/16,00:00:00,Trade,397.89900,399.11100,395.10000,398.60000,2260.97218476,0
    X,04/24/16,00:00:00,Trade,398.60000,405.98000,396.62000,400.99000,4507.77068439,0
    X,04/25/16,00:00:00,Trade,400.99900,412.62000,400.51600,411.40000,5776.58153414,0
    X,04/26/16,00:00:00,Trade,411.40000,417.20000,408.87500,414.30000,6534.81972891,0
    X,04/27/16,00:00:00,Trade,414.30000,416.88000,397.28700,402.13000,5989.5154272,0
    X,04/28/16,00:00:00,Trade,402.96400,403.39000,384.31000,394.96400,8832.33060382,0
    X,04/29/16,00:00:00,Trade,395.22800,397.99000,392.62400,397.98000,4584.48901401,0
    X,04/30/16,00:00:00,Trade,397.97900,399.99000,390.42100,391.73000,4686.11721335,0
    X,05/01/16,00:00:00,Trade,391.45100,397.28100,390.26000,393.61100,2112.71766817,0
    X,05/02/16,00:00:00,Trade,394.20000,396.36900,382.00000,384.56000,6587.73246423,0
    X,05/03/16,00:00:00,Trade,384.53000,392.34000,384.10000,392.34000,4178.0307601,0
    X,05/04/16,00:00:00,Trade,391.53100,394.00000,387.27800,389.59000,3978.33360882,0
    X,05/05/16,00:00:00,Trade,389.56900,393.99000,388.87900,393.53000,4347.2744101,0
    X,05/06/16,00:00:00,Trade,393.52000,400.05000,392.24200,399.70000,5222.70312244,0
    X,05/07/16,00:00:00,Trade,399.52300,405.85000,399.12100,405.53000,3758.90734216,0
    X,05/08/16,00:00:00,Trade,405.53800,405.66000,399.93000,402.40000,1993.79950463,0
    X,05/09/16,00:00:00,Trade,402.38000,407.99000,400.45600,406.99800,5569.81611757,0
    X,05/10/16,00:00:00,Trade,406.65100,407.00000,394.55100,401.24900,5963.497491,0
    X,05/11/16,00:00:00,Trade,401.12800,401.64100,396.23200,396.72900,4790.41907852,0
    X,05/12/16,00:00:00,Trade,396.53000,398.99000,393.79400,397.16800,4794.15499886,0
    X,05/13/16,00:00:00,Trade,397.16900,404.68000,397.16800,404.12000,5690.88453247,0
    X,05/14/16,00:00:00,Trade,404.27700,404.64000,399.78400,403.54700,4047.97858302,0
    X,05/15/16,00:00:00,Trade,403.54700,405.76100,401.33300,404.83000,1999.25460783,0
    X,05/16/16,00:00:00,Trade,404.83000,406.20000,401.64000,404.02000,4685.99912262,0
    X,05/17/16,00:00:00,Trade,403.79000,404.04000,399.78500,402.80900,5520.63970557,0
    X,05/18/16,00:00:00,Trade,402.80000,404.99000,400.65600,404.98900,5735.26909847,0
    X,05/19/16,00:00:00,Trade,404.27100,405.61000,398.21300,399.86800,6860.44702883,0
    X,05/20/16,00:00:00,Trade,399.75000,399.83000,388.24200,395.03000,8880.38634472,0
    X,05/21/16,00:00:00,Trade,395.00000,396.99000,393.50000,395.23100,2955.49836609,0
    X,05/22/16,00:00:00,Trade,395.23100,396.47200,390.12800,390.91100,3674.80723782,0
    X,05/23/16,00:00:00,Trade,391.48800,395.98200,387.64600,393.93900,7233.18279578,0
    X,05/24/16,00:00:00,Trade,393.86000,400.39200,390.49000,399.98900,6403.29760391,0
    X,05/25/16,00:00:00,Trade,399.99000,403.42000,398.00000,401.47800,5088.99341304,0
    X,05/26/16,00:00:00,Trade,401.49000,404.99000,399.00100,404.05000,5517.810854,0
    X,05/27/16,00:00:00,Trade,403.79100,428.28000,402.02800,423.83500,11802.223034,0
    X,05/28/16,00:00:00,Trade,423.81100,448.00000,420.66500,442.69800,9510.79348017,0
    X,05/29/16,00:00:00,Trade,442.78600,497.66000,438.16000,487.00000,12703.6327027,0
    X,05/30/16,00:00:00,Trade,487.88900,496.97000,458.21200,479.87000,10074.5523609,0
    X,05/31/16,00:00:00,Trade,479.88900,488.81800,471.47100,476.32900,8783.35786161,0
    X,06/01/16,00:00:00,Trade,476.32800,485.47000,464.00000,475.17000,9185.20043643,0
    X,06/02/16,00:00:00,Trade,475.00000,482.40000,473.09000,480.04800,6744.36131677,0
    X,06/03/16,00:00:00,Trade,480.04800,508.71300,478.32000,503.89000,11406.4575946,0
    X,06/04/16,00:00:00,Trade,503.89000,520.81000,493.78000,501.00000,9632.42801538,0
    X,06/05/16,00:00:00,Trade,501.00900,515.38800,500.01000,507.50000,6097.57589232,0
    X,06/06/16,00:00:00,Trade,507.00000,518.09900,500.00000,513.12000,7443.32437711,0
    X,06/07/16,00:00:00,Trade,513.98900,519.97100,490.02100,506.68000,9391.85406365,0
    X,06/08/16,00:00:00,Trade,506.60000,512.56000,502.51400,509.38000,6043.72582637,0
    X,06/09/16,00:00:00,Trade,509.00500,512.87000,505.04000,508.92000,5794.87057928,0
    X,06/10/16,00:00:00,Trade,508.92000,515.00000,507.70700,513.99900,4418.43049454,0
    X,06/11/16,00:00:00,Trade,513.91000,523.00000,513.91000,519.99000,4959.56406994,0
    X,06/12/16,00:00:00,Trade,519.95000,579.00000,518.50000,571.01000,14904.7303421,0
    X,06/13/16,00:00:00,Trade,571.97000,634.87900,571.00000,608.90600,23121.2429669,0
    X,06/14/16,00:00:00,Trade,608.84000,627.00000,587.34000,610.17900,12980.470077,0
    X,06/15/16,00:00:00,Trade,609.99900,620.00000,598.24000,619.70000,7710.74777201,0
    X,06/16/16,00:00:00,Trade,619.73900,684.88800,614.05000,679.04900,16548.5032286,0
    X,06/17/16,00:00:00,Trade,678.98900,696.26700,624.92800,670.10000,20100.8173115,0
    X,06/18/16,00:00:00,Trade,670.46600,691.50000,643.36200,686.00000,11884.723105,0
    X,06/19/16,00:00:00,Trade,686.31000,694.26000,660.00000,678.28900,7988.07230426,0
    X,06/20/16,00:00:00,Trade,678.00000,681.01900,622.56900,658.70000,11612.1903842,0
    X,06/21/16,00:00:00,Trade,658.00100,658.69000,570.01000,582.72200,23270.9472531,0
    X,06/22/16,00:00:00,Trade,585.69900,605.50000,545.22200,561.00000,17581.8249823,0
    X,06/23/16,00:00:00,Trade,560.81100,565.50000,490.25600,552.30000,24981.3143356,0
    X,06/24/16,00:00:00,Trade,547.00000,645.19200,536.00000,597.53800,24695.2586649,0
    X,06/25/16,00:00:00,Trade,604.52100,628.00000,584.00000,593.87000,8365.21023175,0
    X,06/26/16,00:00:00,Trade,595.00000,618.00000,555.99900,572.71400,7398.42345992,0
    X,06/27/16,00:00:00,Trade,573.22900,602.75000,568.12000,585.21100,6401.33864924,0
    X,06/28/16,00:00:00,Trade,590.12900,605.00000,579.17600,590.47600,6673.35720405,0
    X,06/29/16,00:00:00,Trade,590.76600,594.77600,555.63400,578.00000,10084.7435971,0
    X,06/30/16,00:00:00,Trade,578.00000,614.02700,573.00000,603.25000,9338.24520643,0
    X,07/01/16,00:00:00,Trade,604.39000,619.95000,600.65200,608.18900,8362.11365623,0
    X,07/02/16,00:00:00,Trade,610.29900,628.00000,606.00000,626.00000,5794.10829018,0
    X,07/03/16,00:00:00,Trade,626.00000,634.00000,581.85000,594.30400,7821.85335231,0
    X,07/04/16,00:00:00,Trade,594.30400,614.90000,583.32000,605.99900,6720.15140361,0
    X,07/05/16,00:00:00,Trade,606.00000,617.22200,600.00000,612.74000,7017.29587592,0
    X,07/06/16,00:00:00,Trade,612.74000,620.55000,606.61100,614.99000,5489.43590612,0
    X,07/07/16,00:00:00,Trade,614.99000,618.48600,555.51100,565.77000,11418.4395057,0
    X,07/08/16,00:00:00,Trade,565.41300,601.52100,553.85000,597.20000,6796.83815587,0
    X,07/09/16,00:00:00,Trade,597.24100,610.00000,562.52200,586.64800,7532.94687332,0
    X,07/10/16,00:00:00,Trade,586.42400,596.20000,580.05400,585.56200,2229.46864378,0
    X,07/11/16,00:00:00,Trade,587.67700,597.00000,584.14100,590.15000,3822.08179734,0
    X,07/12/16,00:00:00,Trade,590.26400,610.00000,585.00000,609.45000,5833.34451494,0
    X,07/13/16,00:00:00,Trade,609.50000,611.80000,595.01000,598.10800,4994.93406941,0
    X,07/14/16,00:00:00,Trade,598.10800,600.99000,590.50000,598.47800,3538.95966946,0
    X,07/15/16,00:00:00,Trade,598.47100,604.88000,596.01300,604.29400,2965.28402595,0
    X,07/16/16,00:00:00,Trade,604.29400,606.73900,599.35600,602.49000,2149.18646742,0
    X,07/17/16,00:00:00,Trade,602.49000,622.65000,601.72000,618.99000,4115.08416724,0
    X,07/18/16,00:00:00,Trade,618.99000,619.99000,608.30000,608.87000,4916.89340462,0
    X,07/19/16,00:00:00,Trade,610.72900,612.99000,602.07200,608.27000,2489.77987805,0
    X,07/20/16,00:00:00,Trade,609.99900,612.99000,602.19000,605.01000,3687.24208295,0
    X,07/21/16,00:00:00,Trade,605.00100,606.99000,598.84100,604.69000,3149.63092675,0
    X,07/22/16,00:00:00,Trade,604.69000,605.99900,591.71000,600.00300,3888.16882589,0
    X,07/23/16,00:00:00,Trade,600.00100,602.99000,590.00000,599.41500,3016.45712652,0
    X,07/24/16,00:00:00,Trade,600.99000,605.52500,596.90500,603.82000,2519.82629024,0
    X,07/25/16,00:00:00,Trade,603.82000,604.86000,593.05100,595.95400,3628.76446341,0
    X,07/26/16,00:00:00,Trade,595.44000,597.30100,581.05000,596.29900,5601.51961795,0
    X,07/27/16,00:00:00,Trade,594.96500,598.10000,586.66600,593.11100,4996.14397133,0
    X,07/28/16,00:00:00,Trade,594.79000,595.42800,588.71100,591.68800,2909.93398744,0
    X,07/29/16,00:00:00,Trade,590.35300,592.16900,587.61000,588.90000,2841.47085546,0
    X,07/30/16,00:00:00,Trade,588.90000,589.30300,585.01000,585.96000,1531.01044524,0
    X,07/31/16,00:00:00,Trade,585.96000,589.30300,563.08500,565.02000,4393.56480515,0
    X,08/01/16,00:00:00,Trade,565.00000,589.30300,543.81000,545.49100,7119.5334448,0
    X,08/02/16,00:00:00,Trade,544.91100,589.30300,496.34400,507.20000,13381.5628394,0
    X,08/03/16,00:00:00,Trade,507.18100,518.99000,430.00000,513.68000,27729.0951432,0
    X,08/04/16,00:00:00,Trade,512.86000,529.00000,506.22200,513.59700,9823.71352825,0
    X,08/05/16,00:00:00,Trade,520.24000,528.93000,511.53000,522.90500,4274.53267439,0
    X,08/06/16,00:00:00,Trade,521.99700,536.12800,515.00000,531.61000,4096.17031646,0
    X,08/07/16,00:00:00,Trade,531.72100,548.24000,527.35000,535.60000,4799.5146655,0
    X,08/08/16,00:00:00,Trade,535.60000,541.81600,534.00000,539.99700,2989.2407315,0
    X,08/09/16,00:00:00,Trade,539.86800,541.58000,529.32000,530.15100,4649.95417871,0
    X,08/10/16,00:00:00,Trade,530.15100,540.00000,521.00000,538.78200,5478.88523963,0
    X,08/11/16,00:00:00,Trade,538.78100,538.78100,530.00000,532.99000,4091.89116973,0
    X,08/12/16,00:00:00,Trade,531.79000,532.99000,521.31000,524.78100,3908.10338301,0
    X,08/13/16,00:00:00,Trade,525.37600,528.98000,522.92700,527.19900,1747.18267759,0
    X,08/14/16,00:00:00,Trade,526.92200,527.20000,502.00000,503.46200,3713.82648987,0
    X,08/15/16,00:00:00,Trade,504.92000,513.51700,501.11000,506.96600,4005.81584358,0
    X,08/16/16,00:00:00,Trade,506.14500,521.13000,503.03200,517.12000,5172.14784827,0
    X,08/17/16,00:00:00,Trade,515.77700,518.99000,506.21000,507.56700,3004.01196422,0
    X,08/18/16,00:00:00,Trade,507.25000,511.48600,506.00000,509.50000,3461.57003587,0
    X,08/19/16,00:00:00,Trade,509.50000,513.67000,505.70000,510.00000,3391.50255935,0
    X,08/20/16,00:00:00,Trade,510.00000,518.05000,507.90000,514.90000,1922.48356872,0
    X,08/21/16,00:00:00,Trade,514.88900,517.83000,511.22000,514.98000,1528.90392108,0
    X,08/22/16,00:00:00,Trade,514.98000,520.95000,512.12000,518.78800,3332.77490266,0
    X,08/23/16,00:00:00,Trade,518.99000,519.81700,513.56300,515.78900,3842.52889435,0
    X,08/24/16,00:00:00,Trade,515.77000,517.59200,513.00000,516.10000,3213.59146643,0
    X,08/25/16,00:00:00,Trade,516.08000,516.10000,508.00100,510.01000,3482.65756215,0
    X,08/26/16,00:00:00,Trade,510.01000,515.74400,508.21000,515.68000,3444.13769267,0
    X,08/27/16,00:00:00,Trade,515.68000,516.49800,505.55000,508.28000,2334.4297248,0
    X,08/28/16,00:00:00,Trade,508.31000,512.99000,507.46200,510.60000,1482.91630349,0
    X,08/29/16,00:00:00,Trade,510.51000,516.58700,510.00000,512.70000,2942.43905903,0
    X,08/30/16,00:00:00,Trade,512.66100,518.54000,511.00900,517.10200,3495.43546011,0
    X,08/31/16,00:00:00,Trade,517.00000,518.11000,511.73600,514.59900,3024.63215053,0
    X,09/01/16,00:00:00,Trade,514.59000,514.96000,508.91000,511.48900,3485.69064702,0
    X,09/02/16,00:00:00,Trade,511.48900,513.99000,507.69800,512.99000,3379.4462727,0
    X,09/03/16,00:00:00,Trade,512.99000,515.00000,511.44000,514.69000,2628.43417554,0
    X,09/04/16,00:00:00,Trade,514.69000,549.00000,514.42100,544.98000,7593.07907811,0
    X,09/05/16,00:00:00,Trade,544.97200,546.20400,536.88900,542.31900,3789.71916759,0
    X,09/06/16,00:00:00,Trade,541.63200,547.49600,538.85100,543.96000,3685.88681471,0
    X,09/07/16,00:00:00,Trade,543.96000,546.99000,538.14000,546.43800,3011.89813204,0
    X,09/08/16,00:00:00,Trade,546.42000,557.43000,544.63000,554.87000,4719.07481076,0
    X,09/09/16,00:00:00,Trade,554.87000,556.49000,548.00000,552.90000,2989.75075634,0
    X,09/10/16,00:00:00,Trade,552.41100,557.85500,552.12100,557.48700,1929.11156816,0
    X,09/11/16,00:00:00,Trade,557.48400,562.49900,553.84500,559.45100,1975.8742122,0
    X,09/12/16,00:00:00,Trade,560.00000,560.55500,524.88800,540.98900,5823.8372459,0
    X,09/13/16,00:00:00,Trade,540.98900,545.22000,540.00000,545.19000,3472.24529706,0
    X,09/14/16,00:00:00,Trade,545.17200,547.16800,542.92100,544.42000,3372.40283738,0
    X,09/15/16,00:00:00,Trade,544.42000,544.97000,540.12100,542.04000,2792.88177272,0
    X,09/16/16,00:00:00,Trade,542.04000,544.99000,540.00000,544.50000,4082.23364008,0
    X,09/17/16,00:00:00,Trade,544.50000,545.00000,541.60100,543.54900,1535.41765002,0
    X,09/18/16,00:00:00,Trade,543.54900,545.69000,541.67400,545.65000,1953.40473265,0
    X,09/19/16,00:00:00,Trade,545.64900,546.22500,543.28500,544.47500,2841.15493014,0
    X,09/20/16,00:00:00,Trade,544.45000,545.64900,542.51000,543.40700,3686.17308315,0
    X,09/21/16,00:00:00,Trade,543.40700,545.35500,520.47700,534.50000,5265.32666897,0
    X,09/22/16,00:00:00,Trade,534.50000,534.98900,529.11600,532.00000,4163.13813055,0
    X,09/23/16,00:00:00,Trade,531.88100,537.68000,529.99900,537.68000,3179.90454624,0
    X,09/24/16,00:00:00,Trade,537.66000,539.99000,535.50000,538.65700,2025.99561435,0
    X,09/25/16,00:00:00,Trade,538.65700,539.08800,534.12000,535.67900,1302.75492251,0
    X,09/26/16,00:00:00,Trade,535.67900,542.82800,534.44000,541.13100,2800.12388838,0
    X,09/27/16,00:00:00,Trade,540.34500,543.37500,539.42700,541.97000,3180.05038367,0
    X,09/28/16,00:00:00,Trade,541.41100,547.69200,539.83000,542.20000,3353.93498202,0
    X,09/29/16,00:00:00,Trade,542.50900,545.13000,539.58600,542.39500,3486.33555451,0
    X,09/30/16,00:00:00,Trade,542.39500,545.75100,540.00000,543.85800,3418.26644245,0
    X,10/01/16,00:00:00,Trade,543.85700,553.83900,541.24200,551.74800,3621.79242862,0
    X,10/02/16,00:00:00,Trade,550.53500,552.71500,544.00100,545.98900,1352.01210165,0
    X,10/03/16,00:00:00,Trade,545.98900,548.97300,544.04700,547.48900,2200.56677779,0
    X,10/04/16,00:00:00,Trade,547.39000,548.00000,544.00000,545.88400,3084.24599635,0
    X,10/05/16,00:00:00,Trade,545.88300,552.48300,544.32000,550.99900,3855.79945332,0
    X,10/06/16,00:00:00,Trade,551.00000,553.38000,547.78200,551.84500,3209.42467711,0
    X,10/07/16,00:00:00,Trade,551.84500,560.79000,549.47800,557.29800,3633.59024275,0
    X,10/08/16,00:00:00,Trade,557.29900,559.46000,552.26600,554.82000,1662.38991289,0
    X,10/09/16,00:00:00,Trade,554.81900,555.96600,552.25500,554.99000,1159.17965042,0
    X,10/10/16,00:00:00,Trade,554.99000,558.85400,551.72000,557.40000,3103.69214964,0
    X,10/11/16,00:00:00,Trade,557.31900,579.00000,555.70000,577.70000,6104.40271322,0
    X,10/12/16,00:00:00,Trade,577.70000,586.61000,576.50200,580.95300,4353.96148003,0
    X,10/13/16,00:00:00,Trade,580.99000,582.35300,573.93000,575.55000,3596.87196918,0
    X,10/14/16,00:00:00,Trade,575.54900,584.70000,572.50000,583.45000,5106.6380422,0
    X,10/15/16,00:00:00,Trade,583.99000,587.56200,581.30000,584.84900,2096.13812005,0
    X,10/16/16,00:00:00,Trade,584.95900,587.04200,578.71100,584.88800,2064.74023509,0
    X,10/17/16,00:00:00,Trade,584.88800,585.99900,580.11900,581.94000,2975.49953561,0
    X,10/18/16,00:00:00,Trade,581.94000,585.34500,579.00100,582.46700,4142.73637894,0
    X,10/19/16,00:00:00,Trade,582.41000,582.99000,572.51000,575.71200,4985.64115453,0
    X,10/20/16,00:00:00,Trade,575.71200,583.00000,574.01900,578.54000,3393.46787506,0
    X,10/21/16,00:00:00,Trade,578.54000,584.00000,578.04500,582.99000,2881.82836724,0
    X,10/22/16,00:00:00,Trade,582.99000,609.63200,581.00100,602.40000,5492.09672178,0
    X,10/23/16,00:00:00,Trade,602.00000,605.88000,597.30000,599.56900,2884.11447321,0
    X,10/24/16,00:00:00,Trade,601.50000,602.00000,596.00000,600.88900,3749.83481658,0
    X,10/25/16,00:00:00,Trade,600.88900,606.69859,598.88000,604.11000,4567.62422931,0
    X,10/26/16,00:00:00,Trade,604.86000,626.00000,600.05000,623.66000,6391.30894438,0
    X,10/27/16,00:00:00,Trade,623.66000,635.12000,617.23800,628.99000,6308.81606756,0
    X,10/28/16,00:00:00,Trade,629.31100,634.00000,626.01100,629.02100,4662.99774369,0
    X,10/29/16,00:00:00,Trade,629.02100,649.87000,626.22000,648.00000,7036.55916486,0
    X,10/30/16,00:00:00,Trade,648.00000,650.00000,626.00000,635.96000,4300.6480305,0
    X,10/31/16,00:00:00,Trade,636.07000,646.22300,616.51000,643.88900,5853.80457582,0
    X,11/01/16,00:00:00,Trade,637.30000,666.33900,633.41600,658.16300,7011.86721676,0
    X,11/02/16,00:00:00,Trade,659.98700,662.00000,648.00000,657.73500,4445.95803025,0
    X,11/03/16,00:00:00,Trade,657.73400,672.40000,604.26000,636.60600,12796.5450508,0
    X,11/04/16,00:00:00,Trade,636.60500,639.50000,605.50000,626.65400,9658.53444017,0
    X,11/05/16,00:00:00,Trade,626.68000,634.70000,621.36400,630.50900,3261.15084435,0
    X,11/06/16,00:00:00,Trade,630.39000,642.00000,625.00000,634.49000,3110.90570975,0
    X,11/07/16,00:00:00,Trade,634.49000,643.00000,629.34500,635.10000,3338.46195196,0
    X,11/08/16,00:00:00,Trade,635.00000,646.96400,632.00000,643.45900,4332.9198452,0
    X,11/09/16,00:00:00,T,643.41000,669.00000,638.50000,662.22300,10720.9414852,0
    X,11/10/16,00:00:00,T,661.76700,664.90000,651.00000,653.00000,4421.68660534,0
    X,11/11/16,00:00:00,T,655.00000,664.26200,651.11500,660.93900,4026.92325377,0
    X,11/12/16,00:00:00,T,660.93900,661.99900,643.34900,646.67600,3399.69800585,0
    X,11/13/16,00:00:00,T,646.99000,649.20700,628.03300,644.70000,5016.97117224,0
    X,11/14/16,00:00:00,T,644.70000,657.33400,643.14000,655.99800,4280.75519965,0
    X,11/15/16,00:00:00,T,657.35200,667.76600,653.98700,666.05000,4708.80165365,0
    X,11/16/16,00:00:00,T,661.69400,697.00000,656.80600,689.95900,9481.42073527,0
    X,11/17/16,00:00:00,T,689.90000,699.99000,677.86000,694.97800,6673.19476117,0
    X,11/18/16,00:00:00,T,694.97800,710.44800,685.12700,703.95400,5097.53489709,0
    X,11/19/16,00:00:00,T,703.95400,714.99000,691.00000,705.77000,2982.91250349,0
    X,11/20/16,00:00:00,T,705.77000,710.00000,670.01000,687.00000,5218.72284442,0
    X,11/21/16,00:00:00,T,684.88400,701.44400,681.65300,699.00000,4395.14491877,0
    X,11/22/16,00:00:00,T,698.99900,713.50000,689.01000,708.50000,6107.88151655,0
    X,11/23/16,00:00:00,T,708.50000,708.54900,692.10000,700.99000,5654.09886741,0
    X,11/24/16,00:00:00,T,700.97500,705.00000,692.10000,702.26900,4759.29998283,0
    X,11/25/16,00:00:00,T,702.24800,702.40100,691.30600,698.34800,3965.07751652,0
    X,11/26/16,00:00:00,T,698.34700,702.67900,685.22000,694.59900,3112.99626354,0
    X,11/27/16,00:00:00,T,694.59900,699.11000,688.10000,696.00900,1592.2833973,0
    X,11/28/16,00:00:00,T,696.59300,698.50000,689.00000,694.50000,3499.81921455,0
    X,11/29/16,00:00:00,T,694.50000,695.99900,691.01800,693.34900,3559.64347847,0
    X,11/30/16,00:00:00,T,693.34900,703.83000,689.86200,702.51000,4794.6070315,0
    X,12/01/16,00:00:00,T,702.90000,712.55000,699.25600,710.40000,4854.0293682,0
    X,12/02/16,00:00:00,T,710.40000,736.00000,705.42000,724.99000,7372.06260984,0
    X,12/03/16,00:00:00,T,724.99000,731.17400,713.20000,713.40000,1787.77035284,0
    X,12/04/16,00:00:00,T,722.49400,730.00000,719.28000,724.50000,1877.22319175,0
    X,12/05/16,00:00:00,T,724.98600,735.12000,702.00000,708.99500,7328.55623023,0
    X,12/06/16,00:00:00,T,708.99400,720.00000,704.24000,716.04200,5544.95616896,0
    X,12/07/16,00:00:00,T,717.10900,724.84200,711.94400,722.98800,4397.10671533,0
    X,12/08/16,00:00:00,T,722.98700,729.29900,712.95000,728.09400,4068.52461627,0
    X,12/09/16,00:00:00,T,729.69900,735.70000,724.31100,732.09500,3741.57034565,0
    X,12/10/16,00:00:00,T,732.95000,736.07000,731.59100,735.11000,729.24234807,0
    

  • administrators

    The last values of chikou_span MUST and WILL BE NaN.

    chikou_span lags 26 days. That doesn't mean that at point [0] (current instant) you get the value that was there 26 periods ago.

    See for example: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:ichimoku_cloud

    Check the 1st chart and see how chikou_span stops producing data 26 bars before the end of the chart.

    If you double check against the chart above, the case is exactly the same.

    The difference in the charts is that hte StockCharts version also gives you the leading values into the future. Originally backtrader had a parameter in Cerebro called lookahead which was meant to support such scenarios. But given the mix of use cases supported, it makes little sense to try to support that.

    The test cases in the backtrader suite show also that the last value of chikou_span is NaN. And additionally that values are produced at some other points in time (both with runonce=True and with runonce=False)



  • Thanks, i have read again the definition, and i agree with you. All is working well.