Custom Indicator variable values

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14356 quote
    rohandowling23
    Participant
    New

    Hi.

    I’m new to prorealtime and need some help.

    I’ve come across the problem (not a new one, actually well documented) regarding proorder having limited stop loss functionality.

    I’m seen the post for how to “Complete trailing stop code function” http://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/ but I don’t understand the code.

    So I’ve tried to create an indicator than would show me what my stops would be. I’ve dumped the code at the bottom

    Basically

    1. assuming a long position entered @ 1.03
    2. want a maximum loss of 30bp
    3. want a trailing stop loss of 20bps with a 5bp step

    My question is

    1. how can I view results for variables I create, ie “mystep”?
    2. I know my code is poor, what could you recommend to enhance?

     

    //trailing stop function
    trailingstart = 20 //trailing will start 
    trailingstep = 5 //trailing step to move the "stoploss"
    mybailout = 30  //my stop loss point
    
    
    mytradeprice = 1.03  //setting random trade price assumming long position
    
    
    IF close >= mytradeprice+(trailingstart*pipsize) then
    ITM = 1  //if 1 when use trailing loss, if 0 use stop loss
    ENDIF
    
    IF close < (mytradeprice+(trailingstart*pipsize)) then
    ITM = 0
    ENDIF
    
    IF ITM = 0 then
    mySL = mytradeprice-(mybailout*pipsize)
    ENDIF
    
    IF ITM = 1 then
    mystep = (close -trailingstart*pipsize)/trailingstep    //counts the number of steps the trailing profit has taken above the trailingstart
    ENDIF
    
    IF ITM = 1 then
    mySL = mytradeprice+(trailingstart*pipsize)+(mystep*(trailingstep*pipsize))
    ENDIF
    
    
    return mySL as "Closeout"
    
    
    #14414 quote
    rohandowling23
    Participant
    New

    Hi All

     

    I figured it out, you just have to use the return function. I have done the majority of my coding in VBA so you can see the variable as you step through the code

    Have updated my code (for long positions only) to have an indicator that will show you you exit levels

     

    //trailing stop function
    
    //variables
    mytradedprice = open  
    myclose = close
    
    trailingstart = 10 //trailing will start
    trailingstep = 5 //trailing step to move the "trailing stop"
    mybailout = -10  //my stop loss point
    
    
    trailingstartprice = mytradedprice+(trailingstart*pipsize)
    trailingstopprice = mytradedprice+(mybailout*pipsize)
    myprofit = myclose - trailingstartprice
    
    ITM = 0
    IF myclose >= trailingstartprice then
    ITM = 1
    else
    ITM = 0
    ENDIF
    
    IF ITM = 0 then
    mySL = trailingstopprice
    else
    mysteps = (myclose - trailingstartprice)/(trailingstep*pipsize)
    rmysteps = round(mysteps)
    mySL = trailingstartprice + (rmysteps*trailingstep*pipsize) - (trailingstart*pipsize)
    ENDIF
    
    return mytradedprice as "My Open Price", mySL as "My Closeout Price", myprofit as "Profit"
    #14424 quote
    Nicolas
    Keymaster
    Master

    Great! But in ProBacktest you can also use GRAPH which is likely a ‘return’ function into automated trading code.

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

Custom Indicator variable values


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Nicolas
9 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/06/2016
Status: Active
Attachments: No files
Logo Logo
Loading...