Announcement

Collapse
No announcement yet.

Highs, Lows by a certain amount..

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

  • Highs, Lows by a certain amount..

    I'm new to programming for eSignal (I've used Tradestation for 10 years), and need any ideas on how to program the following indicator. I think that it is probably relatively easy, but I am at a loss. I would like to be notified when the close of a bar (any time frame, intraday, daily, etc.) is either higher or lower than the close of a previous bar by a certain amount of ticks. For instance, I would like to have the indicator mark the bar or give me a notification that the close of a bar is 10 ticks greater than the close of a previous bar. Obviously, I'd like to also know if the close is ten ticks lower then the close of the previous bar. Is there a simple way to program this in eSignal, or am I better off continuing to use the charts of TS2000i, even though I don't like the data issues with that platform. Thanks in advance.

    James Anderson

  • #2
    James
    The enclosed script should do what you want. It will paint the bar background in yellow when the close is higher/lower than the prior close by a user defined value. You can set the tick value and number of ticks in Edit Studies
    Alex

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("sample");
        
    setShowCursorLabel(false);
    }

    function 
    main(tickVal,tickNum) {

        if(
    tickVal==null){
            
    tickVal 0.01;//define the value of a tick
        
    }
        if(
    tickNum==null){
            
    tickNum 10;//define the number of ticks
        
    }
        
    //if close is higher than prior close plus n ticks OR if close is lower than prev close minus n ticks
        
    if(close()>close(-1)+(tickNum*tickVal) || close()<close(-1)-(tickNum*tickVal)){
            
    setBarBgColor(Color.yellow);//paint the background of the bar in yellow
        
    }

        return;

    Comment


    • #3
      Alexis,

      Thanks a lot for your post and help. The script works fine, but I have attempted to alter it to display green bars for up closes, and red bars for down closes. I've attached the code, because it seems to only be working for the up closes. I hate to ask for your help again, but would you look at the code and tell me where I went wrong. Thanks in advance.

      James Anderson
      Attached Files

      Comment


      • #4
        James
        The attached revision of your efs fixes the errors. Comments are in the script
        Alex
        Attached Files

        Comment

        Working...
        X