I have a program that will not work and I can't figure out why. In funciton main() I am reading the minute, hour, and day of the bars in a one minute chart. I can place a debugPrintln() immediately after where it reads what ibarHour is and it will give it to me. But when it comes time to read these numbers as ibarMinute, ibarHour, and ibarDay in an if statement it will not read the numbers, especially in this line:
if(ibarHour = 9 && ibarMinute = 30) {
Is ibarHour a number or something else?
The goal is to determine the slope, intercept and r2 for data between 9:30 AM and 10:30 AM EST.
Been working on this for 9 hours with no luck, can anyone help out please??? If I am not clear in explanation, please let me know.
if(ibarHour = 9 && ibarMinute = 30) {
Is ibarHour a number or something else?
The goal is to determine the slope, intercept and r2 for data between 9:30 AM and 10:30 AM EST.
Been working on this for 9 hours with no luck, can anyone help out please??? If I am not clear in explanation, please let me know.
PHP Code:
debugClear()
function preMain() {
setPriceStudy(true);
setStudyTitle("First Hour Trading");
setShowCursorLabel(false);
}
function main() {
var ibarHour = getHour(0);
var ibarMinute = getMinute(0);
var ibarDay = getDay(0);
iLength = 60;
if(ibarHour = 9 && ibarMinute = 30) { //This line produces an error, why??
var isumx = 0;
var vsumy = 0;
var vmultxy = 0;
var vsquaredy = 0;
var vsquaredx = 0;
}
}
if(ibarHour = 10 && ibarMinute <= 30) { //calculates from 10:00 to 10:30 AM
var isumx = isumx + 1;
var vsumy = vsumy + close(0);
var vmultxy = vmultxy + (isumx * close(0));
var vsquaredy = vsquaredy + (close(0) * close(0));
var vsquaredx = vsquaredx + (isumx * isumx);
}
}
if(ibarHour = 9 && ibarMinute <= 59) { //Calculates from 9:30 to 10:00 AM and adds them to the one above.
isumx = isumx + 1;
vsumy = vsumy + close(0);
vmultxy = vmultxy + (isumx * close(0));
vsquaredy = vsquaredy + (close(0) * close(0));
vsquaredx = vsquaredx + (isumx * isumx);
}
}
// Calculates slope, intercept, and r2
slope = (iLength * (vmultxy - vsumy * isumx))/(iLength * (vsquaredx - isumx * isumx));
intercept = (vsumy - slope * isumx)/iLength;
r1 = (iLength * vmultxy - isumx * vsumy);
r2 = ((iLength * vsquaredx - isumx * isumx) * (iLength * vsquaredy - vsumy * vsumy));
rsquare = (r1 / r2) * (r1 / r2);
return;
}
Comment