Hello,
I tried to use the Formula Wizard to create a study with the following criteria.
1. First, this formula was designed to be used with a 65-minute chart during regular trading hours for equities (8:30 am - 3 pm CST).
2. I want the price bar to be a different color if the volume of that bar is the highest volume for that time slot during the past 5 days. In other words, if the volume for the 9:35 time slot is higher than that of the 9:35 time slot for the previous 4 days, then the bar should be a different color.
3. I also want the price bar to be a different color if the volume of that bar is higher than the volume for the first bar of that day. So if the volume for the 9:35 bar is higher than the volume for the 8:30 bar on the same day, then the 9:35 bar should be a different color.
Unfortunately, the study doesn't work properly. It colors some of the bars but not others. I haven't figured out a pattern as to why certain bars are not being colored. I will paste the code below in hopes that someone can help me. As an aside, I'll note that I'd prefer to color the volume bars rather than the price bars, but I didn't see a way to do this.
Thanks,
Jason
Here is the code generated by the Formula Wizard:
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description 7532
//{{EFSWizard_Declarations
var vLastAlert = -1;
//}}EFSWizard_Declarations 2482
function preMain() {
//{{EFSWizard_Code_PreMain_setPriceBarColor
setColorPriceBars(true);
//}}EFSWizard_Code_PreMain_setPriceBarColor 3448
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
//{{EFSWizard_PreMain
setPriceStudy(true);
setStudyTitle("Colored bars based on time of day");
//}}EFSWizard_PreMain 9803
}
function main() {
/**
* The main() function is called once per bar on all previous bars, once per
* each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
* in your preMain(), it is also called on every tick.
*/
//{{EFSWizard_Expressions
//{{EFSWizard_Expression_1
if (
getHour() == 8 &&
getMinute() == 30 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24)
) onAction1()
//}}EFSWizard_Expression_1 24559
//{{EFSWizard_Expression_2
else if (
getHour() == 9 &&
getMinute() == 35 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-1)
) onAction2()
//}}EFSWizard_Expression_2 33259
//{{EFSWizard_Expression_3
else if (
getHour() == 10 &&
getMinute() == 40 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-2)
) onAction3()
//}}EFSWizard_Expression_3 32265
//{{EFSWizard_Expression_4
else if (
getHour() == 11 &&
getMinute() == 45 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-3)
) onAction4()
//}}EFSWizard_Expression_4 33667
//{{EFSWizard_Expression_5
else if (
getHour() == 12 &&
getMinute() == 50 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-4)
) onAction5()
//}}EFSWizard_Expression_5 32942
//{{EFSWizard_Expression_6
else if (
getHour() == 1 &&
getMinute() == 55 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-5)
) onAction6();
//}}EFSWizard_Expression_6 31726
//}}EFSWizard_Expressions 265579
//{{EFSWizard_Return
return null;
//}}EFSWizard_Return 2256
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
//{{EFSWizard_Actions
//{{EFSWizard_Action_1
function onAction1() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 1;
}
//}}EFSWizard_Action_1 11061
//{{EFSWizard_Action_2
function onAction2() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 2;
}
//}}EFSWizard_Action_2 11228
//{{EFSWizard_Action_3
function onAction3() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 3;
}
//}}EFSWizard_Action_3 11643
//{{EFSWizard_Action_4
function onAction4() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 4;
}
//}}EFSWizard_Action_4 10397
//{{EFSWizard_Action_5
function onAction5() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 5;
}
//}}EFSWizard_Action_5 11213
//{{EFSWizard_Action_6
function onAction6() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 6;
}
//}}EFSWizard_Action_6 12260
//}}EFSWizard_Actions 129282
I tried to use the Formula Wizard to create a study with the following criteria.
1. First, this formula was designed to be used with a 65-minute chart during regular trading hours for equities (8:30 am - 3 pm CST).
2. I want the price bar to be a different color if the volume of that bar is the highest volume for that time slot during the past 5 days. In other words, if the volume for the 9:35 time slot is higher than that of the 9:35 time slot for the previous 4 days, then the bar should be a different color.
3. I also want the price bar to be a different color if the volume of that bar is higher than the volume for the first bar of that day. So if the volume for the 9:35 bar is higher than the volume for the 8:30 bar on the same day, then the 9:35 bar should be a different color.
Unfortunately, the study doesn't work properly. It colors some of the bars but not others. I haven't figured out a pattern as to why certain bars are not being colored. I will paste the code below in hopes that someone can help me. As an aside, I'll note that I'd prefer to color the volume bars rather than the price bars, but I didn't see a way to do this.
Thanks,
Jason
Here is the code generated by the Formula Wizard:
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description 7532
//{{EFSWizard_Declarations
var vLastAlert = -1;
//}}EFSWizard_Declarations 2482
function preMain() {
//{{EFSWizard_Code_PreMain_setPriceBarColor
setColorPriceBars(true);
//}}EFSWizard_Code_PreMain_setPriceBarColor 3448
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
//{{EFSWizard_PreMain
setPriceStudy(true);
setStudyTitle("Colored bars based on time of day");
//}}EFSWizard_PreMain 9803
}
function main() {
/**
* The main() function is called once per bar on all previous bars, once per
* each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
* in your preMain(), it is also called on every tick.
*/
//{{EFSWizard_Expressions
//{{EFSWizard_Expression_1
if (
getHour() == 8 &&
getMinute() == 30 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24)
) onAction1()
//}}EFSWizard_Expression_1 24559
//{{EFSWizard_Expression_2
else if (
getHour() == 9 &&
getMinute() == 35 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-1)
) onAction2()
//}}EFSWizard_Expression_2 33259
//{{EFSWizard_Expression_3
else if (
getHour() == 10 &&
getMinute() == 40 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-2)
) onAction3()
//}}EFSWizard_Expression_3 32265
//{{EFSWizard_Expression_4
else if (
getHour() == 11 &&
getMinute() == 45 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-3)
) onAction4()
//}}EFSWizard_Expression_4 33667
//{{EFSWizard_Expression_5
else if (
getHour() == 12 &&
getMinute() == 50 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-4)
) onAction5()
//}}EFSWizard_Expression_5 32942
//{{EFSWizard_Expression_6
else if (
getHour() == 1 &&
getMinute() == 55 &&
volume() > volume(-6) &&
volume() > volume(-12) &&
volume() > volume(-18) &&
volume() > volume(-24) &&
volume() > volume(-5)
) onAction6();
//}}EFSWizard_Expression_6 31726
//}}EFSWizard_Expressions 265579
//{{EFSWizard_Return
return null;
//}}EFSWizard_Return 2256
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
//{{EFSWizard_Actions
//{{EFSWizard_Action_1
function onAction1() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 1;
}
//}}EFSWizard_Action_1 11061
//{{EFSWizard_Action_2
function onAction2() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 2;
}
//}}EFSWizard_Action_2 11228
//{{EFSWizard_Action_3
function onAction3() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 3;
}
//}}EFSWizard_Action_3 11643
//{{EFSWizard_Action_4
function onAction4() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 4;
}
//}}EFSWizard_Action_4 10397
//{{EFSWizard_Action_5
function onAction5() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 5;
}
//}}EFSWizard_Action_5 11213
//{{EFSWizard_Action_6
function onAction6() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 6;
}
//}}EFSWizard_Action_6 12260
//}}EFSWizard_Actions 129282
Comment