Calling indicator

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #102207 quote
    umebon
    Participant
    Average

    I’m need help how the code is for calling values from an indicator. The indicator is made by Thomas on this forum(thanks for sharing!) and i want to use the return of mytdaylow, mytdayhigh and mytdaycenter in my trading system but I don’t understand how too call it.

    Return mydayhigh COLOURED (255, 0, 0)style(line, 2) AS "High", mydaylow COLOURED (0, 255, 0)style(line, 2) AS "Low", mytdayhigh COLOURED (0, 255, 0)style(dottedline, 4) AS "Today High", mytdaylow COLOURED (255, 0, 0)style(dottedline, 4) AS "Today Low", mytdaycenter COLOURED (255,153,0,255)style(dottedline, 4)as "Today Centerline"
    #102210 quote
    Vonasi
    Moderator
    Master

    The syntax for CALL is:

    myValue1, myValue2, myValue3 = CALL "myIndicator"[parameter1,parameter2]

     

    where myvalue are the returned values and parameter is the variables required by the indicator (so for example a period or setting).

    So for your indicator replace myValue1 etc with your returned names and replace parameters with any that your indicator needs.

    If a value is not used in your strategy then just replace its name with ‘ignored’.

    umebon thanked this post
    #102211 quote
    umebon
    Participant
    Average

    Tnx, and what parameter do I use?

    Here is the whole code from the indicator that i use by Thomas

    // myCandel-Infos-V1.2
    // 18.06.2019 (Release 1.2)
    // Thomas Geisler
    // Sharing ProRealTime knowledge
    // https://www.prorealcode.com/library/
     
    defparam drawonlastbaronly=true // Zeichung nur am letzten Bar
    //--init--
    alpha = 255
    lookback = 1
    Info = 1
    Arrows = 1
    DayTrend = 1
    Centerline = 1
    HighLowIntraday = 1
    HighLow = 0
    Trendforce = 0
    OBVforce = 0
    //-- end--
     
    //--Info--
    // previous Candle Range[1] and ATR[10] and EMA-ATR[20]of ATR[1]
    myRange = round(Range[1])
    myATR = round(AverageTrueRange[10](close[0]))
    myEATR = round(ExponentialAverage[20](AverageTrueRange[10](close[0])))
    If Info = 1 then
    if myATR < ExponentialAverage[20](myATR) then
    DrawText("                           #myRange#/#myATR#/#myEATR#",barindex,open,Serif,Bold,12) coloured(153,153,153,alpha)
    else
    DrawText("                           #myRange#/#myATR#/#myEATR#",barindex,open,Serif,Bold,12) coloured(255,153,0,alpha)
    endif
    endif
    //--end--
     
    //--Dailys highest high and lowest Low--
    if HighLow then
    if openday <> openday[1] then
    dayindex = dayindex + 1
    dayhigh = 0
    daylow = close
    //dayopen = open
    //dayclose = close
     
    if dayindex > lookback then
    for j = 1 to barindex
    if dayindex[j] = dayindex - lookback then
    mydayhigh = dayhigh[j]
    mydaylow = daylow[j]
    break
    endif
    next
    endif
    endif
     
    dayhigh = max(dayhigh,high)
    daylow = min(daylow,low)
    endif
     
    if dayindex < lookback or not highlow then
    mydayhigh = undefined
    mydaylow = undefined
    endif
     
    if dayindex < lookback or not Centerline then
    mytdaycenter = undefined
    endif
    //--end--
     
    //-- proof close over/under high or low of intraday range--
    mytdayhigh=DHigh(0)
    mytdaylow=DLow(0)
    DM0 = (mytdayhigh-mytdaylow)/2+mytdaylow
     
    If DayTrend = 1 then
    if close > DM0 then
    DrawText("                         • over",barindex,open-10,Serif,Bold,12) coloured(0,255,0,alpha)
    else
    DrawText("                         • under",barindex,open+10,Serif,Bold,12) coloured(255,0,0,alpha)
    endif
    endif
    //--end--
     
    //--Centerline, center of range between intraday high/low--
    If CenterLine = 1 then
    mytdaycenter = DM0
    else
    mytdaycenter = undefined
    endif
    //--end--
     
    //--Show Intraday HighLow as dotted line--
    If HighLowIntraday = 1 then
    mytdayhigh = DHigh(0)
    mytdaylow = DLow(0)
    else
    mytdayhigh = undefined
    mytdaylow = undefined
    endif
    //--end--
     
     
    //--Arrows--
    //Trend bzw Trend force
    if Arrows = 1 then
    BullTrend = (Close - LOWEST[20](LOW)) / AVERAGETRUERANGE[10]
    BearTrend = (HIGHEST[20](HIGH) - Close) / AVERAGETRUERANGE[10]
    Trend = (BullTrend - BearTrend)
    TrendEMA = ExponentialAverage[20](Trend)
     
    // On Balance Volumen zur Bestimmung der Kaufkraft der Bewegung/Trend
    myOBV = OBV
    myOBVA1 = ExponentialAverage[20](myOBV)
    myOBVA2 = ExponentialAverage[10](myOBV)
     
    if Trendforce = 1 and OBVforce = 1 then
    If Trend > TrendEMA and myOBV > myOBVA1 and myOBV > myOBVA2 then
    DRAWARROWup(barindex,low-2) coloured(0,255,0,alpha)
    elsif Trend < TrendEMA and myOBV < myOBVA1 and myOBV < myOBVA2 then
    DRAWARROWdown(barindex,high+2)coloured(255,0,0,alpha)
    endif
    elsIf OBVforce = 1 and not Trendforce then
    if myOBV > myOBVA1 and myOBV > myOBVA2 then
    DRAWARROWup(barindex,low-2) coloured(0,255,0,alpha)
    elsif myOBV < myOBVA1 and myOBV < myOBVA2 then
    DRAWARROWdown(barindex,high+2)coloured(255,0,0,alpha)
    endif
    elsIf Trendforce = 1 and not OBVforce then
    if Trend > TrendEMA then
    DRAWARROWup(barindex,low-2) coloured(0,255,0,alpha)
    elsif Trend < TrendEMA then
    DRAWARROWdown(barindex,high+2)coloured(255,0,0,alpha)
    endif
    endif
    endif
    //--end--
     
    Return mydayhigh COLOURED (255, 0, 0)style(line, 2) AS "High", mydaylow COLOURED (0, 255, 0)style(line, 2) AS "Low", mytdayhigh COLOURED (0, 255, 0)style(dottedline, 4) AS "Today High", mytdaylow COLOURED (255, 0, 0)style(dottedline, 4) AS "Today Low", mytdaycenter COLOURED (255,153,0,255)style(dottedline, 4)as "Today Centerline"
     
     
    // End and make money
    
    #102213 quote
    Vonasi
    Moderator
    Master

    If there are any parameters that you have to set or can modify in the indicator window after it is applied to a chart then these are the parameters.

    #102214 quote
    umebon
    Participant
    Average

    I want the closing price (close) for each (day high, day low and day center) (5min) is that what I should put as a parameter or how do I write too get it?

    #102220 quote
    Vonasi
    Moderator
    Master

    I found some time to try to get CALL to work with that indicator but I couldn’t. There are no parameters needed but even if I created one by // out the lookback = 1 and creating lookback as a changeable parameter it still gives an error message.

    The following strategy should just call the indicator (named MyIndicator(13) in my case) and draw the same lines on the chart but it gives the attached error.

    ignored,ignored,mytdayhigh,mytdaylow,mytdaycenter = CALL "MyIndicator(13)"[1]
    
    buy 1 contract at -high limit
    
    graphonprice mytdayhigh 
    graphonprice mytdaylow 
    graphonprice mytdaycenter

    I tested the same on a different indicator and it worked just fine so there is something about this indicator that it does not like.

    You could just hard code the indicator into your strategy rather than use CALL while we all work out what is wrong.

    Screenshot_11.png Screenshot_11.png
    #102222 quote
    Vonasi
    Moderator
    Master

    From a quick scan through of the code it seems that the values that you want are just the daily high and daily low and a mid point between them which you can simply get by adding the following to your strategy:

    mytdayhigh=DHigh(0)
    mytdaylow=DLow(0)
    mytdaycentre = (mytdayhigh-mytdaylow)/2+mytdaylow
    #102238 quote
    umebon
    Participant
    Average

    Ok, I get the same error message when I run the program. It should work if we identify the problem. Thanks for the help and we keep in touch if we find a solotion.

    #102246 quote
    Nicolas
    Keymaster
    Master

    Just add (Close) at the end of the CALL instruction and it should work.

    umebon thanked this post
    #102251 quote
    Vonasi
    Moderator
    Master

    So the correct format is (change indicator name to whatever you have it named as):

    ignored,ignored,mytdayhigh,mytdaylow,mytdaycenter = CALL "MyIndicator"(close)

    This deals with the required customclose that the indicator needs. I’ve had this issue before (this time I was putting the close in the [ ] which is why I could not get it to work!)  Maybe the documentation for CALL needs a little update to cover this issue?

    umebon thanked this post
    #102252 quote
    Nicolas
    Keymaster
    Master

    I modified the CALL documentation.

    Vonasi and umebon thanked this post
    #102573 quote
    umebon
    Participant
    Average

    Hi

    I am on vacation and I will take a look at this when I am back. Superthanks for the help so far!!

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

Calling indicator


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
umebon @umebon Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by umebon
6 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/08/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...