Close operation and open a new operation.

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #165975 quote
    Link
    Participant
    Senior

    I am in the market with an operation for several days.

    I see that these days the conditions have been given several times to re-enter the market.

    What I want is that if I am in the market and the conditions to enter are met, the operation is closed and a new operation is opened.

    Thanks.

    #165982 quote
    robertogozzi
    Moderator
    Master

    It makes no sense, as the reopening price will be the closing price of the old trade and there are no advantages.

    Even overnight fees won’t change.

    You can easily  do this by exiting and reopening after 30 bars have elapsed:

    IF MyLongConditions AND LongOnMarket AND ((BarIndex - TradeIndex) >= 30) THEN
       SELL AT Market
       BUY  AT Market
    ENDIF
    #165990 quote
    nonetheless
    Participant
    Master

    or you could try “cumulative orders = true” to add to your position each time conditions are met

    #165991 quote
    Link
    Participant
    Senior

    Please, no cumulative órders.

     

    If onmarket aNd conditions then

    Sell at market

    Exitshort at market

    #166043 quote
    XORANDNOT
    Participant
    Senior

    It makes no sense, as the reopening price will be the closing price of the old trade and there are no advantages.

    Even overnight fees won’t change.

    You can easily do this by exiting and reopening after 30 bars have elapsed:

    When you code “sell at market” and “buy at market” in the same bar, ProRealtime won’t do anything. At least not in a backtest, and I think neither in reality with IG. It will just leave the old position open, because in effect, nothing changes. No orders will be executed.

    I think what was implied in the original question is : How do you get a new entry price for an old position on whose basis exits (trailing stops, target profits, and so on) are being calculated. Instead of taking “positionprice” for that purpose, you can remember the closing price of a certain bar as “newpositionprice” and do all exit calculations with this one from then on.

    #166053 quote
    Link
    Participant
    Senior

    The position should be Closed, and start a new operation.

    #166055 quote
    XORANDNOT
    Participant
    Senior

    This will make the broker happy by paying more fees.

    #166062 quote
    Vonasi
    Moderator
    Master

    What is the point of closing a position and immediately opening a new one? You will just have to pay the spread to the broker each time just to be in exactly the same position as you were (except now holding at a worse price than you were before). This is why if a buy order and a sell order are sent to the broker at the same time by a strategy they just cancel each other out.

    #166064 quote
    Monochrome
    Participant
    Senior

    Maybe he wishes to lock in profit and start a new trade with a fresh stoploss.

    #166065 quote
    XORANDNOT
    Participant
    Senior

    Sounds like a rather expensive type of trailing stop.

    #166068 quote
    Paul
    Participant
    Master

    Close and reentry in same direction in the same bar can happen with cumulated orders and maintaining 1 position-size I believe.

    Some code will run into a problem, because i.e. a trailingstop won’t reset unless it’s modified for this specific issue. I use it with these adjustments for backtesting only.

    #166071 quote
    XORANDNOT
    Participant
    Senior

    I just re-checked on demo today : When you close a position and re-open it again in the same bar, nothing happens. No orders are executed, and the old position is kept open with all stops and limits as they were before.

    #166078 quote
    Vonasi
    Moderator
    Master

    When you close a position and re-open it again in the same bar, nothing happens.

    Yes – each order cancels out the other.

    #166079 quote
    Vonasi
    Moderator
    Master

    Maybe he wishes to lock in profit and start a new trade with a fresh stoploss.

    Then just move the stop loss – it achieves exactly the same thing but without paying the spread.

    #166131 quote
    Monochrome
    Participant
    Senior

    ‘set stoploss’ can’t be moved right? You’d have to code in a separate exit which only activates on bar close.

    I mean I personally wouldn’t do that but I can see reasons for it

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

Close operation and open a new operation.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Link @tony-manero Participant
Summary

This topic contains 20 replies,
has 7 voices, and was last updated by Monochrome
4 years, 10 months ago.

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