Announcement

Collapse
No announcement yet.

Adding Price of Another index to chart screen

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

  • Adding Price of Another index to chart screen

    Is there anyway to add only the price of say SPX or INDX to a chart of ESU4? I don't want any charting, studies or anything on the data, just the price, ticker symbol and possibly the change

  • #2
    Chris
    The enclosed efs provides you with an example of how to do it.
    It will print at the bottom of the chart of any symbol the last value of $INDU with the current Net Change and Percent Change. Also if the Net Change is positive it will write those values in blue, if negative in red.
    Alex



    PHP Code:
    function preMain() {

    setPriceStudy(true);
    setStudyTitle("Sym")
    setShowCursorLabel(false);
    }
            
    function 
    main() {
            
    var 
    vSymbol close(0, -3"$INDU,D");
    var 
    vChange vSymbol[0]-vSymbol[1];
    var 
    vChngPct = ((vSymbol[0]-vSymbol[1])/vSymbol[1])*100

    if(vChange>=0){
    drawTextRelative(20,0,"$INDU: "+vSymbol[0].toFixed(2)+"   Net: "+vChange.toFixed(2)+"   Net%: "+vChngPct.toFixed(2),
                     
    Color.blue,null,Text.RELATIVETOLEFT|Text.BOLD|Text.RELATIVETOBOTTOM,"MS Sans Serif",10,1);
    }
    if(
    vChange<0){
    drawTextRelative(20,0,"$INDU: "+vSymbol[0].toFixed(2)+"   Net: "+vChange.toFixed(2)+"   Net%: "+vChngPct.toFixed(2),
                     
    Color.red,null,Text.RELATIVETOLEFT|Text.BOLD|Text.RELATIVETOBOTTOM,"MS Sans Serif",10,1);
    }

    return ;

    Comment


    • #3
      The enclosed revision adds the option to change the symbol through Edit Studies
      Alex

      PHP Code:
      function preMain() {

      setPriceStudy(true);
      setStudyTitle("Sym")
      setShowCursorLabel(false);

      var 
      fp1 = new FunctionParameter("Sym"FunctionParameter.STRING);
      fp1.setName("Symbol");        
      fp1.setDefault("$INDU");
      }
              
      function 
      main(Sym) {

      var 
      vSym Sym;
      vSym +=",D";
      var 
      xSym Sym;
              
      var 
      vSymbol close(0, -3vSym);
      var 
      vChange vSymbol[0]-vSymbol[1];
      var 
      vChngPct = ((vSymbol[0]-vSymbol[1])/vSymbol[1])*100;

      if(
      vChange>=0){
      drawTextRelative(20,0,xSym.toUpperCase()+": "+vSymbol[0].toFixed(2)+"   Net: "+vChange.toFixed(2)+"   Net%: "+vChngPct.toFixed(2),
                       
      Color.blue,null,Text.RELATIVETOLEFT|Text.BOLD|Text.RELATIVETOBOTTOM,"MS Sans Serif",10,1);
      }
      if(
      vChange<0){
      drawTextRelative(20,0,xSym.toUpperCase()+": "+vSymbol[0].toFixed(2)+"   Net: "+vChange.toFixed(2)+"   Net%: "+vChngPct.toFixed(2),
                       
      Color.red,null,Text.RELATIVETOLEFT|Text.BOLD|Text.RELATIVETOBOTTOM,"MS Sans Serif",10,1);
      }

      return ;

      Comment


      • #4
        Awesome. Thanks so much for your help.

        Comment

        Working...
        X