2 bars late on entry and exit

Forums ProRealTime English forum ProOrder support 2 bars late on entry and exit

Viewing 6 posts - 1 through 6 (of 6 total)
  • #239391

    if i back test this simple code, entry and exit are 2 bars late. i want position to open or close on OPEN as the conditions are met.

    new to this! any advice much appreciated

     

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Conditions to enter long positions
    indicator1 = MACD[12,26,9](Open )
    c1 = (indicator1 >= 0)

    IF c1 THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF

    // Conditions to exit long positions
    indicator2 = MACD[12,26,9](Open )
    c2 = (indicator2 < 0)

    IF c2 THEN
    SELL AT MARKET
    ENDIF

    #239394

    Code is read at the end of each bar and positions are opened or closed at the Open of the next bar … which is only a few miliiseconds after close of previous bar.

    Hope above helps, if not just say.

    #239395

    thank you for feed back.

    if i replace with close, is still 1 bar late.

    i would like to enter position on market open.

    i attach screen shot of graph showing that MACD histogram positive on oct 1 but position doesnt open till nov 1.

     

    how do i trigger open on oct 1 when macd is positive?

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Conditions to enter long positions
    indicator1 = MACD[12,26,9](close)
    c1 = (indicator1 >= 0)

    IF c1 THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF

    // Conditions to exit long positions
    indicator2 = MACD[12,26,9](close)
    c2 = (indicator2 < 0)

    IF c2 THEN
    SELL AT MARKET
    ENDIF

     

    #239397

    If this is a monthly time frame, then the “close” of a monthly bar is at the end of the month…

    #239398

    how do i trigger open on oct 1 when macd is positive?

    Use multi-Timeframe.

    For example, conditions could be satisfied on a monthly timeframe, but the trade could be opened on a 1 minute timeframe … so 1 minute into the October bar or said another way … 1 minute after the end of the September bar.

    https://www.prorealcode.com/topic/multi-timeframe-mtf-indicators-for-prorealtime/

     

    1 user thanked author for this post.
    #239399

    thank you!  i get it now!

     

    1 user thanked author for this post.
Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login