So here is an example of mocking custom bars by managing different O/H/L/C series separately grouped by a struct. Is this the 'right' way?
can I replace customBars.Open = malloc(NumBars * sizeof(var)); memset(myBars.StartingBar, 0, NumBars * sizeof(var));
by customBars.Open = series(0) ?

typedef struct {
int* OpenBar;
vars OpenDate;
vars Open;
vars High;
vars Low;
vars Close;
vars Volume;
} CustomBars;

function initCustomBars(CustomBars* customBars){
if (is(INITRUN)) {
} else {
if (customBars->Open == NULL) { //allocate bars when NumBars is available
customBars->OpenBar = malloc(NumBars * sizeof(int)); memset(customBars->OpenBar, 0, NumBars * sizeof(int));
customBars->OpenDate = malloc(NumBars * sizeof(var)); memset(customBars->OpenDate, 0, NumBars * sizeof(var));
customBars->Open = malloc(NumBars * sizeof(var)); memset(customBars->Open, 0, NumBars * sizeof(var));
customBars->High = malloc(NumBars * sizeof(var)); memset(customBars->High, 0, NumBars * sizeof(var));
customBars->Low = malloc(NumBars * sizeof(var)); memset(customBars->Low, 0, NumBars * sizeof(var));
customBars->Close = malloc(NumBars * sizeof(var)); memset(customBars->Close, 0, NumBars * sizeof(var));
customBars->Volume = malloc(NumBars * sizeof(var)); memset(customBars->Volume, 0, NumBars * sizeof(var));
}
}

}


function run() {
static CustomBars myBars;
initCustomBars(&myBars);
}

Last edited by purpledawn; 01/18/17 06:06.