Announcement

Collapse
No announcement yet.

formula but no signal on chart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • formula but no signal on chart

    I am trying to get either the price or indicator payne to signal an indicator cross of ma. when I load, nothing happens. vVSI is defined as a function() outside of the main. Any ideas? Without the signal code, the plotting is fine, with it, the plot doesn't occur.

    Thanks!

    Carson

    var vVSI = null;
    var vEma = null;
    bInit = false;

    function main() {
    if(!bInit){
    vVSI = getSeries(efsInternal("myVSI")); //~ returns the series for VSI
    vEma = getSeries(ema(5, vVSI));
    bInit = true;
    }

    if(vVSI > vEma){
    setBarBgColor(Color.green);
    } else {
    if(vVSI < vEma) {
    setBarBgColor(Color.red);
    }

    return Array (vVSI, vEma);

  • #2
    Re: formula but no signal on chart

    Carson
    You are missing a closing curly bracket to end the code block that paints the background.
    FWIW also missing in your code is a closing curly bracket to end the main function but I suppose that was a simple omission in copying the code as you indicate the script is otherwise plotting.
    Lastly the return statement should be return new Array (item1, item2 etc) as shown in the example Steve Hare provided to you in this thread on the same topic
    Alex


    Originally posted by arsond
    I am trying to get either the price or indicator payne to signal an indicator cross of ma. when I load, nothing happens. vVSI is defined as a function() outside of the main. Any ideas? Without the signal code, the plotting is fine, with it, the plot doesn't occur.

    Thanks!

    Carson

    var vVSI = null;
    var vEma = null;
    bInit = false;

    function main() {
    if(!bInit){
    vVSI = getSeries(efsInternal("myVSI")); //~ returns the series for VSI
    vEma = getSeries(ema(5, vVSI));
    bInit = true;
    }

    if(vVSI > vEma){
    setBarBgColor(Color.green);
    } else {
    if(vVSI < vEma) {
    setBarBgColor(Color.red);
    }

    return Array (vVSI, vEma);

    Comment

    Working...
    X