John Carter coloured momentum candles

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #209701 quote
    Alfy
    Participant
    Average

    Good morning guys, I’m trying to colour the candlesticks in my charts using a momentum indicator and although it is working

    DonchianMidline = (Highest[20](high)+Lowest[20](low)+Average[20](close) )/3
    sma=close-(DonchianMidline)
    Delta = linearregression[20](sma)
     
     
    if delta>0 and delta>delta[1] Then
    DRAWCANDLE(open, high, low, close)COLOURED(0,245,255)
    colour=1
    endif
     
    if delta>0 and delta<delta[1]  then
    DRAWCANDLE(open, high, low, close)COLOURED(0,0,255)
    colour=2
    endif
     
    if delta<0 and delta<delta[1]  then
    DRAWCANDLE(open, high, low, close)coloured(255,0,0)
    colour=3
    endif
    if delta<0 and delta>delta[1] then
    DRAWCANDLE(open, high, low, close)coloured(255,255,0)
    colour=4
    endif
    RETURN colour
    

     

    on the monthly and weekly charts, on the daily charts its doing something strange with all the prices squashed. Can someone take a look at my code and let me know what I’m doing wrong please?

    Best regards and thank you

    #209707 quote
    GraHal
    Participant
    Master

    Appears to works fine on mine?

    See attached on Monthly Chart

    #209709 quote
    Alfy
    Participant
    Average

    yep, works on weekly too but not on daily chart

    #209710 quote
    GraHal
    Participant
    Master

    Works fine on Daily Chart on mine, I checked up to 100K bars … very colourful! 🙂

    Alfy thanked this post
    #209711 quote
    Alfy
    Participant
    Average

    Strange, ok, thanks for the feedback

    #209717 quote
    JC_Bywan
    Moderator
    Master

    Maybe your scale on your daily chart isn’t set up the same way as in the other charts, you can check with right click on price scale on right margin, then in the menu pick the one at the end about “configuration of the zone” (not sure the exact english name of it), then as in attached image you are in “scale” menu (left side) and on the right side of the panel check the box about using price only is checked, it will avoid making visible the values 1 to 4 of the returned “colour” variable of your indicator added to price, assuming it was that kind of squashing.

    Maybe it wasn’t the problem at all, but the absence of screen capture also means absence of clues for those willing to help, we have to make hypothesis of what “squashed” means in the first place before wondering what might have done this. So maybe I got the wrong “squash”, and the wrong solution…

    Alfy thanked this post
    #209721 quote
    Alfy
    Participant
    Average

    All fixed. If interested please see attached fixed code.

    DonchianMidline = (Highest[20](high)+Lowest[20](low)+Average[20](close) )/3
    sma=close-(DonchianMidline)
    Delta = linearregression[20](sma)
     
     
    
    
     
     
    if delta>0 and delta>delta[1] Then
    DRAWCANDLE(open, high, low, close)COLOURED(0,245,255)
    endif
     
    if delta>0 and delta<delta[1]  then
    DRAWCANDLE(open, high, low, close)COLOURED(0,0,255)
    endif
     
    if delta<0 and delta<delta[1]  then
    DRAWCANDLE(open, high, low, close)coloured(255,0,0)
    endif
    if delta<0 and delta>delta[1] then
    DRAWCANDLE(open, high, low, close)coloured(255,255,0)
    endif
    RETURN
    #209732 quote
    GraHal
    Participant
    Master

    values 1 to 4 of the returned “colour” variable of your indicator

    To close the loop and so we all know for future on similar ‘squashings’ 🙂 … the amended code has removed the refs to colour 1 to 4.

    Alfy thanked this post
    #209734 quote
    Alfy
    Participant
    Average

    thanks so much for all your help!

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

John Carter coloured momentum candles


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Alfy @alfy Participant
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by Alfy
2 years, 12 months ago.

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