Horizontal Shift MA -2 below/above MA

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #201998 quote
    sakkerssakkers
    Participant
    New

    Hi,

    I need help with the following code.  I want to add an extra condition to the below code but don’t know what the code is for horizontal shift.

    and WeightedAverage [17] horizontal shift -2 is above WeightedAverage[17](close)        for the top line

    and WeightedAverage [17] horizontal shift -2 is below WeightedAverage[17](close)        for the bottom line

     

    if close[0] > WeightedAverage[17](close) then
    DRAWCANDLE(open,high,low,close)COLOURED(0,80, 0)
    ENDIF
    
    if close[0] < WeightedAverage[17](close) then
    DRAWCANDLE(open,high,low,close)COLOURED(122, 85, 171)
    ENDIF
    RETURN
    #201999 quote
    JC_BywanJC_Bywan
    Moderator
    Master

    Hi,

    you can use for your horizontal shift -2: WeightedAverage[17](close)[2]

    or define a variable wa17, shift it, and simplify code script with added conditions with:

    wa17=WeightedAverage[17](close)
    
    if close[0] > wa17 and wa17[2]>wa17  then
    DRAWCANDLE(open,high,low,close)COLOURED(0,80, 0)
    ENDIF
    
    if close[0] < wa17 and wa17[2]<wa17 then
    DRAWCANDLE(open,high,low,close)COLOURED(122, 85, 171)
    ENDIF
    RETURN
    sakkers thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Horizontal Shift MA -2 below/above MA


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
sakkers @sakkers Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by JC_BywanJC_Bywan
3 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/06/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...