How do I calculate ROI% based on a combination of EOD and intraday time frames?

Forums ProRealTime English forum ProScreener support How do I calculate ROI% based on a combination of EOD and intraday time frames?

Viewing 4 posts - 1 through 4 (of 4 total)
  • #218696

    Hi Everyone!

    How do I create a code that will calculate a ROI% in the following scenario:

    I have a criterion on the end of day close on the daily chart 956 days ago that is triggered. I want to calculate a ROI% that is based on an order for tomorrow (955 days ago) which is equal to one cent above the close today (956), but I want to exit the trade 150 minutes after the market opens. Also, if the trade is not filled within the first 30 minutes of the day, I want to cancel the order.

    Example:

    Trade criteria on the close of today (956 days ago) is met.

    XYZ stock closes 956 days ago at 59.06.

    Order for 955 days ago (which is the next day) is a limit order at 59.07.

    If the order would be filled in the first 30 minutes of the day, I want to exit the trade at 150 minutes from the open time of the day (955) and have the screener calculate a column that shows what the ROI% would be at the 150 minutes mark.

    If the order would not be filled during the first 30 minutes of the day, I want the screener to return 0.

    I have figured out how to get this ROI% with only end of day data, but I can’t figure out how to get it to do what I describe above for the intraday time frames indicated. (If there is no way to calculate it for the 150 minutes timeframe, I will use the 2 hour timeframe instead.)

    Here is the code I currently am using to calculate for end of day data:

     

    N = 956

    Combo = Close[N] > 5 and Volume[N] > 500000

     

    OpenBelow99 = (Open / (Close[1]+.01)) < 1

    LowVsYstCLBelow99AndOpenAbove99 = (Low / (Close[1]+.01)) <= 1

    LowVsYstCLAbove99 = (Low / (Close[1]+.01)) > 1

     

    IF LowVsYstCLBelow99AndOpenAbove99 THEN

    LowVsYstCL = ((Close / (Close[1]+.01))-1)*100

    ENDIF

    IF OpenBelow99 THEN

    LowVsYstCL = ((Close – Open) / Open)*100

    ENDIF

    IF LowVsYstCLAbove99 THEN

    LowVsYstCL = 0

    ENDIF

     

    criteria11 = LowVsYstCL[N-1]

    SCREENER [combo] (criteria11 AS “ROI %”)

     

    What is the code to accomplish what I am looking for?

    Thank you!

    #218705

    I figured out the following code, and it works perfectly… but only going back until you have a holiday that only trades til noon, then the calculations become inaccurate. Is there anyway to fix this?

     

    #218717

    With IG there’s a 256-bar limit, you cannot exceed that lookback period.

    With PRT Premium that limit is 1024 bars.

    This could be the source of the reported inaccuracy.

     

    1 user thanked author for this post.
    #218755

    Thank you, Roberto!

    I have PRT Premium.

    The problem currently is occurring only 24 daily bars looking back (which is 96 2-hours bars looking back.) The problem is due to the early close for July 4th. I figured out the work around:

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

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