Changes the size of the buffer - sets the possible number of elements in it
setSize(size:int)
Parameters
Name |
Type |
Действие |
Значение по умолчанию |
size |
int |
New size for the buffer |
— |
Return value
A reference to an object of type Buffer for a chain of calls
Example
export class Main extends Indicator {
constructor() {
super();
this.buffers = {
bufferMain : this.addBuffer(),
};
}
onInit() {
this.buffers.bufferMain
.setColor(Color.Red)
.setWidth(3);
}
async onUpdate() {
const priceType = 0,
{bufferMain} = this.buffers,
{Close} = await Bar.load([Bar.Mode.Close], priceType);
// fill the bufferMain with the values of the Close array
bufferMain.fill(Close);
// Get the current buffer size
let BufferSize = bufferMain.size();
this.print('Initial bufferMain size is '+ BufferSize + ' elements.');
// Set a new buffer size
bufferMain.setSize(BufferSize + 777);
BufferSize = bufferMain.size();
this.print('Now bufferMain size is '+ BufferSize + ' elements.');
}
}