Announcement

Collapse
No announcement yet.

Exchange time on tick chart

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

  • Exchange time on tick chart

    Could anyone suggest a way of marking the FX exchange start time on tick, volume, or period charts based on the following script for minute charts?

    Many thanks!

    PHP Code:
    /**Foreign Exchange Market - Start Time**/
    var fpArray = new Array(); 
    var 
    0;
    /*                                                                          */
    function preMain(){
        
    setPriceStudy(true);
        
    setStudyTitle("fxMarket Marker");
        
    setShowCursorLabel(false);
        
    setShowTitleParameters(false);
        
    setComputeOnClose();
    /*                                                                          */
        
    fpArray[x] = new FunctionParameter("FX1"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("FX1");
        
    setDefault(1500);
        } 
        
    fpArray[x] = new FunctionParameter("FX2"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("FX2");
        
    setDefault(1700);
        } 
        
    fpArray[x] = new FunctionParameter("FX3"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("FX3");
        
    setDefault(2200);
        } 
        
    fpArray[x] = new FunctionParameter("FX4"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("FX4");
        
    setDefault(000);
        }  
        
    fpArray[x] = new FunctionParameter("FX5"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("FX5");
        
    setDefault(100);
        } 
        
    fpArray[x] = new FunctionParameter("FX6"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("FX6");
        
    setDefault(500);
        }
        
    fpArray[x] = new FunctionParameter("LC"FunctionParameter.COLOR);
        
    with(fpArray[x]){ 
        
    setName("Line Color");
        
    setDefault(Color.brown);
        } 
        
    fpArray[x] = new FunctionParameter("BT"FunctionParameter.NUMBER);
        
    with(fpArray[x]){ 
        
    setName("Bar Thickness");
        
    setDefault(1);
        }
    }
    /*                                                                          */
    function main(FX1,FX2,FX3,FX4,FX5,FX6,LC,BT){
        if ((
    getHour()*100)+getMinute()==FX1){
        
    drawLineRelative(0,0,0,9999,PS_DOTBTLC"SYD"); 
        
    drawTextRelative(-2,0,"SYD",LC,null,Text.RELATIVETOBOTTOM,"Arial",9,"SYD"); 
        }
        if ((
    getHour()*100)+getMinute()==FX2){
        
    drawLineRelative(0,0,0,9999,PS_DOTBTLC"TOK");
        
    drawTextRelative(-2,0,"TOK",LC,null,Text.RELATIVETOBOTTOM,"Arial",9,"TOK"); 
        }
        if ((
    getHour()*100)+getMinute()==FX3){
        
    drawLineRelative(0,0,0,9999,PS_DOTBTLC"MSK");
        
    drawTextRelative(-2,0,"MSK",LC,null,Text.RELATIVETOBOTTOM,"Arial",9,"MSK"); 
        }    
        if ((
    getHour()*100)+getMinute()==FX4){
        
    drawLineRelative(0,0,0,9999,PS_DOTBTLC"PAR");
        
    drawTextRelative(-2,0,"PAR",LC,null,Text.RELATIVETOBOTTOM,"Arial",9,"PAR"); 
        }
        if ((
    getHour()*100)+getMinute()==FX5){
        
    drawLineRelative(0,0,0,9999,PS_DOTBTLC"LND");
        
    drawTextRelative(-2,0,"LND",LC,null,Text.RELATIVETOBOTTOM,"Arial",9,"LND"); 
        }
        if ((
    getHour()*100)+getMinute()==FX6){
        
    drawLineRelative(0,0,0,9999,PS_DOTBTLC"NYC");
        
    drawTextRelative(-2,0,"NYC",LC,null,Text.RELATIVETOBOTTOM,"Arial",9,"NYC"); 
        }
    /*                                                                          */    
    return null;

    --FOREX--

  • #2
    RuGO
    If in your conditions you are just using hours and not minutes then a simple solution is to change them as follows
    if (getHour(0)==FX? && getHour(0)!=getHour(-1)){
    and replace the values in the FunctionParameters with just the hour value (ie 22 in place of 2200)
    Alex

    Comment


    • #3
      That did the trick... many thanks Alexis!

      Guess VIP stands for Vewy Ingenious Pwogwamming!?
      --FOREX--

      Comment


      • #4
        RuGO
        You are most welcome
        Alex

        Comment


        • #5
          Alex, one more question on this... could you suggest a way to draw the FX?? line in a different color at a specific point in time after the exchange opens (ie. if TOK time is FX2 + 7 Hours, change the original "LC" to yellow)?

          TIA!!!
          --FOREX--

          Comment


          • #6
            RuGO
            One way you can do this is by determining (and storing as a global variable) the bar count of the bar in which the FX?? line is originally drawn. To do this you would use the getCurrentBarCount() function.
            Then when your time condition is met you would determine the bar index of that bar (relative to the current bar) by subtracting the current bar count from the stored bar count [this will be a negative number] and redraw the line at that bar index in a different color
            Alex

            Comment

            Working...
            X