Announcement

Collapse
No announcement yet.

Parabolic and macd logic problems

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

  • Parabolic and macd logic problems

    I got this study to work most of the time, but there seems to be issues with the alerts. I only want alerts when both conditions are met which it picks up on some tickers, but not all. The macd could be long and the parabolic could be short, but it still gives a signal even though both statements are not true. Any suggestions? For instance try using it on IDC, you will see what the problem is.




    var study = new MACDStudy (7,18,9,"Close",false)
    var vLastAlert = -1
    var vParSAR = new ParabolicStudy(0.02, 0.02, 0.2)






    function preMain() {
    setPriceStudy(true);
    setColorPriceBars(false);
    setCursorLabelName("MACD", 0);
    setCursorLabelName("SIGNAL", 1);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    }




    function main () {
    var MACD = study.getValue(MACDStudy.MACD);
    var Signal = study.getValue(MACDStudy.SIGNAL);



    if(Signal < MACD + close() > vParSAR.getValue(ParabolicStudy.STOP) && !Strategy.isLong() )
    Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR);


    if(Signal > MACD + close() < vParSAR.getValue(ParabolicStudy.STOP) && !Strategy.isShort() )
    Strategy.doShort("Short", Strategy.MARKET, Strategy.NEXTBAR);


    if(Strategy.isLong() )
    Alert.addToList(getSymbol(), "Long", Color.green, Color.black ) ;


    else if(Strategy.isShort() )
    Alert.addToList(getSymbol(), "Short", Color.red, Color.black ) ;




    return new Array(MACD,Signal);

    }
Working...
X