user interface - Highest high and lowest low between a time frame and drawing a rectangle for visual for an X amount of days -


my objective create rectangle object on chart measures highest high , lowest low between specified time frame , x amount of days?

a sample screenview

i know how create object chart i'm not sure how can make repeat x amount of days back. how can achieve this? thinking maybe loop approach?i use guidance.

try code (expert advisor). ok, not efficient (as recalculate every tick), demonstrates concept pretty well. enter image description here

and here's code it:

//+------------------------------------------------------------------+ //|                                            geraldhighlowv0r1.mq4 | //|               copyright 2015, joseph.lee @ fs [dot] com [dot] | //|                                            http://www.fs.com.my/ | //+------------------------------------------------------------------+ #property copyright "copyright 2015, joseph.lee @ fs [dot] com [dot] my" #property link      "http://www.fs.com.my/" #property version   "1.00" #property strict  extern int      vitimeofdaystarthour    =  3; extern int      vitimeofdayendhour      =  9; extern int      vidaystodraw            = 10;   void ontick() {     string      vsglobaldebug           = "";     datetime    vdcurrentdaystart       = itime(symbol(), period_d1, 0);    //get broker today datetime of midnight      objectsdeleteall();     //---------------------------------------------------------------     //process [vidaystodraw] number of days (**sat/sun included)     //---------------------------------------------------------------     for(int viday=0; viday<vidaystodraw; viday++) {         datetime vddateofsection        = vdcurrentdaystart-(viday*period_d1*60);                       //get section midnight datetime         datetime    vdsectionstart      = vddateofsection + (vitimeofdaystarthour*period_h1*60);        //add hours mark start of section         datetime    vdsectionend        = vddateofsection + (vitimeofdayendhour  *period_h1*60);        //add hours mark end of section          //----------------------------------------------------------------------         //calculate number of bars between (inclusive) start , end time         //----------------------------------------------------------------------         int     visectionendbarindex         = ibarshift(symbol(), period_current, vdsectionend,false);         int     visectionstartbarindex       = ibarshift(symbol(), period_current, vdsectionstart,false);         int     vibarcountbtwstartandendhour = visectionstartbarindex-visectionendbarindex+1;         //-----------------------------------------------------------------          //-----------------------------------------------------------------         //find highest/lowest bar index within day section         //-----------------------------------------------------------------         int     visectionhighestbar     = ihighest(symbol(), period_current, mode_high, vibarcountbtwstartandendhour, visectionendbarindex);         int     visectionlowestbar      = ilowest(symbol(), period_current, mode_low, vibarcountbtwstartandendhour, visectionendbarindex);         //-----------------------------------------------------------------          //-----------------------------------------------------------------         //find highest/lowest price within day section         //-----------------------------------------------------------------         double  visectionhighestprice   = ihigh(symbol(), period_current, visectionhighestbar);         double  visectionlowestprice    = ilow( symbol(), period_current, visectionlowestbar);         //-----------------------------------------------------------------          //-----------------------------------------------------------------         //add verbose/debug info display         //-----------------------------------------------------------------         stringadd(             vsglobaldebug, "\n[day" + integertostring(viday) + "]: "                 + "start: "     + timetostring(vdsectionstart)                 + ", lowest: "  + doubletostring(visectionlowestprice,digits)                 + ", end: "     + timetostring(vdsectionend)                 + ", highest: " + doubletostring(visectionhighestprice,digits));         //-----------------------------------------------------------------          //-----------------------------------------------------------------         //crete rectangle object day section         //-----------------------------------------------------------------         string  vsobjname   = "hlday" + integertostring(viday);         objectcreate(0, vsobjname, obj_rectangle, 0, vdsectionstart, visectionlowestprice, vdsectionend, visectionhighestprice);         objectsetinteger(0, vsobjname, objprop_color, clrdarkgreen);         objectsetinteger(0, vsobjname, objprop_width, 0);         objectsetinteger(0, vsobjname, objprop_back, true);         objectsetinteger(0, vsobjname, objprop_selectable, false);         //-----------------------------------------------------------------     }     chartredraw();      //-----------------------------------------------------------------     // show debug/verbose info     //-----------------------------------------------------------------     comment("\n" + vsglobaldebug ); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -