Announcement

Collapse
No announcement yet.

High/Low from Buy/Sell

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

  • High/Low from Buy/Sell

    Hello Y'all,

    I have ran into a stumbling block attempting to calculate the most recent high/low from my most recent buy/sell signal. It is similar to a Real Time Swing, except I want to use my last buy/sell signal as my point of determination as opposed to "number of bars". Any suggestions? Thank you in advance

    PB

  • #2
    High/Low from Buy/Sell

    Hello,

    I am having difficulty calculating the most recent high/low from my most recent buy/sell signal. It is similar to a Real Time Swing, except I want to use my last buy/sell signal as my point of determination as opposed to "number of bars". Any suggestions? Thank you in advance

    PB

    Comment


    • #3
      Hello PB,

      Try adding a couple global variables, nSignalHigh and nSignalLow. Within your buy and sell conditions set them equal to high(0) or low(0), respectively. You will then be able to reference the nSignalHigh and nSignalLow variables on subsequent bars as needed.
      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment


      • #4
        Thank you Jason for the feedback. I will implement these changes and let you know the results.

        Regards,
        PB

        Originally posted by JasonK
        Hello PB,

        Try adding a couple global variables, nSignalHigh and nSignalLow. Within your buy and sell conditions set them equal to high(0) or low(0), respectively. You will then be able to reference the nSignalHigh and nSignalLow variables on subsequent bars as needed.

        Comment


        • #5
          Thank you Jason for the feedback. Should I set nSignalHigh equal to "high" and nSignalLow equal to "low"? Thx again

          Regards,
          PB

          Originally posted by JasonK
          Hello PB,

          Try adding a couple global variables, nSignalHigh and nSignalLow. Within your buy and sell conditions set them equal to high(0) or low(0), respectively. You will then be able to reference the nSignalHigh and nSignalLow variables on subsequent bars as needed.

          Comment


          • #6
            Hello PB,

            As I mentioned in my previous reply, set them equal to high(0) and low(0).

            nSignalHigh = high(0);

            or

            nSignalLow = low(0);
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Re: High/Low

              Hello Jason,

              I have implemented your recommended changes and have one the following question: How do I effectively identify and reference my current position bar mark (whether long/short) so that the (high/low) is determined from that bar marker?

              Thank you in advance for your assistance.

              Peter

              Originally posted by JasonK
              Hello PB,

              As I mentioned in my previous reply, set them equal to high(0) and low(0).

              nSignalHigh = high(0);

              or

              nSignalLow = low(0);

              Comment


              • #8
                Re: Re: High/Low

                Hello Peter,

                Originally posted by pbeno
                Hello Jason,

                I have implemented your recommended changes and have one the following question: How do I effectively identify and reference my current position bar mark (whether long/short) so that the (high/low) is determined from that bar marker?

                Thank you in advance for your assistance.

                Peter
                To track your long/short state you could create another global variable, call myPosition. At the same time that you record the high(0) or low(0) set myPosition to "long" or "short," respectively. You could use strings or numbers, such as 1 for long, 0 for no position and -1 for short.

                PHP Code:
                var myPosition 0;  // global declaration

                function main() {

                ...

                    if (
                myPosition != &&  /* your long conditions */ == true) {
                        
                nSignalHigh high(0);
                        
                myPosition 1;
                        
                        
                // or 
                        // myPosition = "long";
                    
                }

                ....


                You don't need to keep track of the bar index where a trade condition occurs, if that's what you meant by bar marker. Just track your position state with the global variable and add that global variable to your conditional statements to prevent long signals from executing if you're position is already long. Likewise for short conditions.
                Jason K.
                Project Manager
                eSignal - an Interactive Data company

                EFS KnowledgeBase
                JavaScript for EFS Video Series
                EFS Beginner Tutorial Series
                EFS Glossary
                Custom EFS Development Policy

                New User Orientation

                Comment


                • #9
                  Hello Jason,

                  Thank you for the reply. Unfortunately, declaring "my position" is not my trouble area. I am challenged by the fact my Buy/Sell signals are determined by the percent change of "today's close" with respect to most recent high/low since my most recent position. For example, if "today's close" is >=1.0% of the most recent high then a buy is triggered. The problem is determining the most recent high/low with respect to my position. Here is a portion of my logic for your review. I use "high(-5)" b/c I have not determined how to accurately calculate the most recent high/low since "my position".

                  nsignalhigh =high(-5);
                  nsignallow = low(-5)
                  nsignalclose=close(0);
                  nmaxpercent =.01;

                  FullBuy2=((nsignalclose-nsignalhigh)/nsignalhigh) >= maxpercent;
                  FullSell2=((nsignalclose-nsignallow)/nsignallow) <= -nmaxpercent;

                  Thank you again,
                  Peter

                  Comment


                  • #10
                    Re: Re: Re: High/Low

                    Hello Jason,

                    I forgot to include this in my last email. The following is the logic used in MetaStock to perform what I am attempting to do in ESignal. In MetaStock they simply have trough/peak funciton to find high/low since "myposition". Hopefully this helps.

                    Signal Formula
                    target:=1.000; pt:=Trough(1,Security(".GDAXI",c),target); time:=TroughBars(1,Security(".GDAXI",c),target); signal:=Cross(((Security(".GDAXI",c)-pt)/pt)*100,target); signal AND (Ref(BarsSince(signal),-1)>=time)


                    Originally posted by JasonK
                    Hello Peter,



                    To track your long/short state you could create another global variable, call myPosition. At the same time that you record the high(0) or low(0) set myPosition to "long" or "short," respectively. You could use strings or numbers, such as 1 for long, 0 for no position and -1 for short.

                    PHP Code:
                    var myPosition 0;  // global declaration

                    function main() {

                    ...

                        if (
                    myPosition != &&  /* your long conditions */ == true) {
                            
                    nSignalHigh high(0);
                            
                    myPosition 1;
                            
                            
                    // or 
                            // myPosition = "long";
                        
                    }

                    ....


                    You don't need to keep track of the bar index where a trade condition occurs, if that's what you meant by bar marker. Just track your position state with the global variable and add that global variable to your conditional statements to prevent long signals from executing if you're position is already long. Likewise for short conditions.

                    Comment


                    • #11
                      Re: Re: Re: Re: High/Low

                      Hello Peter,

                      Originally posted by pbeno
                      Hello Jason,

                      I forgot to include this in my last email. The following is the logic used in MetaStock to perform what I am attempting to do in ESignal. In MetaStock they simply have trough/peak funciton to find high/low since "myposition". Hopefully this helps.

                      Signal Formula
                      target:=1.000; pt:=Trough(1,Security(".GDAXI",c),target); time:=TroughBars(1,Security(".GDAXI",c),target); signal:=Cross(((Security(".GDAXI",c)-pt)/pt)*100,target); signal AND (Ref(BarsSince(signal),-1)>=time)
                      The formula code you've posted does not directly translate into EFS code. Some of the functions used are unique to MetaStock. You may want to try contacting some of our EFS Consultants to see if they can assist you with this formula conversion project.
                      Jason K.
                      Project Manager
                      eSignal - an Interactive Data company

                      EFS KnowledgeBase
                      JavaScript for EFS Video Series
                      EFS Beginner Tutorial Series
                      EFS Glossary
                      Custom EFS Development Policy

                      New User Orientation

                      Comment

                      Working...
                      X