adding a moving average on the script, and plot

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

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
    • Topics: 5
    • Replies: 367
    • Posts: 372

    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

    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
    • Topics: 5
    • Replies: 367
    • Posts: 372

    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 !

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

Pin It on Pinterest