Announcement

Collapse
No announcement yet.

Help to improve it, please

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

  • Help to improve it, please

    Please, can someone help me?
    I would like to put the texts BUY and SELL, and sound alerts, when the formula make changes in colors:

    /************************************************** *****************
    Provided By: TS Support, LLC for eSignal. (c) Copyright 2002
    ************************************************** ******************/


    function preMain()
    {
    setStudyTitle("Movtrend");
    setCursorLabelName("Movtrend", 0);
    setDefaultBarFgColor(Color.white, 0);
    setPlotType(PLOTTYPE_INSTANTCOLORLINE);
    setDefaultBarThickness(4, 0);
    setPriceStudy(true);

    }

    var wt = null;
    var wt_1 = null;

    function main(n) {

    if(n == null)
    n = 34;
    var sum = 0;
    var i = 0;

    if(getBarState()==BARSTATE_NEWBAR){
    wt_1 = wt;
    }

    for(i = n; i > 0; i--)
    sum += (i - (n + 1) / 3) * close(i - n);
    wt = 6 / (n * (n + 1)) * sum;

    if(wt>wt_1){
    setBarFgColor(Color.lime);
    setPriceBarColor(Color.navy);
    }
    if(wt<wt_1){
    setBarFgColor(Color.purple);
    setPriceBarColor(Color.red);
    }


    return wt;
    }

  • #2
    Please, I would like to know if some Moderator can help to improve the formula or if I asked something wrong.
    Thanks.
    Barros.

    Comment


    • #3
      Barros
      To add the text the easiest solution is to use the same efs I modified for you a couple of years ago (see this thread) and replace the following section of code which identifies the points in which the plot changes color and paints the background
      PHP Code:
      if(wt_1<wt_2&&wt>wt_1)
          
      setBarBgColor(Color.lime);
          
          if(
      wt_1>wt_2&&wt<wt_1)
          
      setBarBgColor(Color.yellow); 
      with the following code
      PHP Code:
      if(wt_1<wt_2&&wt>wt_1){
              
      drawTextRelative(-1AboveBar1"Buy"Color.bluenullText.PRESET|Text.CENTER"Arial"11"Buy"+rawtime());
          }else{
              
      removeText("Buy"+rawtime());
          }
              
          if(
      wt_1>wt_2&&wt<wt_1){
              
      drawTextRelative(-1BelowBar1"Sell"Color.rednullText.PRESET|Text.CENTER"Arial"11,"Sell"+rawtime());
          }else{
              
      removeText("Sell"+rawtime());
          } 
      which will draw the Buy and Sell text using the same conditions.
      Alex

      Comment


      • #4
        Thank you very much

        Thank you very much

        Comment

        Working...
        X