Announcement

Collapse
No announcement yet.

Price percentage from MA

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

  • Price percentage from MA

    Can any one out there write a study that can measure the following for me......
    If the price is above the 50MA what is the difference of it's high from the MA in Percentage terms.

    If the price is below the 50MA what is the difference of it's low from it's MA in percentage terms.

    If the indicator is x or greater, then Place dot on bar or, colour bar on price.

    Sure hope someone can help out.

    Jack

  • #2
    Jack
    You can do that using the builtinMA.efs that is in the builtin folder.
    Just after the comment section "Insert your code..." add the following lines

    PHP Code:
    var percDiff 0;
     
        if(
    close()>vMA.getValue(MAStudy.MA))
            
    percDiff = ((high()-vMA.getValue(MAStudy.MA))/vMA.getValue(MAStudy.MA))*100;
        if(
    close()<vMA.getValue(MAStudy.MA))
            
    percDiff = ((low()-vMA.getValue(MAStudy.MA))/vMA.getValue(MAStudy.MA))*100
    Then change the return statement from return vMA.getValue(MAStudy.MA) to return percDiff;. Lastly in preMain change setPriceStudy(true); to setPriceStudy(false); and modify the default length of the MA to 50
    At this point you can set up your conditions to evaluate if percDiff is greater/lesser than your specification and color the price bar when that happens.
    FWIW the results are not much different than what you would get when using the Price Oscillator set to 1 and 50 for the lengths of the averages. The shape of the oscillator is very similar with only slightly different values.
    An even simpler way is to use the Envelope study with the bands set at the same percentage value that would trigger the signal on the oscillator
    Alex

    Comment

    Working...
    X