I am trying to teach myself EFS and would appreciate it if someone could point out my error in this code as I am having difficulty with variable declaration and returns.
I want to return the gap % size on a daily chart to the cursor window.
What I have come up with is the code below.
If someone could have a look and explain the problem I would really appreciate it.
Thanks in anticipation
P
function preMain() {
setStudyTitle("Gap Size");
setCursorLabelName("Gap", 0);
}
//Declare variable percentage size
var perc;
function main(perc) {
{
// Calculate gap size by - Today's Open divided by yesterday's Close subtract 1 multiply answer by 100
perc = (((Open(0)/Close(-1))-1)*100);
}
// If gap percent is zero, return nothing
{
if Open() != Close(-1) onAction1();
// otherwise return result of calculation as a variable
return;
perc;
}
}
I want to return the gap % size on a daily chart to the cursor window.
What I have come up with is the code below.
If someone could have a look and explain the problem I would really appreciate it.
Thanks in anticipation
P
function preMain() {
setStudyTitle("Gap Size");
setCursorLabelName("Gap", 0);
}
//Declare variable percentage size
var perc;
function main(perc) {
{
// Calculate gap size by - Today's Open divided by yesterday's Close subtract 1 multiply answer by 100
perc = (((Open(0)/Close(-1))-1)*100);
}
// If gap percent is zero, return nothing
{
if Open() != Close(-1) onAction1();
// otherwise return result of calculation as a variable
return;
perc;
}
}
Comment