TradePrice Entry and Exit

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #213258 quote
    ZeroCafeine
    Participant
    Senior

    Hi

    I read the documentation about the TradePrice function and I do some tests and I realize that the TradePrice function does not make the difference between an entry price and an exit price, is there a solution to remedy this problem?

    For example on the documentation we can use the following code:

    IF BARINDEX-TRADEINDEX(1)>5 ......

    The problem is that if you use a filter to enter a trade after five candles then when you exit a trade you will also have to wait five candles to re-enter.

    Other question: If I have for example a position with five different entries how can I allocate to five different variables (or more) the entry price to be able to use them in the future and reset them once I have exited my position completely (or partially to complicate things further)

    Tks in advance for your light or you links,

    Best Reguards,
    ZeroCafeine

    #213265 quote
    JS
    Participant
    Senior

    Hi,

    You can simply use…

    If OnMarket then

    myEntryPrice = TradePrice

    EndIf

    If NOT OnMarket then

    myExitPrice=TradePrice

    EndIf

    ZeroCafeine thanked this post
    #213270 quote
    ZeroCafeine
    Participant
    Senior

    tks you @JS

    Do you have another idea if you have several inputs and several outputs and you don’t know the total number of trades in advance, also and you to reset them?

    example with 3 entries and 2 exits?

    I have to program something simple and put the code here

    #213313 quote
    JS
    Participant
    Senior
    Hi,

    With multiple contracts you can use “CountOfPosition” to find out the total amount of contracts…

    The average position price can be found with “PositionPrice”…

    You can continue to follow the entry/exit price of the individual contracts with “TradePrice”…

    #213452 quote
    ZeroCafeine
    Participant
    Senior
    now I’m using this :
    MyFirstBuying = OnMarket AND Not OnMarket[1]
    IF MyFirstBuying Then
    myFirstEntryPrice = TradePrice
    MyFirstBuyingTradeIndex = TRADEINDEX
    ENDIF
    
    MyLastBuying = ABS(CountOfPosition) > ABS(CountOfPosition[1])
    IF MyLastBuying Then
    MyLastBuyingPrice = TradePrice
    MyLastBuyingTradeIndex = TRADEINDEX
    ENDIF
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

TradePrice Entry and Exit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/13/2023
Status: Active
Attachments: No files
Logo Logo
Loading...