Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © firerider
- //@version=4
- study("Sunspots")
- // from https://wwwbis.sidc.be/silso/eisnplot
- varip int[] sunspots = array.from(18,21,16,15,10,0,0,15,15,22,37,35,31,26,26,23,18,13,0,13,18,31,38,38,34,25,13,12,12,12,16,17,14,14,12,12,36,38,59,56,50,44,41,43,33,30,30,43,23,20,20,17,17,15,30,29,27,14,14,23,37,36,39,28,0,12,17,0,0,34,36,31,33,27,23,28,30,22,14,22,17,14,17,23,22,34,31,33,33,27,22,22,24,33,34,25,21,29,9,10,10,10,9,0,0,0,0,0,0,0,9,9,0,0,16,0,0,10,0,9,13,21,40,51,47,19,16,16,0,0,0,0,0,0,0,0,0,0,0,0,14,21,22,19,24,16,13,13,19,29,18,15,18,21,28,26,12,18,14,29,39,46,46,25,14,0,0,12,12,26,18,14,15,14,12,17,18,11,11,22,11,13,13,13,14,27,25,13,13,17,22,36,34,30,17,25,16,14,14,14,30,31,36,44,47,39,33,19,34,38,31,30,24,24,14,32,51,51,48,38,55,58,67,50,41,33,38,51,26,23,15,12,0,0,0,12,23,23,12,12,27,29,30,30,58,49,58,43,29,14,0,0,16,12,13,26,27,27,43,53,51,49,39,38,36,39,39,39,49,56,55,55,48,36,27,29,21,13,0,0,0,13,13,13,13,23,37,41,49,57,60,63,51,36,36,44,60,67,63,41,31,39,33,34,21,18,18,14,27,35,37,37,30,48,51,48,69,61,61,59,56,46,42,32,27,24,26,13,24,14,13,27,29,24,32,36,41,53,44,29,31,31,29,36,27,27,47,27,14,24,12,0,0,0,0,17,17,14,25,34,17,22,19,14,42,48,48,47,48,36,28,35,25,32,26,25,22,13,0,12,20,28,32,26,29,33,32,33,29,28,25,20,13,15,19,20,24,21,29,36,26,18,15,64,51,34,57,60,78,87,83,78,65,85,82,69,47,38,31,24,13,42,44,51,62,56,73,99,116,130,138,141,113,83,83,83,93,61,48,38,38,28,32,30,24,45,42,55,97,101,118,124,104,96,87,67,63,60,67,56,57,81,84,78,56,67,92,111,123,127,92,71,71,71,73,80,87,78,64,56,74,73,62,62,80,70,55,71,76,76,45,43,63,84,90,66,46,36,52,57,57,50,41,36,35,36,56,31,11,24,42,63,73,98,115,106,126,135,130,115,80,70,58,45,39,33,23,17,15,36,52,59,59,61,47,39,50,50,58,65,50,27,15,38,41,49,56,44,41,46,32,34,38,63,49,59,75,72,68,68,82,74,93,115,109,71,60,54,43,43,29,43,63,96,90,91,99,107,95,81,92,88,79,79,70,61,36,38,29,18,0,12,31,51,59,60,59,73,92,98,70,65,86,77,64,56,90,125,131,136,140,105,114,89,72,54,72,80,94,139,145,169,191,191,160,143,142,123,108,109,91,116,122,112,103,109,128,116,118,118,113,128,100,100,89,69,79,90,124,146,161,170,148,154,176,156,141,183,194,174,134,130,110,104,93,101,94,103,96,125,128,125,99,114,145,173,171,177,170,162,157,162,164,141,125,121,132,128,137,127,138,142,131,158,131,124,98,135,132,129,127,154,162,151,151,132,159,114,102,93,76,81,78,57,75,90,100,115,108,109,103,103,84,97,117,114,109,112,93,93,71,92,120,126,109,113,113,104,79,70,63,52,71,118,149,154,141,126,105,102,112,109,113,86,76,49,65,45,57,62,75,89,59,35,38,29,42,32,13,29,46,46,49,65,58,54,48,49,55,70,64,59,44,55,58,48,48,44,39,20,24,27,63,86,108,115,106,97,110,104,116,116,96,85,88,85,88,62,74,86,77,70,71,94,89,88,84,88,106,94,89,65,79,72,64,53,53,30,25,14,16,30,58,54,51,90,61,79,112,148,168,162,146,138,134,126,117,106,112,110,104,96,95,96,87,88,87,80,85,91,96,110,101,105,119,122,137,110,102,109,116,110,80,77,87,94,80,82,109,78,73,89,121,151,165,148,151,153,127,107,106,121,128,111,113,123,117,106,88,57,51,30,16,16,16,20,17,36,70,87,103,104,126,128,125,131,129,132,146,117,122,107,110,125,129,125,117,102,86,57,38,36,29,29,63,71,68,86,110,107,111,120,122,132,143,174,152,123,98,122,123,158,131,108,98,74,33,30,32,50,54,72,80,71,69,71,71,77,78,75,80,83,126,150,145,142,171,159,122,116,95,82,89,70,76,73,58,52,61,64,55,64,67,81,84,58,75,95,136,145,113,85,79,99,78,73,63,62,60,43,40,49,70,76,73,83,80,95,119,115,102,109,95,73,82,85,92,95,79,78,67,53,69,65,50,47,45,44,45,51,47,61,65,65,79,108,122,121,133,138,142,139,132,121,105,106,95,78,82,84,72,77,77,78,70,53,47,44,54,60,28,31,50,42,43,47,67,72,60,62,65,74,60,54,56,60,78,79,57,53,57,54,53,56,56,89,99,95,130,150,162,160,145,154,156,148,163,160,128,119,110,90,63,43,47,47,37,55,60,55,49,66,72,61,52,53,49,64,72,80,38,42,43,62,59,61,48,56,64,38,35,45,40,72,109,114,107,78,67,50,30,51,53,58,70,77,96,92,88,83,77,66,73,81,100,101,115,110,123,111,110,119,107,66,51,49,49,49,41,42,30,35,47,72,73,95,79,98,101,93,114,113,126,122,136,139,126,125,117,110,93,93,95,85,87,90,93,89,82,98,111,105,107,102,141,150,142,104,98,122,110,108,116,122,116,125,134,142,153,160,173,206,183,133,127,112,113,131,108,108,118,96,92,78,72,73,50,60,77,64,51,79,76,48,26,35,26,16,29,51,64,95,104,111,113,123,129,139,137,118,108,77,60,61,75,69,80,77,112,109,121,109,124,141,122,110,80,79,73,36,60,77,77,73,95,85,59,53,57,80,70,85,71,68,73,103,89,103,96,114,107,86,82,71,86,89,64,72,81,90,108,108,124,96,100,110,134,129,146,139,138,78,50,43,56,50,53,71,74,74,90,72,78,65,49,37,25,13,18,60,52,37,25,13,25,52,63,63,90,77,79,72,65,71,54,63,56,43,53,48,60,68,79,57,47,73,96,106,120,122,112,132,128,128,119,146,155,130,114,128,118,124,144,138,132,148,147,150,146,130,106,101,123,128,122,145,166,142,104,101,113,135,152,173,166,183,192,145,113,84,72,67,62,72,40,37,73,106,98,95,124,139,110,117,110,98,89,95,142,187,176,151,144,135,135,114,121,140,140,143,140,114,111,109,96,103,106,100,124,100,136,124,133,153,136,134,167,140,107,120,137,142,133,117,96,93,80,74,116,110,133,129,154,146,116,100,97,76,77,94,99,93,94,118,127,144,167,171,147,147,147,137,158,161,147,130,113,103,106,127,126,133,136,146,158,153,171,207,220,196,155,158,161,141,154,127,134,116,111,113,111,132,112,109,111,122,126,136,141,139,126,146,151,137,136,112,115,122,118,101,118,96,114,133,158,135,121,114,117,94,65,61,73,80,105,145,187,199,178,178,173,150,123,85,72,57,45,77,80,77,82,88,115,123,127,142,148,120,132,139,123,150,154,133,166,156,133,151,138,102,87,85,66,91,109,109,91,78,70,48,55,57,64,62,74,64,87,119,133,142,156,162,174,197,182,137,74,84,95,120,95,80,93,90,77,40,55,67,67,71,93,132,134,145,167,172,194,185,197,183,162,161,144,119,86,62,18,10,0,15,35,35,17,39,65,62,64,58,78,109,137,122,131,165,165,153,146,128,113,123,89,83,62,69,75,79,86,107,109,116,105,93,102,120,125,150,149,116,86,95,82,66,76,82,96,110,102,120,116,142,165,154,175,169,160,126,125,104,94,114,123,82,79,80,95,101,119,108,144,165,181,193,180,178,135,126,117,105,89,68,68,74,59,36,30,30,42,74,89,70,64,61,92,110,107,123,132,138,136,132,107,101,92,102,80,90,98,112,109,137,101,106,86,75,69,89,92,112,102,111,103,99,77,65,74,75,84,78,103,117,139,152,143,157,154,141,125,115,93,65,57,57,71,69,90,104,115,140,162,166,175,178,154,175,138,137,118,115,93,97,88,91,100,94,88,88,104,122,102,105,88,89,103,99,111,106,122,124,101,80,59,52,40,68,66,56,43,50,60,59,62,109,126,141,146,153,138,113,93,89,96,93,89,76,84,88,84,60,51,62,53,65,41,39,87,89,64,58,43,46,44,21,22,58,60,65,52,42,37,26,35,17,28,23,27,44,56,76,55,53,46,38,41,49,20,26,81,99,108,99,105,101,81,72,51,38,43,35,35,54,55,53,51,43,47,41,59,86,103,105,96,100,117,140,137,128,127,138,117,83,69,65,47,41,30,15,19,34,44,103,104,124,145,150,139,163,163,165,172,164,124,103,89,101,77,59,50,73,72,78,67,53,14,12,33,31,29,27,44,49,80,90,109,124,112,92,93,95,98,97,90,54,70,80,77,68,64,61,56,45,36,27,23,21,32,39,41,54,75,88,99,109,97,112,123,110,103,92,71,53,43,43,50,50,58,44,36,36,36,29,31,34,40,51,62,67,76,69,64,53,61,90,94,108,112,93,76,69,78,66,55,46,39,38,33,39,50,65,73,71,81,81,69,47,55,44,56,56,35,43,36,29,37,27,43,44,42,57,46,81,89,83,56,68,86,75,71,64,65,78,86,96,101,152,162,169,156,120,95,93,62,51,22,20,26,33,37,26,13,30,53,65,57,55,59,79,75,94,95,89,107,94,78,67,78,67,81,93,88,86,85,101,82,100,82,78,82,75,66,71,61,60,49,39,56,38,34,30,41,55,58,71,56,59,61,65,61,51,51,47,32,49,36,33,50,54,61,60,78,82,83,83,81,86,65,63,56,54,49,22,18,72,68,69,76,65,67,71,57,37,22,37,40,51,70,35,31,61,86,97,90,47,40,38,41,45,44,58,54,66,62,64,67,63,48,67,69,83,77,64,36,35,44,52,83,108,103,79,89,89,84,75,85,63,38,46,50,42,38,36,46,52,47,34,37,34,26,48,26,36,45,68,78,77,111,83,78,79,63,91,80,51,70,57,70,59,79,72,47,37,36,33,20,21,35,34,32,32,30,20,17,16,12,12,12,40,33,20,18,26,25,34,43,37,48,46,33,42,36,31,28,25,26,21,13,37,45,57,76,90,82,89,87,83,73,71,60,57,34,44,52,76,79,83,78,88,87,55,38,30,43,46,18,28,16,25,35,34,34,33,33,41,36,41,14,0,10,0,0,12,14,19,33,44,42,38,38,40,28,39,47,50,36,24,23,12,12,0,0,0,0,0,0,0,11,19,0,13,13,25,41,56,50,62,59,53,58,69,60,39,64,59,56,52,39,27,13,0,0,0,13,15,21,16,12,12,0,16,38,39,51,81,72,77,79,71,58,59,63,80,58,49,47,16,14,28,48,49,48,49,58,64,68,74,77,78,67,65,49,31,43,57,53,79,78,67,59,39,28,15,13,14,38,63,53,55,36,60,55,30,29,26,30,17,12,0,15,35,40,41,56,60,63,68,66,63,41,42,41,38,29,27,29,28,16,28,27,15,15,17,25,25,37,23,13,13,12,0,27,25,25,22,11,0,14,24,26,12,36,31,27,27,29,28,24,13,0,0,11,12,13,25,30,41,46,51,55,61,56,38,34,31,19,14,20,0,0,12,14,23,12,0,13,27,15,22,30,16,0,0,0,0,16,12,11,11,11,12,12,11,0,0,0,0,0,0,0,0,11,26,31,30,25,30,36,33,56,75,68,57,43,47,40,30,30,34,35,36,47,47,39,20,14,13,13,11,19,24,23,21,19,16,24,19,14,13,27,32,27,29,24,27,32,38,50,58,59,56,39,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,14,14,14,18,31,52,57,52,49,66,71,83,100,76,50,36,23,0,12,14,14,22,25,19,0,0,0,23,15,28,40,30,43,46,41,38,26,36,34,24,12,29,18,17,31,27,23,11,0,0,11,15,0,0,0,25,12,24,25,30,37,50,55,20,31,25,24,21,14,0,0,15,23,24,25,34,24,14,14,0,0,0,0,11,11,31,30,30,29,27,31,35,24,23,25,18,21,19,16,12,11,23,13,0,0,7,16,26,31,43,45,38,61,59,52,33,21,22,0,0,0,0,0,0,0,12,12,0,11,12,15,0,13,13,13,14,13,13,12,13,12,14,12,13,12,13,22,33,45,45,50,60,63,63,69,54,53,48,38,23,40,51,73,59,56,105,112,119,100,97,88,62,40,29,11,23,12,12,13,14,13,11,21,22,21,12,23,36,39,37,42,42,40,35,25,24,27,26,23,11,11,0,0,0,0,0,11,0,0,0,0,0,0,11,11,23,23,23,23,23,24,23,21,11,0,0,0,0,0,0,0,0,0,0,0,0,0,13,15,16,25,15,0,0,0,0,0,0,15,17,16,15,13,11,0,0,0,0,0,13,11,0,0,11,13,13,0,0,0,0,0,0,11,16,19,25,26,29,24,16,13,0,0,0,13,0,0,0,13,11,11,12,13,16,20,12,0,0,12,13,15,16,12,12,0,0,0,0,0,0,0,0,0,0,11,12,0,0,0,11,13,16,20,22,25,25,28,25,23,20,16,12,0,0,0,0,0,0,0,0,0,16,15,12,12,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,14,0,0,0,0,0,0,0,0,0,0,0,12,13,11,0,0,0,0,0,0,0,0,12,0,13,16,11,13,12,11,0,13,16,27,22,23,21,18,15,14,0,0,0,0,0,0,13,14,15,14,20,23,11,11,13,12,0,0,0,0,0,0,0,12,13,27,33,30,27,33,20,23,21,22,22,21,13,0,0,11,10,0,0,0,0,11,15,15,14,14,14,29,33,56,48,41,37,19,16,14,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,12,12,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,12,11,0,0,0,0,0,0,0,0,0,0,0,12,13,13,12,11,14,16,16,12,15,29,32,28,13,11,0,0,0,0,0,0,0,0,0,0,16,14,12,16,14,0,0,0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,15,17,14,12,11,0,0,0,0,0,0,5,13,26,23,17,0,11,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,11,3,0,15,11,11,13,15,15,14,12,0,0,0,0,9,11,3,0,0,0,0,0,0,0,0,17,21,18,5,0,0,13,0,0,11,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,15,15,13,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,16,19,21,22,26,19,16,13,11,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,14,18,16,11,11,11,11,11,0,12,0,0,0,13,15,32,38,30,22,14,0,0,0,0,0,0,13,14,17,19,11,5,0,11,12,12,13,12,13,16,14,12,11,16,24,24,11,5,0,0,0,0,0,0,0,0,0,0,0,0,12,12,16,26,25,26,26,27,26,24,24,18,13,13,12,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,12,7,0,0,5,0,5,0,0,0,0,0,9,5,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,14,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,4,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,23,8,0,0,0,0,0,6,12,13,12,14,7,4,4,15,4,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12,19,14,12,12,12,12,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,16,11,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,11,13,13,13,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,13,26,15,24,20,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,6,0,9,11,13,16,16,16,14,12,11,11,11,11,8,0,0,0,0,0,0,0,0,0,0,6,4,0,0,0,4,2,0,7,5,5,8,0,0,0,0,0,0,0,2,0,0,0,0,0,6,11,11,11,11,11,11,20,21,21,21,26,15,11,11,12,14,17,12,13,13,12,17,10,5,0,0,0,13,16,12,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,7,5,4,0,0,0,0,0,0,0,0,0,0,0,0,6,20,18,20,14,0,4,13,13,14,21,17,14,14,12,17,18,19,22,41,35,42,34,26,5,9,16,26,31,41,38,44,29,29,29,32,26,20,5,0,10,13,13,13,26,34,48,44,53,58,75,86,96,87,56,48,45,41,37,25,21,14,14,12,12,11,11,13,20,14,13,7,0,0,12,12,24,28,31,35,33,30,32,32,34,24,17,0,0,0,0,0,0,0,0,0,0,0,3,14,12,14,12,20,21,25,35,32,23,27,17,20,7,0,0,0,0,9,7,0,0,0,0,2,2,0,0,0,0,0,0,0,0,10,9,9,10,16,36,38,34,18,17,13,10,16,35,30,13,7,21,14,15,17,22,14,11,23,24,19,13,13,13,11,8,22,27,30,27,25,19,12,12,9,0,0,0,4,13,10,6,0,0,0,0,10,14,19,21,25,35,15,19,36,57,46,44,36,54,55,50,55,46,37,29,10,0,0,0,0,0,10,16,20,33,32,33,30,26,28,13,14,28,27,20,14,19,27,31,41,41,42,30,14,28,29,22,30,31,35,39,38,50,36,26,27,19,8,15,12,11,12,12,22,15,15,13,16,11,11,23,19,34,46,57,56,57,61,61,51,44,50,20,17,12,16,22,23,19,29,22,35,50,48,49,46,72,75,55,31,36,31,21,7,4,0,2,8,13,17,17,24,9,0,0,7,0,19,8,10,20,23,20,15,13,22,13,17,19,17,21,35,48,70,75,51,43,40,33,33,22,67,73,83,81,96,96,93,75,47,32,22,11,0,0,0,13,43,64,81,68,56,44)
- calculateCandleTimeDiff() =>
- // 2010-01-01 00:00 signal day time serie start.
- referenceUnixTime = 1262300400
- candleUnixTime = (time / 1000) + 1
- timeDiff = candleUnixTime - referenceUnixTime
- iff(timeDiff < 0, na, timeDiff)
- getSignalCandleIndex() =>
- timeDiff = calculateCandleTimeDiff()
- // Day index, days count elapsed from reference date.
- candleIndex = floor(timeDiff / 86400)
- iff(candleIndex < 0, na, candleIndex)
- getSignal() =>
- // Map array data items indexes to candles.
- int candleIndex = getSignalCandleIndex()
- int itemsCount = array.size(sunspots)
- // Return na for candles where indicator data is not available.
- int index = candleIndex > itemsCount ? na : candleIndex
- signal = if (index >= 0 and itemsCount > 1)
- array.get(sunspots, index)
- else
- na
- // Compose signal time serie from array data.
- int SignalSerie = getSignal()
- // Calculate plot offset estimating market week open days
- plot(series=SignalSerie, style=plot.style_histogram, linewidth=4, color=color.orange)
Advertisement
Add Comment
Please, Sign In to add comment