Announcement

Collapse
No announcement yet.

Paint bar of Rate of change of a moving average

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

  • Paint bar of Rate of change of a moving average

    Hello all,

    Trying to convert Easylanguage code to EFS.

    1. Need Rate of Change of an Exponential MA of a variable length that the user would define.
    2. If Rate of change is positive, would put a small green dot on bar
    3. If Rate of change is negative, would put a small yellow dot on bar.

    Thanks and the Easylanguage code is below if you need it.

    MC

    Input: Price(Close),Length(20),RC(1);

    Condition1 = RateOfChange((XAverage(Price, Length)), RC ) > 0; {Up Slope}
    Condition2 = RateOfChange((XAverage(Price, Length)), RC ) < 0; {Down Slope}


    value1 = H - ((h-l)/2.1);
    value2 = L + ((h-l)/2.1);

    PlotPaintBar(value1, value2, "PriceBarMA");

    If Condition1 Then
    SetPlotColor(1, Green)
    Else
    If Condition2 Then
    SetPlotColor(1, Yellow);

  • #2
    this should be close to your request, check it out...


    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description 7532


    //{{EFSWizard_Declarations

    var vEMA10 = new MAStudy(10, 0, "Close", MAStudy.EXPONENTIAL);
    var vLastAlert = -1;

    //}}EFSWizard_Declarations 9951


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("mcDot");
    //}}EFSWizard_PreMain 6396

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    vEMA10.getValue(MAStudy.MA, -1)-vEMA10.getValue(MAStudy.MA, -2) < vEMA10.getValue(MAStudy.MA, -2) - vEMA10.getValue(MAStudy.MA, -3)
    ) onAction1();
    //}}EFSWizard_Expression_1 12885
    if (
    vEMA10.getValue(MAStudy.MA, -1)-vEMA10.getValue(MAStudy.MA, -2) >= vEMA10.getValue(MAStudy.MA, -2) - vEMA10.getValue(MAStudy.MA, -3)
    ) onAction2();
    //}}EFSWizard_Expressions 22952


    //{{EFSWizard_Return
    return null;
    //}}EFSWizard_Return 2256

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    drawShapeRelative(0, high(), Shape.CIRCLE, "", Color.yellow, Shape.LEFT);
    vLastAlert = 1;
    }

    function onAction2() {
    drawShapeRelative(0, high(), Shape.CIRCLE, "", Color.red, Shape.LEFT);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_1 17046

    //}}EFSWizard_Actions 25130

    Comment


    • #3
      loomis,

      many thanks. it worked like a champ. learning efs ain't easy, but you are definitely making the learning curve less painful.

      it would be nice if i could change the size of the shapes like in ts 6.0. the sizesmake all the shapes a bit intrusive, but i'm not complaining.

      thanks again,
      largo

      Comment

      Working...
      X