Announcement

Collapse
No announcement yet.

First bar of the day breakout

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • First bar of the day breakout

    Is it possible to reference the first bar of the day using Formula Wizard? I want to build a system that goes long if the high of the first 5 minute bar is broken and short if the low of the first 5 minute bar is broken.

    The only way I can see to reference bars at the moment is as an offset of the current bar, which doesn't help me.

  • #2
    onetouch
    You will not be able to do that using the Formula Wizard as it requires creating global variables which the Formula Wizard cannot do. You will need to write it using the Editor (Tools-> EFS-> Editor...).
    If you are using a 5 minute chart then what you are trying to accomplish is relatively easy to do. You need to first create two global variables (ie outside of preMain and main) and set them initially to 0
    PHP Code:
    var first5High 0;
    var 
    first5Low  0
    Then in main you create the condition that will evaluate to true only while the first 5 minute bar is forming and will assign a value to those variables
    PHP Code:
    if(day(0)!=day(-1)){
        
    first5High high(0);
        
    first5Low  low(0);

    Once the first 5 min bar of the day is completed the variables first5High and first5Low will be permanently set to the High and Low of that bar and you can use them to set the conditions of your system
    With regards to writing the system I would suggest you review the BackTesting Tutorials as those will provide you with specific information on the required logic (even if they use other studies as examples)
    If you encounter any problems post your code and someone will be available to assist you in fixing it.
    Alex

    Comment

    Working...
    X