CALL issue?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #88598 quote
    robdav
    Participant
    Veteran

    Hi

    First of all let me explain what I’m trying to do here, hopefully this isn’t me missing something!

    My main indicator returns 14 variables. As part of this indicator I return these values at barindex so they are always visible because they change often and as a result I have to set DEFPARAM DRAWONLASTBARONLY = True as otherwise they would be continually blurred across the chart.

    I would also like to use these 14 variables and use DRAWARROW at barindex-1 when price equals any one of them in the past, therefore I have to set DEFPARAM DRAWONLASTBARONLY = False as otherwise I would miss when the condition occurred.

    Obviously I cannot achieve this in one indicator because of the conflicting DEFPARAM DRAWONLASTBARONLY setting. If I break this out into two indicators it’s fine. The problem is, the calculations for the 14 variables are quite CPU intensive as they are, therefore if I duplicate the code into two separate indicators I am exacerbating the problem and the indicators are very slow.

    So I thought about trying to use the CALL command in the second indicator to see if this helps. The problem is I’m either using the CALL function incorrectly or there is a problem with it.

    Without providing my exact code I have written a couple of indicators to highlight the issue I’m experiencing. Basically if I only add the ‘CALLING_INDICATOR’ to my chart (added on price) it draws everything that’s in the ‘MAIN_INDICATOR’ even though it is not added to the the chart at all and isn’t part of anything I’ve ‘CALL’ed. Is this the expected behavior?

    Thanks, Rob

    DEFPARAM DRAWONLASTBARONLY = True
    
    // Arrows is a boolean, true or false toggle option as a variable for the indicator setting
    
    // Donchian
    hh = highest[30](High)
    ll = lowest[30](Low)
    middle = (hh-ll)*0.500
    
    IF Arrows = 1 THEN
    
    // Long signal
    IF close = hh THEN
    DRAWSEGMENT(barindex, hh, barindex[1], hh[1]) coloured(0,0,0)
    DRAWARROW(barindex-1,hh) COLOURED (10,255,10,50)
    DRAWCANDLE(Open,High,Low,Close) COLOURED (0,0,0) BORDERCOLOR(0,0,0)
    ENDIF
    
    // Short signal
    IF close = ll THEN
    DRAWARROW(barindex-1,ll) COLOURED (255,10,10,50)
    DRAWCANDLE(Open,High,Low,Close) COLOURED (0,0,0) BORDERCOLOR(0,0,0)
    DRAWSEGMENT(barindex, ll, barindex[1], ll[1]) coloured(01,0,0)
    ENDIF
    
    ENDIF
    
    drawtext("                        -- 100.0%",barindex,hh,Monospaced,Standard,11) coloured(0,0,0)
    drawtext("                                               (#hh#)",barindex,hh,Monospaced,Standard,11) coloured(0,0,0)
    
    drawtext("                        -- 0.00%",barindex,ll,Monospaced,Standard,11) coloured(0,0,0)
    drawtext("                                               (#ll#)",barindex,hh,Monospaced,Standard,11) coloured(0,0,0)
    
    RETURN hh, ll, middle
    
    DEFPARAM DRAWONLASTBARONLY = False
    
    ignored, ignored, middle = CALL "MAIN_INDICATOR"[1]
    
    // Long signal
    IF close = middle THEN
    DRAWARROW(barindex-1,middle) COLOURED (10,255,10,50)
    ENDIF
    
    RETURN
    
    MAIN_INDICATOR.itf CALLING_INDICATOR.itf
    #88608 quote
    robertogozzi
    Moderator
    Master

    Yes, because if you CALL an indicator it means you want to use it, doesn’t it?

    If you DON’T want to display those objects when youe MAIN_INDICATOR is CALLed then you’ll have to add a variable called “Flag” (or whatever you prefer) as either True or False, then use the false value when CALLing it, while setting it to true when it’s on your charts.

    Of course you’ll have to change all lines where any (un)wanted object is drawn so that they are executed only when the variable FLAG is set.

    robdav and Nicolas thanked this post
    #88656 quote
    robdav
    Participant
    Veteran

    Yes, because if you CALL an indicator it means you want to use it, doesn’t it?

    If you DON’T want to display those objects when youe MAIN_INDICATOR is CALLed then you’ll have to add a variable called “Flag” (or whatever you prefer) as either True or False, then use the false value when CALLing it, while setting it to true when it’s on your charts.

    Of course you’ll have to change all lines where any (un)wanted object is drawn so that they are executed only when the variable FLAG is set.

    Personally, If I CALL a variable from an indicator and ignore the other two then it would be better if it just returned what I called rather than non variable content (i.e. all the DRAW code etc) but there you go.

    Alternatively if we could control DEFPARAM DRAWONLASTBARONLY within code sections rather than globally then that would also be good.

    #88748 quote
    Nicolas
    Keymaster
    Master

    Because DRAWONLASTBARONLY is set to false in the main code, it is normal that it overrides the one set in the CALLed indicator.

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

CALL issue?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
robdav @robdav Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Nicolas
7 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/14/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...