how to code multiple consecutive conditions with MACD?

Forums ProRealTime English forum ProBuilder support how to code multiple consecutive conditions with MACD?

Viewing 15 posts - 1 through 15 (of 18 total)
  • #189073

    hi everyone,

    I’m trying to turn this image into code, could you help me or is there something similar that is already coded?

    how to detect :
    – X bar red
    – X bars green
    – finaly X bars red

    or in the same idea how to detect :
    – MACD > S-Line on X bars
    – MACD < S-Line on X bars
    – finaly MACD > S-Line on X bars

     

    #189088

    #1

    #2

     

    1 user thanked author for this post.
    #189091

    tks you so much, in addition I just bought Nicolas’ training ;-), and tks agin 🙂

    1 user thanked author for this post.
    #189092

    I tryed the both code and get all the time 0, it’s mean the condition is never reached, but it’s will help me for my home work,

    what is mean using the summation here ? and why Px :

    not easy for me to understand

    #189096

    p1 is the first periods, p2 is the second period and p3 is the last period (the latest bars).

    I was returned many items on shares.

    You can test it as a screener replacing the last line with

     

    1 user thanked author for this post.
    #189419

    Big tks to your answere, I do to much time to understand the logic, I’m to old :-), how to detect the lowest Red2 and Red1 persiode pls ?

    tks in advance

    #189437

    I am attaching a diagram, both as a Pic and eXcel file.

    I hope it’s clear.

     

    1 user thanked author for this post.
    #189455

    Hi Roberto,

    Your explanations are not clear but Very Clear, so that is the code and the photo of Excel files :

     

    now the question is how to use Px as a variable, I mean for exemple the P2 it’s was maybe 3 or 6 or 10 ?, you can also give me just a link if you have and I will work on it, and tks again for your help

    #189471

    I modified the title of the topic, please try to

    • Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
    1 user thanked author for this post.
    #189498

    You can simply use several constants, p1, p2 and p3, like I did in the code above, or you can use arrays to store as many values you need:

    1 user thanked author for this post.
    #189502

    ok tks you, I don’t understand what is mean the $p ?, about array I don’t know because I never learn about it but I can imagine the idea you want to tell me,

    so I hope this is my last question for this thread, do you think it will be beter to make this screener with a FOR boucle condition to detect what I need in like this exemple :

    Best Reguards

    #189505

    $p[] is an array. You can find info at https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/.

    No, your example is not correct.

    If you can explain your idea with more details I may try to help you. If you mean to apply arrays to the code above, then my answer is no, you can’t, because of the logic behind that code.

     

    1 user thanked author for this post.
    #189515

    tks again for your answers, I will get time and make somethink as an indicator or as a screener and try if my idea and what I have in my head can work or not and put the result here, maybe 2 or 3 days I hope no more, tks again roberto for all your help

    #189572

    hi all

    I think I found what I want as an indicator, I will try to change it as a screener, I have a problem to code directly a screener because I can’t draw on it, or maybe they have solution, so I made this () code can detect what I want, like you to in your exemple
    P3 = Red2 (from bar IDs 0 to 10)
    P2 = Green1 (from bar IDs X3 to X3+10)
    P1 = Red1 (from bar IDs X2 to X2+50)

    and I think we can change the first 10 to a variable and the 50 to a variable too, that is the code :

    and I also add a photo for the understanding

    d

    #189802

    This is the code that I modified to:

    • use PipSize, otherwise it will plot correctly only on instruments with a pip ratio of 1
    • replace the offset of graphic objects with a variable named OFFSET
    • replace 10 and 50 periods, with variables P1 and P2:

    and this is the screener:

     

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 18 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login