更改緩衝區的大小-設置緩衝區中可能的元素數量
setSize(size:int)
Parameters
Name |
Type |
Действие |
Значение по умолчанию |
size |
int |
緩衝區的新大小 |
— |
Return value
引用Buffer類型的對像以進行一系列調用
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);
// 用 Close 數組的值填充 bufferMain
bufferMain.fill(Close);
// 獲取當前緩衝區大小
let BufferSize = bufferMain.size();
this.print('Initial bufferMain size is '+ BufferSize + ' elements.');
// 設置新的緩衝區大小
bufferMain.setSize(BufferSize + 777);
BufferSize = bufferMain.size();
this.print('Now bufferMain size is '+ BufferSize + ' elements.');
}
}