2 minute time frame in strategy

Forums ProRealTime English forum ProOrder support 2 minute time frame in strategy

Viewing 15 posts - 16 through 30 (of 31 total)
  • #145048

    just a little reminder

    always take standard units where everyone is and have a top down approach

    M2, M3, … never used on my side.

     

    #145050
    nwa

    Cheers for the info. It’s really a technical coding query rather than a strategy / philosophy enquiry but thanks for the input in any case. The code supplied is really just an example.

    #145052

    Can anyone suggest a way of coding the order to remain in place for both of the two 1 minute bars of the two minute bar?

    I (and others?) am confused as the example you show are both on 2mn TF and so there will not be 2 x 1 min bars anyway?

    #145055

    Try this (not tested):

     

    #145056

    This could be a better approach (not tested):

     

    1 user thanked author for this post.
    avatar nwa
    #145063
    nwa

    Hi GraHal,

    The strategy I’m looking to implement involves 2m, 5m and 10m meaning in order to run the code I have to use the 1min chart as the basis to enable it to function. I can’t / don’t run it on the 2m time frame / chart for back testing or demo / live auto trading as it will not execute.

    So if you run the example code I pasted using the 1min chart (as I have to do to enable the strategy code to function) you’ll see what I mean about orders placing on the 1st minute of the two minute bar and then cancelling after the 1st 1 minute bar has closed. I assume this is because the basis is the 1min chart and the ‘Stop’ function only places an order on the 1st bar after the condition is satisfied and cancels thereafter i.e. the first 1 minute bar of the conditions being met. Whereas what I’m looking to achieve is to keep the order live / in place for both of the 1 minute bars making up the 2 minute bar – or until the level is breached at which point entry would be made.

    1 user thanked author for this post.
    #145067

    Thank you @nwa  for your comprehensive explanation … pleasure to read and easy to understand!

    1 user thanked author for this post.
    avatar nwa
    #145076

    I’m intrigued now re the problem and the fix … I have your code running on Forward Test on 1 min TF and I was expecting to see a Pending Order appear and disappear every 1 minute … is that correct?

    If Yes, well I don’t see, I don’t even get  a Pending Order! 🙂

    #145077
    nwa

    Hi Roberto,

    Just running the code on demo briefly, the entry in the code is set to the default (1 minute) time frame and so when the two minute is below the lower bollinger band the system creates orders continually on the basis of the 1 minute bars i.e. it doesn’t respect the two minute time frame with respect to order generation:

    I’ll try your other suggestion next when I get a chance.

     

    #145078
    nwa

    Hi GraHal,

    Running my example code as per below on the 1 minute time frame, see attached screenshots where the order generates in the first minute and disappears in the next:

    Luckily the conditions were met just there when I ran it to give you the perfect example. Are you not seeing behaviour like this?

    #145081
    nwa

    Grahal, Orders only appear once the two minute conditions are met, and then only last for 1 minute as opposed to the full duration of the two minute bar

    1 user thanked author for this post.
    #145084

    I used this code (which is the same as my second one I posted mith the addition of MyHI to make Entry fixed for the 1-minute bars), in addition I added some debugging instructions, Graph & GraphOnPrice, on the 1-min chart:

    I also used this indicator on the 2-min chart to have the signals as a histogram:

    As you can see from pic BB1, the signal (on Dax €5, today at 14:02 Utc +2 is plotted correctly (there was a signal even the previous candle, but the entry price was never reached), the 1-minute bar at 14:03 (the second 1-minute bar only can see the signal, as it’s generated when the 2-minut bar closes, unless there’s a previous adjacent signal) places the pending order, which is immediately executed.

    As you can see from pic BB2, another signal was plotted on the 2-min bar today at 09:18 Utc+2. The second pending order was placed at 09:20 (the first 1-minute bar AFTER the 2-min bar) and it entered at 09:21.

    Being based on signals showing on the 2-min TF, the pending orders on the 1-min bar can be placed:

    • on the second (or last) 1-min bar of the 2-min bar, since signals are only updated when the 2-minute bar closes
    • on the first 1-min bar of the 2-min bar AFTER the 2-min bar that originated the signal, for the opposite reason, since the signals show on the last 1-min bar of the 2-min bar, the first 1-min bar of each 2-min bar still has the PREVIOUS 2-min bar VALID.

    If you remove UPDATEONCLOSE, you can see the difference.

    If there’s still something incorrectct, please:

    • post the code you used
    • post the name of the instrumend traded
    • post the date and hour of both the 2-min and 1-min candles involved

    so that we can replicate any issue.

     

     

     

    #145406
    nwa

    Hi Roberto,

    “Being based on signals showing on the 2-min TF, the pending orders on the 1-min bar can be placed: on the second (or last) 1-min bar of the 2-min bar, since signals are only updated when the 2-minute bar close” or “on the first 1-min bar of the 2-min bar AFTER the 2-min bar that originated the signal, for the opposite reason, since the signals show on the last 1-min bar of the 2-min bar, the first 1-min bar of each 2-min bar still has the PREVIOUS 2-min bar VALID.”

    If I understand correctly from what you’ve said above, then a pending order can only be placed on the close of the last minute of the two minute bar since this is when ‘updateonclose’ executes? Am I correct in my interpretation?

    I ran you code as per below on demo (which I modified the bollinger band length from 20 to 2 purely to generate more frequent orders for observation) on EURUSD around 15:00 UTC + 0 :

    I observed in picture 1 attached a pending order placed on the open of the second 1 minute bar @ 14:57 on the two minute candle. I don’t understand why this order placed assuming my statement on ‘updateonclose’ as per above being a requirement for order placement.

     

    FYI the indicator BBlow shown in the pictures attached is:

     

    I observed in picture 2 attached a pending order being placed at 15:14  on the close of 15:12 on the two minute chart despite no bollinger touch on close the 15:12 candle (BBlow indicator = 0).

    So I’m not observing the behaviour I’d be expecting to see with my current understanding of the code.

    I tried removing ‘updateonclose’ for observation and if I remember correctly saw orders placed on the close of each 1 minute bar when the BBlow indicator was returning 1.

    So still a bit confused on my end..

    #145412

    On the second minute of the bar which shows the signal + the first minute of the next bar.

    20 is the correct periods for the BB.

    #145418
    nwa

    20 is the correct periods for the BB.

    I modified the bollinger band length from 20 to 2 purely to generate more frequent orders for observation

     

    On the second minute of the bar which shows the signal

    The 2min bar which shows the signal must be closed to generate the signal no? So how can it generate an order before generates a signal?

    the first minute of the next bar.

    For clarity do you mean on the open or close of the first minute of the next bar after the signal?

     

     

Viewing 15 posts - 16 through 30 (of 31 total)

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