How to get the current points ahead or behind in code

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #162885 quote
    charleskyriakou
    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
    Mattias
    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
    Vonasi
    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.

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 Vonasi
4 years, 11 months ago.

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