Announcement

Collapse
No announcement yet.

Line Above an EMA

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

  • Line Above an EMA

    I am new to esignal and not have done any coding. How do I produce a line on a chart that is some price above/below an EMA or other study?

  • #2
    Re: Line Above an EMA

    Welcome to eSignal.

    It's a steep learning curve.

    I thought I would lend a hand since I had the code to do just what you want to do and it only took about 10 minutes. You shouldn't have to waste hours figuring this kind of stuff out.

    The TRO_TRADE_ZONES_MA allows YOU to enter the moving average type, length, offset, and band colors.

    You can also move the button around, but leave it alone until after you figure a few things out...lol

    In the screenshot, I am using an ema(5) with an offset of .25.

    The study plots a line .25 above and another .25 below the value of the ema(5). It also shades the area to make it easier to see.

    I hope this helps.

    MAY ALL YOUR FILLS BE COMPLETE.

    Here's the code:

    PHP Code:


    /*************************************
    Alexis C. Montenegro © April 2004                         
    Use and or modify this code freely. If you redistribute it
    please include this and or any other comment blocks and a 
    description of any changes you make. 
    ..........................................................

    TRO_TRADE_ZONES_MA 20060730  PLOTS TRADE ZONE LINES based on moving avg


    Modifying Programmer:  Avery T. Horton, Jr.  aka *************
                         
    ****************************************/

    debugClear(); 


    var 
    xAvgr1c1 null;

    function 
    preMain() {

        
    setPriceStudy(true);
        
    setStudyTitle("TRO_TRADE_ZONES");
        
    setCursorLabelName("Long Top "0);
        
    setCursorLabelName("Long Bot "1);
        
    setCursorLabelName("Open     "2);
        
    setCursorLabelName("Short Top"3);
        
    setCursorLabelName("Short Bot"4);
        
    setCursorLabelName("PrevClose"5);

        
    setDefaultBarFgColor(Color.blue,0);
        
    setDefaultBarFgColor(Color.blue,1);
        
    setDefaultBarFgColor(Color.lime,2);
        
    setDefaultBarFgColor(Color.red,3);
        
    setDefaultBarFgColor(Color.red,4);
        
    setDefaultBarFgColor(Color.magenta,5);

        
    setDefaultBarThickness(2,0);
        
    setDefaultBarThickness(2,1);
        
    setDefaultBarThickness(2,2);
        
    setDefaultBarThickness(2,3);
        
    setDefaultBarThickness(2,4);
        
    setDefaultBarThickness(2,5);

        
    setPlotType(PLOTTYPE_FLATLINES,0);  
        
    setPlotType(PLOTTYPE_FLATLINES,1);
        
    setPlotType(PLOTTYPE_FLATLINES,2);
        
    setPlotType(PLOTTYPE_FLATLINES,3);
        
    setPlotType(PLOTTYPE_FLATLINES,4);
        
    setPlotType(PLOTTYPE_FLATLINES,5);

    //    checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/PrevDay-OHLC.efs");

    }

    var 
    vOpen null;
    var 
    vOpen1 null;
    var 
    vHigh null;
    var 
    vHigh1 null;
    var 
    vLow null;
    var 
    vLow1 null;
    var 
    vClose1 null;

    var 
    vMid null;
    var 
    vMid1 null;


    askForInput();

        var 
    iDecimals = new FunctionParameter("iDecimals"FunctionParameter.NUMBER);
        
    iDecimals.setDefault); 


        var 
    iAvgType1 = new FunctionParameter("iAvgType1"FunctionParameter.STRING);
            
    iAvgType1.addOption("Simple");
            
    iAvgType1.addOption("Exponential");
            
    iAvgType1.addOption("Weighted");
        
    iAvgType1.setDefault"Exponential" ); 
        
    iAvgType1.setName("Fast AVG Type");

        var 
    iLength1 = new FunctionParameter("iLength1"FunctionParameter.NUMBER);
        
    iLength1.setDefault05 ); 
        
    iLength1.setName("AVG Length");


        var 
    iOffset1 = new FunctionParameter("iOffset1"FunctionParameter.NUMBER);
        
    iOffset1.setDefault.10 ); 
     
        var 
    iColorLong = new FunctionParameter("iColorLong"FunctionParameter.COLOR);
            
    iColorLong.setDefaultColor.RGB(215,255,195));

        var 
    iColorShort = new FunctionParameter("iColorShort"FunctionParameter.COLOR);
            
    iColorShort.setDefaultColor.RGB(254,233,233));

        var 
    iButtonX = new FunctionParameter("iButtonX"FunctionParameter.NUMBER);
        
    iButtonX.setDefault50 ); 

        var 
    iButtonY = new FunctionParameter("iButtonY"FunctionParameter.NUMBER);
        
    iButtonY.setDefault15 ); 

    function 
    mainiDecimals,   iAvgType1 iLength1,   iOffset1  
                   
    iColorLong iColorShortiButtonX iButtonY ) {

     
    //   if (close(-1)==null) 
       //     return;

     
      // initialize upon first loading formula

        
    if(getBarState() == BARSTATE_ALLBARS) {
            
    drawTextPixeliButtonXiButtonY " TRO_TradeZone_MA @URL=EFS:editParameters"Color.white

    Color.green
                
    Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON
                
    "Comic Sans MS"13"UpExp"); 
            
    vDate = new Date();
            
    vInterval getInterval();
            
    vSymbol getSymbol().toUpperCase();
        
            
    // for RTH, eg, to convert, ES Z2 to ES Z2=2
            
    var rootSymbol vSymbol.substring(0,3);
            if (
    rootSymbol == "ES " || rootSymbol == "NQ "
                if ( 
    vSymbol.indexOf("=2") == -vSymbol += "=2";
        
            
    vSymbol += ",D";
     
    //       return null;
        
    }

        
        if(
    getBarState()==BARSTATE_NEWBAR&&getDay()!=getDay(-1)) {
            
    vHigh1 vHigh;
            
    vLow1 vLow;
            
    vOpen1 vOpen;
            
    vClose1 formatPriceNumberclose(-1) ) * ;//comment out this line if using alternate 

    vClose1 
            vMid1 
    formatPriceNumbervMid ) * ;
            
    vHigh high();
            
    vLow low();
            
    vOpen=open();

       }

           if( 
    iAvgType1 == "Simple" )      { xAvgr1c1  smaiLength1 inv(vInterval) ) } ;
           if( 
    iAvgType1 == "Exponential" ) { xAvgr1c1  emaiLength1 inv(vInterval) ) } ;
           if( 
    iAvgType1 == "Weighted" )    { xAvgr1c1  emaiLength1 inv(vInterval) ) } ;

    vLongTop    rnd(xAvgr1c1 iOffset1,  iDecimals) ; 

    vShortTop    rnd(xAvgr1c1 iOffset1,  iDecimals) ; 

        
        if (
    vOpen1 == null || vLow1 == null || vHigh1 == null || vClose1 == null) {
            return;
        } else {


     
    setBarBgColor(iColorLong ,0xAvgr1c1vLongTop );

    setBarBgColor(iColorShort1vShortTopxAvgr1c1 );

     
    return new Array( 
    vLongTop,  rndxAvgr1c1iDecimals), vShortTop  ) ;
        }
    }


    function 
    editParameters() {
        
    askForInput("TRO_TRADE_ZONES_MA");
        return;
    }

    // rnd function  
    function rnd(valueiDecimals ) { // Round the price to iDecimals digits

    value =  value Math.pow(10iDecimals);

        return 
    Math.round(valueiDecimals) / Math.pow(10iDecimals);




    Originally posted by iholmes89
    I am new to esignal and not have done any coding. How do I produce a line on a chart that is some price above/below an EMA or other study?
    Attached Files
    Last edited by buzzhorton; 07-30-2006, 11:51 PM.

    Comment


    • #3
      EMA Lines

      thx, buzz

      Comment

      Working...
      X