adding a moving average on the script, and plot

Optuma Forums Optuma Scripting adding a moving average on the script, and plot

This topic contains 4 replies, has 2 voices, and was last updated by  Sachin 3 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #46883

    Sachin
    • Topics: 1
    • Replies: 2
    • Posts: 3

    How to I add a moving average to the below script? I added it manually on the chart , but I want It on the script. This is what it looks like on the daily chart. could not get the plot function to get it to work( see pic below ). 

    thanks,

    q1=MACD(Week(PERIODAMOUNT=1), BAR1=12, BAR2=26, OSC=9).Histogram;  this worked 

    q2=MA(Week(PERIODAMOUNT=1), q1, BARS=20, STYLE=Center, CALC=Close); this did not work 

    q1 and q2 – does not look like below : 

     

    Capture

    #46887
    Matthew
    Matthew
    • Topics: 3
    • Replies: 67
    • Posts: 70

    Hi,

    You need to specify the plots after the script functions are set.  For example:

    The above script will produce a result as per the following image when used with a Show View tool…

    Ex5

    For more information on setting up multi plot scripts please refer to Section 10 of the Intermediate Scripting course here:

    https://learn.optuma.com/course/intermediate-scripting/

     

    #46891

    Sachin
    • Topics: 1
    • Replies: 2
    • Posts: 3

    thank you, but it is still not the same see below

    the 2nd one is where I add the ma manually . the top one is the script.  please help me to have them look the same.  I want it to look like the bottom one, what is wrong with the script? thanksCapture12 

    #46903
    Matthew
    Matthew
    • Topics: 3
    • Replies: 67
    • Posts: 70

    Hi,

    From what i can see the Moving Averages vary because a Time Frame over ride is being used in the histogram script. On the Show View where the MA is included as part of the script, the timeframe override for the histogram to weekly is picked up by the MA, and weekly values are used (so the data is padded, that is why the line is straight for each 5 bar segment).  That means the Moving Average is calculating the average of the last 20 weekly histogram values.

    With the other show view where the MA has been manually applied, the MA has no reference to the time frame override being used, as a result it calculates using the last 20 (daily) values of the histogram.

    When you change the charts time frame to weekly, you will see that both MA lines match.

    #46907

    Sachin
    • Topics: 1
    • Replies: 2
    • Posts: 3

    Got it , thank you !

    Got it , thank you !

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close