Announcement

Collapse
No announcement yet.

Monthly Open Range to EFS - pls help!!

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

  • Monthly Open Range to EFS - pls help!!

    This is probably quite simple for those gifted with ability to code. But I am struggling and would much appreciate anyone's help

    Goal: Build EFS code to automatically use first daily bar of each month to create opening range for that month, then for each following month renew

    Steps:

    take high of first trading day of month and draw horizontal line from this first day of month high and project line out to last day of month....repeat afresh for each month or show historically when scroll back
    take low of first trading day of month and draw horizontal line from this first day of month low and project line out to last day of month....repeat afresh for each month or show historically when scroll back

    issues..... apart from fact my programming skills are minimal I am struggling with

    1. How to specify first trading day of month in EFS?
    2. How to draw line to last day of month, i.e project forward in EFS

    If anyone can help me write this code I would be incredibly grateful

    regards

    Bryan

  • #2
    Bryan
    To answer your questions
    1. Depending on what your needs are you can accomplish that with something as simple as a conditional statement that checks if the current bar's month value is different than that of the previous bar's month value eg
    if(month(0)!=month(-1))
    in which case you retrieve and save to two global variables the High and Low values of the bar that meets the conditional statement.
    2. I would suggest against drawing lines [at least initially] as it can complicate matters. Instead return to the chart the daily High and Low values that you save when the above conditional statement is true (which occurs on the first bar of a month). The plotted values will continue unchanged throughout the entire month - since you have stored those values and the conditional statement will no longer be true - and end when the new month starts - which is when new values are stored because the condition is true again
    Alex


    Originally posted by bryan1810 View Post
    This is probably quite simple for those gifted with ability to code. But I am struggling and would much appreciate anyone's help

    Goal: Build EFS code to automatically use first daily bar of each month to create opening range for that month, then for each following month renew

    Steps:

    take high of first trading day of month and draw horizontal line from this first day of month high and project line out to last day of month....repeat afresh for each month or show historically when scroll back
    take low of first trading day of month and draw horizontal line from this first day of month low and project line out to last day of month....repeat afresh for each month or show historically when scroll back

    issues..... apart from fact my programming skills are minimal I am struggling with

    1. How to specify first trading day of month in EFS?
    2. How to draw line to last day of month, i.e project forward in EFS

    If anyone can help me write this code I would be incredibly grateful

    regards

    Bryan

    Comment


    • #3
      ACM - thanks for taking the time to respond, much appreciated. I understand your script for each month but how therefore would you ask for the first day of each month? Thats the bit I am really struggling with. (thanks for explaing no need draw individually, understand now just to make it coniuously and it will automatically truncate itself)

      thanks again
      Last edited by bryan1810; 01-06-2015, 12:37 AM.

      Comment


      • #4
        Bryan

        but how therefore would you ask for the first day of each month?
        As I explained in my prior reply (in which I also provided a basic example of the conditional statement) you can do that with a conditional statement that checks if the current bar’s month value is different from (ie not equal to) the prior bar’s month value in which case you assign to two global variables the bar's High and Low values.
        Each bar has a date and time associated with it (ie year, month, date, etc) and on the first bar of each month its monthly value is going to be different from that of the preceding bar.
        See the following screenshot that illustrates a very basic example of what I explained.



        As you can see I am using that very same conditional statement and painting the background when that statement is true which occurs on each first bar of a month (note for example that the cursor is on 12/1/2014 which is the first day of December). For your purpose you would replace the command to paint the background with the assignments of the High and Low of that bar to two global variables which you then return to the chart through the return statement
        As an aside if - as you indicate – you are unfamiliar with programming in EFS then you may want to review the JavaScript for EFS videos and the Core JavaScript Reference Guide. Those will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with the specifics of EFS.
        Alex


        Originally posted by bryan1810 View Post
        ACM - thanks for taking the time to respond, much appreciated. I understand your script for each month but how therefore would you ask for the first day of each month? Thats the bit I am really struggling with. (thanks for explaing no need draw individually, understand now just to make it coniuously and it will automatically truncate itself)

        thanks again

        Comment

        Working...
        X