How to create a breakout box between 2 hours, Code please?

Forums ProRealTime English forum ProOrder support How to create a breakout box between 2 hours, Code please?

Tagged: 

Viewing 15 posts - 1 through 15 (of 57 total)
  • #71015

    I have searched this site, gone through the replies by Nicolas, watched the video various times, checked youtube comments and sections, but I can’t seem to find the code for the “How to create a breakout box between 2 hours” ?

    I would then apply the code I was trying to develop, into an automated system.

    I was looking at the 5 minute chart, I was trying to build a breakout box for 11pm-6am. It would reset each day, and show high and low between the set times each day, see indicator below that somebody else wrote, but I have amended;

     

    The code would work out the high and low between these times, 11pm-6am, and only trade between 8am and 8pm, it would close all trades at 9pm.

    It would Buy, if the price crosses over the high, by 2 points, or sell, if the price crosses under the low, by 2 points.

    Only 1 buy allowed per day and 1 sell allowed per day.

    Stop loss 15, target 15.

    I have read various topics and codes, it seems fairly straight forward, and is covered in various posts by various people, but not all together, I have tried to piece the codes together, but I can’t seem to make it all work. 🙁

    Any help would be much appreaciated. 🙂

    #71043

    This is basically, an Open Range Break Out strategy, this could be coded as follows:

     

    1 user thanked author for this post.
    #71076

    Nicholas,

    Many thanks for that. 😉

    I knew it was basic for you, just couldn’t write the correct information to tie it all together.

    Thanks again.

    #75269

    Nicholas,

    I have been using the code as above and it’s working well. 😉

    I have been through the pdf’s below, but can’ find what I am looking for.

    I only want, 1 buy allowed per day and 1 sell allowed per day which is working, but is it possible to insert another piece of code, to amend that slightly.

    As this is a breakout code, would it be possible to code in, that if the buy won, (say hit target) that the sell trade can’t happen and the other way, if the sell won, (say hit target) that the buy trade can’t happen.?

    I can’t see anywhere in the guides anything about this, perhaps it’s not possible?

    Thanks in advance. 😉

     

    #75275

    You can try this modified code: (not tested)

     

    1 user thanked author for this post.
    #75281

    not trying to be clever 🙂 but lines 13 and 25 need to be changed to something like below  …

     

     

    1 user thanked author for this post.
    #75293

    Good point GraHal!! You deserve a glass of fresh Wine .. or do you prefer green tea? 😉

    #75300

    Wine after nine, so coffee be fine … to keep my brain going! 🙂

    Any ideas why I get attached message when I  run the code?

    #75302

    Because yl and yh are only calculated one time at 06h10 AM

    To avoid the problem, try to change the code with:

     

    2 users thanked author for this post.
    #75324

    Nicholas and GraHal,

    Many thanks for your quick help. 😉

    I will now try and backtest.

    Thanks again.

    #75840

    Nicholas / GraHal

     

    Many thanks for the previous codes, they are working well, I am just a little lost with a trailing stop loss method. 😉

     

    I have seen a stop loss method, as described below, and wondered if this was possible?

     

    I looked through the https://www.prorealcode.com/blog/learning/kinds-trailing-stop-proorder/ but there are so many, I am confused as to which it could be. L

    Original Target Profit in Pips = 100p
    Projected Risk in Pips = -30p

    In this scenario I would place a Hard Stop Loss @ Entry – 30p

    Once the trade has acquired 50% of my Projected Profit {50p}, I will move my SL to risk 20% of those 50p.
    50 x 20% = 10. Thereby Locking in a 40p Profit.

    And continue to Trail my SL @ Max Trade Profit Pips – (Max Trade Profit Pips x 20%)

    I will continue to do this even through my Original Projected Profit in Pips Target of 100p

    eg.
    Up 50p = Risk 10p Locking in 40p Prft.
    Up 80p = Risk 16p Locking in 64p Prft.
    Up 100p = Risk 20p Locking in 80p Prft.
    Up 135p = Risk 27p Locking in 108p Prft.
    Up 200p = Risk 40p Locking in 160p Prft.

     

    Lastly, if I want to select which days of the week for a back-test, where do I insert the code please?

    Say I would like to exclude Tuesday’s, but when I insert the code below in line 2, it doesn’t work.

     

    DayOfWeek[1] DayOfWeek[3] DayOfWeek[4] DayOfWeek[5]

     

    Monday =1

    Tuesday =2

    Wednesday =3

    Thursday =4

    Friday =5

     

    Many thanks in advance.

    #75848

    As for SL, I think this should work fine (line 20 of the Snippet Library, modified to accomodate both Long & Short trades https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0)

    As for DayOfWeek, lines 17 and 24 at https://www.prorealcode.com/topic/something-is-missing-in-my-friday-sell-off/ will be great of help.

    3 users thanked author for this post.
    #75859

    robertogozzi,

    Many thanks.

    I have inserted the hard stop at: set stop ploss 30 and it works great. 🙂

    I have looked at: (As for DayOfWeek, lines 17 and 24 at https://www.prorealcode.com/topic/something-is-missing-in-my-friday-sell-off/) but not being code minded, i’ll admit to being totally lost and all I get is an error message;

    Syntax error:

    This variable is not used in the code:daysforbiddenentry.

    I tried to insert it here, I would like Tuesdays removed.

    Many thanks in advance

    #75860

    I tried again, incorperating the daysForbiddenEntry into the tcondition, but still I get the error.

     

    #75861

    To write code, please use the <> “insert PRT code” button to make code easier to read and understand. Thank you.

     

Viewing 15 posts - 1 through 15 (of 57 total)

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