Use indicator value as a constant

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #183736 quote
    TraktorTraktor
    Participant
    New

    Hi Everybody

    I’m using the ATR indicator as my Stop loss and profit target and I want that value to not update with each new bar. I’ve tried different methods but nothing works so far.

    ATR = AverageTrueRange[14] 
    
    
    SET STOP pLOSS (1*ATR)
    SET TARGET pPROFIT (2*ATR)

    Here the Value of “ATR” updates as every new bar opens but I want to only get the value from the same bar as I opened my position and use that value as a constant but I can’t seem to figure out how.

    Thanks in advance

    #183781 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    ATR = AverageTrueRange[14] 
     
    If MyLongConditions and Not OnMarket Then
       Buy at Market
       SET STOP pLOSS (1*ATR)
       SET TARGET pPROFIT (2*ATR)
    Endif

    embedding the two lines in the IF…ENDIF block where a trade us entered ensures they won’t be executed each candle.

    Zigo thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

Use indicator value as a constant


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Traktor @traktor Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
4 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/22/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...