how to code multiple consecutive conditions with MACD?

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #190294 quote
    ZeroCafeine
    Participant
    Senior

    how to get this screener but only when the both of MACD < 0 and MySLine  < 0 ? I think also they have a problem to reset the variable, because when the condition “Cond ” is true I think is true all the time ?

    #190306 quote
    ZeroCafeine
    Participant
    Senior

    I answer to my self for a small problem, I use the CPx as a condition but it’s just a condition for continue or nor the for loop

    #190316 quote
    robertogozzi
    Moderator
    Legend

    This is the updated screener with both variables < 0 and conditions that are always cleared at the beginning:

    //Defparam drawonlastbaronly = true
    MyMACD    = MACDline[12,26,9](close)
    MACDflag  = MyMACD < 0
    MySLine   = MACDSignal[12,26,9](close)
    SLINEflag = MySline < 0
    //MyHis = MACD[12,26,9](close)
    //Offset = 10 * pipsize
    p1     = 10
    p2     = 50
    // (。♥‿♥。) Block Start
    // Block End (。♥‿♥。)
    CP3 = 0
    CP2 = 0
    CP1 = 0
    IF MyMACD < 0 AND MySLine < 0 THEN
     
    // (。♥‿♥。) Block Start P3
    //BACKGROUNDCOLOR (0, 155, 10, 25)
    FOR X3 = 0 To p1 Do
    //IF MyMACD[Y] Crosses Under MySLine[Y] AND MyMACD[Y] < 0 AND MySLine[Y] < 0 THEN
    IF MyMACD[X3] Crosses Under MySLine[X3] THEN
    //AbscisseP3 = X3
    //BarP3 = Barindex[X3]
    CP3 = 1
    //Drawtext("#X3#", Barindex[X3], Low[X3]-1)
    //DRAWELLIPSE(BarP3-1,LOW[X3]-Offset,BarP3+1,HIGH[X3]+Offset)coloured(255,10,10)
    Break
    //ELSE
    //CP3 = 0
    ENDIF
    Next
    // Block End (。♥‿♥。)P3
     
    // (。♥‿♥。) Block Start P2
    IF CP3 THEN
    FOR X2 = X3 To X3+p1 Do
    //IF MyMACD[Y] Crosses Under MySLine[Y] AND MyMACD[Y] < 0 AND MySLine[Y] < 0 THEN
    IF MyMACD[X2] Crosses Over MySLine[X2] THEN
    //AbscisseP2 = X2
    //BarP2 = Barindex[X2]
    CP2 = 1
    //Drawtext("#X2#", Barindex[X2], Low[X2]-1)
    //DRAWELLIPSE(BarP2-1,LOW[X2]-Offset,BarP2+1,HIGH[X2]+Offset)coloured(255,10,10)
    Break
    //ELSE
    //CP2 = 0
    ENDIF
    Next
    ENDIF
    // Block End (。♥‿♥。)P2
     
    // (。♥‿♥。) Block Start P1
    IF CP2 THEN
    FOR X1 = X2 To X2+p2 Do
    //IF MyMACD[Y] Crosses Under MySLine[Y] AND MyMACD[Y] < 0 AND MySLine[Y] < 0 THEN
    IF MyMACD[X1] Crosses Under MySLine[X1] THEN
    //AbscisseP1 = X1
    //BarP1 = Barindex[X1]
    CP1 = 1
    //Drawtext("#X1#", Barindex[X1], Low[X1]-1)
    //DRAWELLIPSE(BarP1-1,LOW[X1]-Offset,BarP1+1,HIGH[X1]+Offset)coloured(255,10,10)
    Break
    //ELSE
    //CP1 = 0
    ENDIF
    Next
    ENDIF
    // Block End (。♥‿♥。)P1
     
    ENDIF
    // tks to the Nisola's Cours ;-)
    Cond = CP1 AND CP2 AND CP3 AND MACDflag AND SLINEflag
    SCREENER[Cond]
Viewing 3 posts - 16 through 18 (of 18 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

how to code multiple consecutive conditions with MACD?


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 17 replies,
has 3 voices, and was last updated by robertogozzi
4 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/28/2022
Status: Active
Attachments: 5 files
Logo Logo
Loading...