MA of bullish candlesticks

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #70378 quote
    robertogozzi
    Moderator
    Master

    Is it possible to write an SMA that only operates un candles having a bullish body, while ignoring the other ones?

    #70383 quote
    Nicolas
    Keymaster
    Master

    Yes you can use the “non linear data serie SMA” I introduced in this code: Moving Average of Price Median  (and other examples in the New Renko System thread).

    Are you reinventing the RSI? 😉

    robertogozzi thanked this post
    #70418 quote
    robertogozzi
    Moderator
    Master

    No, I was just wondering what crossings may happen creting two different MAS, one for Bullish candles and one for Bearish ones.

    #70433 quote
    Nicolas
    Keymaster
    Master

    Well, that’s an idea! I think we could it easily with the examples I pointed. I will code it tomorrow.

    robertogozzi thanked this post
    #70533 quote
    Nicolas
    Keymaster
    Master

    Sorry Roberto, I forgot to code your project today. Please remind me later! 😉

    #70540 quote
    edfredfr
    Participant
    Junior

    Nicolas please look at me  picture . no more back data BAR !!

    #70553 quote
    robertogozzi
    Moderator
    Master

    Nicolas please look at me picture . no more back data BAR !!

    Please stick to the topic! Thank you.

    #70569 quote
    Nicolas
    Keymaster
    Master

    Here is the code of what you are looking for, the moving average of bullish and bearish candlesticks:

    priceMAperiod=20
    
    countup=0
    countdn=0
    sumup=0
    sumdn=0
    lastup=0
    lastdn=0
     
    for i = 0 to barindex do
    if close[i]<>lastup and close[i]>open[i] then
    lastup=close[i]
    countup=countup+1
    priceup=lastup
    sumup=sumup+priceup
    endif
    if countup=priceMAperiod then
    break
    //
    endif
    next
    for i = 0 to barindex do
    if close[i]<>lastdn and close[i]<open[i] then
    lastdn=close[i]
    countdn=countdn+1
    pricedn=lastdn
    sumdn=sumdn+pricedn
    endif
    if countdn=priceMAperiod then
    break
    //
    endif
    
    next
    if lastup<>lastup[1] then
    avgup = sumup/priceMAperiod
    endif
    if lastdn<>lastdn[1] then
    avgdn = sumdn/priceMAperiod
    endif
    
    
    return avgup coloured(0,200,0), avgdn coloured(200,0,0)
    robertogozzi thanked this post
    #70585 quote
    robertogozzi
    Moderator
    Master

    Thank you very much Nicolas!

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

MA of bullish candlesticks


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by robertogozzi
7 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/14/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...