need help to programm this pattern with MACD

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #205243 quote
    ZeroCafeineZeroCafeine
    Participant
    Senior
    Hi everyone, I need your help to program this pattern, I have tried several different codes and I find more or less results, but it is not great, A code to detect zones 1, 2 and 3 Z3 = MACD MACD Z1 = MACD < S-Line Z1, Z2 and Z3 < 0 and there is a sample of code and picture to explain
                                               
    //    _  _   _       _ _         _
    //   /_\| |_| |_ _ _(_) |__ _  _| |_ ___
    //  / _ \  _|  _| '_| | '_ \ || |  _(_-<
    // /_/ \_\__|\__|_| |_|_.__/\_,_|\__/__/
    MyMACD = MACDline[12,26,9](close)
    MySLine = MACDSignal[12,26,9](close)
    
    PointA = MyMACD Crosses Over MySLine AND MyMACD < 0 AND MySLine < 0
    
    IF PointA Then
    FOR X3 = 1 To 100 Do
    IF MyMACD[X3] Crosses Under MySLine[X3] AND MyMACD[X3] < 0 AND MySLine[X3] < 0 Then
    AbscisseX3 = X3
    BarIndX3 = Barindex[X3]
    CondP3 = 1
    Break
    ELSE
    CondP3 = 0
    ENDIF
    Next
    
    IF CondP3 Then
    FOR X2 = X3+1 To 100 Do
    IF MyMACD[X2] Crosses Over MySLine[X2] AND MyMACD[X2] < 0 AND MySLine[X2] < 0 Then
    AbscisseX2 = X2
    BarIndX2 = Barindex[X2]
    CondP2 = 1
    Break
    ELSE
    CondP2 = 0
    ENDIF
    Next
    ENDIF
    
    IF CondP2 Then // AND Not CondP3[1]
    FOR X1 = X2+1 To 100 Do
    IF MyMACD[X1] Crosses Under MySLine[X1] AND MyMACD[X1] < 0 AND MySLine[X1] < 0 Then
    AbscisseX1 = X1
    BarIndX1 = Barindex[X1]
    CondP1 = 1
    Break
    ELSE
    CondP1 = 0
    ENDIF
    Next
    ENDIF
    ELSE
    CondP3 = 0
    CondP2 = 0
    CondP1 = 0
    ENDIF
    
    AllCondition = CondP3 AND CondP2 AND CondP1
    
    // ########################################################################
    //    _ _     ___      _              _               _ _
    //  _| | |_  |   \ ___| |__ _  _ __ _(_)_ _  __ _   _| | |_
    // |_  .  _| | |) / -_) '_ \ || / _| | ' \/ _ | |_  .  _|
    // |_     _| |___/\___|_.__/\_,_\__, |_|_||_\__, | |_     _|
    //   |_|_|                      |___/       |___/    |_|_|
    Debuging = 0
    If Debuging Then
    DRAWTEXT("#CondP3#", barindex, pipsize)
    DRAWTEXT("#CondP2#", barindex, - pipsize)
    DRAWTEXT("#CondP1#", barindex,- 3 * pipsize)
    DRAWTEXT("#AllCondition#", barindex, - 5 * pipsize)
    ENDIF
    
    IF AllCondition AND Not AllCondition[1] Then
    BACKGROUNDCOLOR(0,255,0,42)
    DrawRectangle(BarIndX1, 2*pipsize , BarIndX3, -2*pipsize)
    DRAWTEXT("◄", barindex, pipsize)
    DRAWTEXT("►", BarIndX1, pipsize)
    ENDIF
    
    RETURN
    
    Best Reguards
    SmartSelect_20221204-173615_Samsung-Notes.jpg SmartSelect_20221204-173615_Samsung-Notes.jpg
    #205302 quote
    JSJS
    Participant
    Master

    Hi @ZeroCafeine

    Try this…

    The pattern is red-green-red-green…

    MyMACD = MACDline[12,26,9](close)
    MySLine = MACDSignal[12,26,9](close)
    
    For i=0 to 100
    If MyMACD[i] Crosses Over MySLine[i] and MyMACD[i]<0 and MySLine[i]<0 then
    PointA = BarIndex[i]
    DrawVLine(PointA) Coloured(255,0,0)
    Break
    EndIf
    
    If MyMACD[i] Crosses Under MySLine[i] and MyMACD[i]<0 and MySLine[i]<0 then
    X3 = BarIndex[i]
    DrawVLine(X3) Coloured(0,255,0)
    Break
    EndIf
    Next
    
    Return MyMACD as "MyMACD" coloured(0,0,255), MySLine as "MySLine" coloured(255,0,0)
    
    Nicolas and ZeroCafeine thanked this post
    Scherm­afbeelding-2022-12-05-om-23.14.49.png Scherm­afbeelding-2022-12-05-om-23.14.49.png
    #205306 quote
    JSJS
    Participant
    Master

    It’s not necessary to use a For-loop here…

     
    MyMACD = MACDline[12,26,9](close)
    MySLine = MACDSignal[12,26,9](close)
    
    
    If MyMACD Crosses Over MySLine and MyMACD<0 and MySLine<0 then
    PointA = BarIndex
    DrawVLine(PointA) Coloured(255,0,0)
    EndIf
    
    If MyMACD Crosses Under MySLine and MyMACD<0 and MySLine<0 then
    X3 = BarIndex
    DrawVLine(X3) Coloured(0,255,0)
    EndIf
    
    Return MyMACD as "MyMACD" coloured(0,0,255), MySLine as "MySLine" coloured(255,0,0)
    
    Nicolas and ZeroCafeine thanked this post
Viewing 3 posts - 1 through 3 (of 3 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

need help to programm this pattern with MACD


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by JSJS
3 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/04/2022
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...