Using ATR as SL or TP

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #8589 quote
    K12ANK12AN
    Participant
    Junior

    I would like to use the Average True Range (ATR) value as an exit criteria to my strategy.

    I would like to test the following possibilities. Any help would be much appreciated.

    1. Take profits if pips = ATR
    2. Take profit if pips = ATR/2
    3. Stop loss if pips = ATR
    4. Stop loss if pips = ATR/2
    5. Trailing stop if pipsĀ = ATR
    6. Trailing stop if pipsĀ = ATR/2
    #8592 quote
    NicolasNicolas
    Keymaster
    Legend

    Please find below a code snippet to code that:

    atr = averagetruerange[14]
    
    //set TP 2 times the ATR and SL 1 time the ATR
    SET TARGET PROFIT atr*2
    SET STOP LOSS atr
    
    #8598 quote
    K12ANK12AN
    Participant
    Junior

    Thank you for your prompt advice Nicolas.

    I will give it a try šŸ˜‰

    #8608 quote
    K12ANK12AN
    Participant
    Junior

    Would this be a problem if the ATR value is not a whole number? i.e. if ATR = 11.3 , would the SL or TP be set at 11 i.e. the nearest whole number?

    Or would it be rejected as 11.3 is not a valid pip value?

     

    Regards

    Kiran

    #8609 quote
    NicolasNicolas
    Keymaster
    Legend

    It’s not a problem since SET STOP LOSS and SET TARGET PROFIT need “price” value, not point one (these are different instructions : PLOSS and PPROFIT).

    e.g.:

    SET TARGET PROFIT 0.0032
    SET STOP LOSS 0.010
Viewing 5 posts - 1 through 5 (of 5 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

Using ATR as SL or TP


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
K12AN @k12an Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/01/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...