Is exit code executed on next bar?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #154552 quote
    theo123
    Participant
    Junior

    Hi, basic question: are exit code executed on the next bar?  it seems yes when using probactest.

    If yes, how can I make it exit right away when the price hits that exitprice

    If LongOnMarket AND LongExit THEN
    SELL AT MARKET
    ENDIF

    thanks for anyone that can advice.

    #154579 quote
    Vonasi
    Moderator
    Master

    Strategy code is read through at the close of a bar and any orders or market instructions sent through and actioned at the opening of the next bar.

    Use multi time frame in your code or use STOP and LIMIT orders to exit at a price.

    STOP (pending)

    LIMIT

    #154697 quote
    theo123
    Participant
    Junior

    Thanks Vonasi, so it will be happen on the next bar unless it is a stop.  I see 2 option based on your reply:

    1. Add a stop:  Can I add the exit/stop as a moving exit (not trailing since i dont want to be limited by the minimum distance required by IG/guaranteed stop)?

    for example: the LongExit is calculated based on an event (EventTrigger).  This normally happens multiple times after I go long, so multiple times the Long Exit will change and it will be near the price.

    EventTrigger = close crosses over donchianMiddle
    DCDatEVENT = DonchianDown
    
    if EventTrigger then
    LongExit=DCDatEVENT
    mybarindex=BARINDEX
    endif

    2. can you elaborate on the mulitframe. thanks.

    #154709 quote
    Vonasi
    Moderator
    Master

    SET orders are placed on the market at the open of a candle and remain there until cancelled or their distance is changed by another SET order or until they are hit by price.

    Pending STOP and LIMIT orders have to be placed at the close of every bar (and are applied at the open of the next bar) because they last for one bar only.

    Multi time frame allows you to make decisions on say a 1 hour time frame but then control the trade on say a 1 minute time frame so you can adjust your orders regularly at the close of every minute throughout the hour candle. Using MTF does however limit the data available to back test on as faster time frames cover a shorter period for the same number of bars.

    Plenty more elaboration on MTF in the sticky topic about it:

    Multi timeframe – MTF indicators for ProRealTime

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

Is exit code executed on next bar?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
theo123 @theo123 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/20/2020
Status: Active
Attachments: No files
Logo Logo
Loading...