Steve,
Thank you for the assistance. The following script is based on the one you provided with some minor changes. I have been testing this on two charts running side by side. Both are ym h9 and the 1st is a 1 minute and the 2nd is 50t. After both are loaded with the exact same script and begin running, they are in sync historically. When the 1 minute chart changes direction from positive to negative or the opposite, the 50t chart does NOT change direction at all and continues constant. If I reload a different time templet onto the 50t chart, the prior data becomes in sync and the process continues. If I wait for the 1 minute to reverse direction a second time, the 50t again does NOT reverse direction until I reload a different time templet again.
Your thoughts on how to resolve this would be appreciared. After we clear this issue up, I would like to address the issue you raised on improving the resource utilization.
Best Regards,
Alan
var MA1, MA2, aa1, aa11, bInit, paa1, paa11, pp;
function preMain() {
setPriceStudy(false);
setStudyTitle("Steve2a");
setCursorLabelName("paa1", 0);
setCursorLabelName("paa11", 1);
setCursorLabelName("pp", 2);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.black, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(3, 2);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
}
paa1 = 0;
paa11 = 0;
pp = 0;
function main() {
pp = 0;
if (!bInit) {
var Symbol1 = getSymbol();
var Interval1 = "1";
var vSymbol1 = Symbol1 + "," + Interval1;
MA1 = efsInternal("myFunction1", sym(vSymbol1));
MA2 = efsInternal("myFunction2", sym(vSymbol1));
aa1 = efsInternal("myFunction3", sym(vSymbol1));
aa11 = efsInternal("myFunction4", sym(vSymbol1));
bInit = true;
}
if (MA1.getValue(0) >= MA2.getValue(0)) {
setBarThickness(3, 0);
setBarFgColor(Color.blue, 0);
}
if (MA2.getValue(0) >= MA1.getValue(0)) {
setBarThickness(1, 0);
setBarFgColor(Color.black, 0);
paa1 = 0;
}
else {
paa1 = aa1.getValue(0);
}
if (MA2.getValue(0) >= MA1.getValue(0)) {
setBarThickness(3, 1);
setBarFgColor(Color.red, 1);
}
if (MA1.getValue(0) >= MA2.getValue(0)) {
setBarThickness(1, 1);
setBarFgColor(Color.black, 1);
paa11 = 0;
}
else {
paa11 = aa11.getValue(0);
}
return new Array(paa1, paa11, pp);
}
function myFunction1() {
if (!bInit) {
MA1 = sma(7, close());
bInit = true;
}
return MA1.getValue(0);
}
function myFunction2() {
if (!bInit) {
MA2 = sma(25, close());
bInit = true;
}
return MA2.getValue(0);
}
function myFunction3() {
var aa1 = 0;
if (!bInit) {
MA1 = sma(7, close());
MA2 = sma(25, close());
bInit = true;
}
if (MA1.getValue(0) >= MA2.getValue(0)) {
aa1 = 4;
}
else if (MA2.getValue(0) >= MA1.getValue(0)) {
aa1 = 0;
}
return aa1;
}
function myFunction4() {
var aa11 = 0;
if (!bInit) {
MA1 = sma(7, close());
MA2 = sma(25, close());
bInit = true;
}
if (MA2.getValue(0) >= MA1.getValue(0)) {
aa11 = -4;
}
else if (MA1.getValue(0) >= MA2.getValue(0)) {
aa11 = 0;
}
return aa11;
}
Thank you for the assistance. The following script is based on the one you provided with some minor changes. I have been testing this on two charts running side by side. Both are ym h9 and the 1st is a 1 minute and the 2nd is 50t. After both are loaded with the exact same script and begin running, they are in sync historically. When the 1 minute chart changes direction from positive to negative or the opposite, the 50t chart does NOT change direction at all and continues constant. If I reload a different time templet onto the 50t chart, the prior data becomes in sync and the process continues. If I wait for the 1 minute to reverse direction a second time, the 50t again does NOT reverse direction until I reload a different time templet again.
Your thoughts on how to resolve this would be appreciared. After we clear this issue up, I would like to address the issue you raised on improving the resource utilization.
Best Regards,
Alan
var MA1, MA2, aa1, aa11, bInit, paa1, paa11, pp;
function preMain() {
setPriceStudy(false);
setStudyTitle("Steve2a");
setCursorLabelName("paa1", 0);
setCursorLabelName("paa11", 1);
setCursorLabelName("pp", 2);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.black, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(3, 2);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
}
paa1 = 0;
paa11 = 0;
pp = 0;
function main() {
pp = 0;
if (!bInit) {
var Symbol1 = getSymbol();
var Interval1 = "1";
var vSymbol1 = Symbol1 + "," + Interval1;
MA1 = efsInternal("myFunction1", sym(vSymbol1));
MA2 = efsInternal("myFunction2", sym(vSymbol1));
aa1 = efsInternal("myFunction3", sym(vSymbol1));
aa11 = efsInternal("myFunction4", sym(vSymbol1));
bInit = true;
}
if (MA1.getValue(0) >= MA2.getValue(0)) {
setBarThickness(3, 0);
setBarFgColor(Color.blue, 0);
}
if (MA2.getValue(0) >= MA1.getValue(0)) {
setBarThickness(1, 0);
setBarFgColor(Color.black, 0);
paa1 = 0;
}
else {
paa1 = aa1.getValue(0);
}
if (MA2.getValue(0) >= MA1.getValue(0)) {
setBarThickness(3, 1);
setBarFgColor(Color.red, 1);
}
if (MA1.getValue(0) >= MA2.getValue(0)) {
setBarThickness(1, 1);
setBarFgColor(Color.black, 1);
paa11 = 0;
}
else {
paa11 = aa11.getValue(0);
}
return new Array(paa1, paa11, pp);
}
function myFunction1() {
if (!bInit) {
MA1 = sma(7, close());
bInit = true;
}
return MA1.getValue(0);
}
function myFunction2() {
if (!bInit) {
MA2 = sma(25, close());
bInit = true;
}
return MA2.getValue(0);
}
function myFunction3() {
var aa1 = 0;
if (!bInit) {
MA1 = sma(7, close());
MA2 = sma(25, close());
bInit = true;
}
if (MA1.getValue(0) >= MA2.getValue(0)) {
aa1 = 4;
}
else if (MA2.getValue(0) >= MA1.getValue(0)) {
aa1 = 0;
}
return aa1;
}
function myFunction4() {
var aa11 = 0;
if (!bInit) {
MA1 = sma(7, close());
MA2 = sma(25, close());
bInit = true;
}
if (MA2.getValue(0) >= MA1.getValue(0)) {
aa11 = -4;
}
else if (MA1.getValue(0) >= MA2.getValue(0)) {
aa11 = 0;
}
return aa11;
}
Comment