Volatility indicator

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #90282 quote
    mjharm
    Participant
    New

    To forum members,

    I have been using a volatility based indicator within other programs, Beyond Charts, Metastock, to act as a Macro over an index.

    If the market volatility is too great, say above 8%, then I do not enter any positions.

    There does not appear to be such an indicator available within Pro Real Time.

    The code for such an indicator from Metastock is as follows:

    XAOATR:=Security(“C:Trading DataStocksASXIndicesXAO”,ATR(5));
    XAO:=Security(“C:Trading DataStocksASXIndicesXAO”,C);
    XAOATR/XAO*100;
    5;
    7;
    ATR(5)/C*100; 5; 7;

    So if possible can this code be translated into ProRealCode. The index which I am trialing it on is the Nasdaq.

    Hoping this makes sense and someone is able to help.

    Kind regards

    mjharm.

    mechanicaltrade thanked this post
    #90318 quote
    Nicolas
    Keymaster
    Master

    That could be coded like this:

    //ATR(5)/C*100
    volat = averagetruerange[5]/close*100
    
    RETURN volat, 8

    (not tested).

    mjharm thanked this post
    #90392 quote
    mjharm
    Participant
    New

    Thank you Nicolas very much for your prompt expertise in coding the volatility formula I recently posted.

    I have tested it and when it displays on a chart ( Ticker- Nasdaq, Name- US Tech 100 Cash ) the desired result is not displayed.

    As an example- ATR is 323 and the Close price is 6876. Therefore 323/6876*100 = 4.69%.

    The window at the bottom which has the Volat line applied to it displays 94.48.

    Also enquiry with regard to the values on the right hand side of the displayed window – Is it possible to make the scale a percentage instead of a number which it currently is?

    Happy to accept these questions may be more appropriate to IG direct and if so please advise and I will follow up with them.

    Kind regards

    mjharm

    #90394 quote
    Nicolas
    Keymaster
    Master

    The code I made is actually making the right calculation according to your original code.

    Take ATR of 5 periods, divided it by the current Close and put it in percentage format.

    If I take the value of yesterday Sunday 3rd (on a daily timeframe),

    ATR is 90.20, Close is 6874.4, so the formula returned 90.20/6874.4*100 = 1.31%

    See attached picture.

    mjharm thanked this post
    volatility-indicator.jpg volatility-indicator.jpg
    #90489 quote
    mjharm
    Participant
    New

    Hi Nicolas,

    Yes you are correct. I was not putting the code in its own window below the chart- I was placing the indicator- aptly  called ‘ nicolas volat’ – inside of the ATR window.

    Rookie mistake no doubt. Your attached image cleared up the problem.

    Thanks again Nicolas – you are a legend!

    mjharm

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Volatility indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
mjharm @mjharm Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by mjharm
7 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/02/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...