OR function in indicator don’t work…

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #205926 quote
    Robin81
    Participant
    Junior

    I made a script for finding equal lows on the DAX. I look for differences of 0, 0.5 and 1 points, because the price sometimes deviates slightly.

    Now I have made the script below, so that a line is placed on the graph. The problem is that the script can’t handle searching for 0, 0.5 and 1 simultaneously. I’ve used the function with OR and it doesn’t seem to work. I can of course put the formula in the script again to create three conditions, but it seems to me that there is a smarter way to do it.

    If I enter 1 value in Af1 it works perfectly, but with multiple values using the OR function it doesn’t work.

    Who knows how I can cleverly include this in the script with Af1= 0 OR 0.5 OR 1. What am I overlooking? 🙂

     

    //DAX same lows
    //26-11-22

    Af1 = 0 OR 0.5 OF 1

    //Same lows
    for p = 4 to 100 do
    if ABS(low[1] – low[p]) = Af1 THEN
    x1 = barindex[1]
    y1 = low[1]
    x2 = barindex[p]
    y2 = low[p]
    endif
    next
    DRAWSEGMENT (x1,y1,x2,y2)coloured(255,10,10)
    RETURN

    #205927 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    “or” is for booleans, not for choosing among various numbers.

    You could say you want anything between 0 and 1, with 1 included, by keeping a simple Af1=1 , and by using <= (it means inferior or equal to) this way:

    if ABS(low[1] – low[p]) <= Af1 THEN

    #205929 quote
    JS
    Participant
    Senior

    Hi @Robin81

    You can try this one…

     

    //DAX same lows
    //26-11-22
    
    Af1 = -0.5
    
    //Same lows
    While Af1<>1 do
    Af1 = Af1 + 0.5
    for p = 4 to 100 do
    if ABS(low[1] - low[p]) = Af1 THEN
    x1 = barindex[1]
    y1 = low[1]
    x2 = barindex[p]
    y2 = low[p]
    DRAWSEGMENT (x1,y1,x2,y2)coloured(255,10,10)
    endif
    next
    WEnd
    RETURN
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

OR function in indicator don’t work…


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Robin81 @robin81 Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by JS
3 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/16/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...