Announcement

Collapse
No announcement yet.

MA or MACD study

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

  • MA or MACD study

    Is it possible to have a MA or MACD study plotted on the chart by designating which one you want with the Edit Studies Parameters?

    I know I saw this but can't remember enough to do a thorough search.

    Thanks.

  • #2
    David
    Not sure if this is what you are asking but I don't think it is possible to switch between price or non-price study through Edit Studies
    Alex

    Comment


    • #3
      Right, how about switching between stochastic and macd in Edit Studies?

      Comment


      • #4
        David
        The enclosed example will allow switching between MACD and Stochastic. Add a Function Parameter called "Selector" with "Stochastic" and "MACD" options, the necessary global variables and use retArray in the return statement
        Alex

        PHP Code:
        if(bInit==false){
                if(
        Selector=="Stochastic"){
                    
        vStudy1 stochK(14,1,3);
                    
        vStudy2 stochD(14,1,3);
                    
        setCursorLabelName("%K",0);
                    
        setCursorLabelName("%D",1);
                }else if(
        Selector=="MACD"){
                    
        vStudy1 macd(12,26,9);
                    
        vStudy2 macdSignal(12,26,9);
                    
        vStudy3 macdHist(12,26,9);
                    
        setCursorLabelName("MACD",0);
                    
        setCursorLabelName("Sig",1);
                    
        setCursorLabelName("Hist",2);
                    
        setPlotType(PLOTTYPE_HISTOGRAM,2)
                }            
                
        setDefaultBarFgColor(Color.blue,0);
                
        setDefaultBarFgColor(Color.red,1);
                
        setDefaultBarFgColor(Color.magenta,2);
                
        bInit=true;
            }
            
            if(
        Selector=="Stochastic"){
                var 
        retArray = new Array (vStudy1.getValue(0),vStudy2.getValue(0));
            }else if(
        Selector=="MACD"){
                var 
        retArray = new Array (vStudy1.getValue(0),vStudy2.getValue(0),vStudy3.getValue(0));
            } 

        Comment

        Working...
        X