How to code a change of the "ribbon"

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #97962 quote
    AlgoAlex
    Participant
    Master

    Given a number of moving averages with different periods, I would like to code the first moment when they are arranged by order, for example:

    ma1=Average[1]
    ma2=Average[2]
    ma3=Average[3]
    ma4=Average[4]
    
    ma1>ma2>ma3>ma4

    and that only candle to use as an entry signal.

    Hope I have been clear.

     

    Thanks anybody

     

    Alex

    #97964 quote
    robertogozzi
    Moderator
    Master
    ma1=Average[1]
    ma2=Average[2]
    ma3=Average[3]
    ma4=Average[4]
    x = ma1 > ma2 AND ma2 > ma3 AND ma3 > ma4
    return x

    So.

    • x > x[1]    will tell you the first bar when they are in order
    • x < x[1]    will tell you the first bar when they are no more in order
    • x <> x[1] will tell you whenever there’s been a change from order to disorder and viceversa
    AlgoAlex thanked this post
    #97967 quote
    AlgoAlex
    Participant
    Master

    So.

    • x > x[1] will tell you the first bar when they are in order
    • x < x[1] will tell you the first bar when they are no more in order
    • x <> x[1] will tell you whenever there’s been a change from order to disorder and viceversa

    So, if I would code an entry, it would be like:

    slope=x-x[1]
    
    if slope crosses over 0 then
    buy at market

    Am I right?

    #97982 quote
    robertogozzi
    Moderator
    Master

    Yes, sure.

    You may also add GRAPH to your code to watch desired values as they change candle after candle.

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

How to code a change of the "ribbon"


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
AlgoAlex @alexf Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/08/2019
Status: Active
Attachments: No files
Logo Logo
Loading...