MA of bullish candlesticks

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

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

    #70383 quote
    NicolasNicolas
    Keymaster
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

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

    #70433 quote
    NicolasNicolas
    Keymaster
    Legend

    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
    NicolasNicolas
    Keymaster
    Legend

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

    #70540 quote
    edfredfredfredfr
    Participant
    Junior

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

    his-5.jpg his-5.jpg
    #70553 quote
    robertogozzirobertogozzi
    Moderator
    Legend

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

    Please stick to the topic! Thank you.

    #70569 quote
    NicolasNicolas
    Keymaster
    Legend

    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
    moving-average-of-bullish-and-bearish-candlesticks.png moving-average-of-bullish-and-bearish-candlesticks.png
    #70585 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Thank you very much Nicolas!

Viewing 9 posts - 1 through 9 (of 9 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

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 robertogozzirobertogozzi
8 years, 4 months ago.

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