How to get the current points ahead or behind in code

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #162885 quote
    charleskyriakoucharleskyriakou
    Participant
    Junior

    I would like to vary a trailing stop loss mid-trade depending on the current points ahead / behind of the trade, but I can’t seem to find the constant in the coding window function help. Does anyone know if this exists or how I can derive this value?

    Thanks in advance.

    #162899 quote
    MattiasMattias
    Participant
    Senior

    Something like this?

    status = close - tradeprice(1)

    Simply check the difference between the current close and which price the last order was executed.

    charleskyriakou thanked this post
    #162921 quote
    VonasiVonasi
    Moderator
    Master

    Mattias’s suggestion will only work for long positions so you will need to use the reversed calculation for short positions:

    status = tradeprice(1) - close

    Also if you have multiple positions open at multiple prices then it won’t work.

    You should consider using COUNTOFPOSITION with POSITONPRICE or POSITIONPERF in a calculation.

    COUNTOFPOSITION

    POSITIONPRICE

    POSITIONPERF

    Nicolas, Mattias and charleskyriakou thanked this post
Viewing 3 posts - 1 through 3 (of 3 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

How to get the current points ahead or behind in code


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by VonasiVonasi
5 years, 6 months ago.

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