Announcement

Collapse
No announcement yet.

Stop'd in entries

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

  • Stop'd in entries

    I am attempting to set my stop level, which I want to calculate at the end of each intraday bar, to be the level at which I enter the trade (either long or short) should this level be breached.

    At this point I am certain that my end-of-bar calculations are correct however I am not certain that when I backtest the strategy it is not performing a continuos calculation of the desired ("end of bar") level. Would this be cleared up by the calculation being set to compute on close? This may be why I am not seeing any trades. (where would I place setComputeOnClose? -- should I assign these entry and exit levels, ie.stop entries, to a variable? not sure how to proceed...)

    If that is not the case then something is wrong with my code's logic. I want to compute the stop for the next bar on the close of this bar. I want to enter a trade on this next bar if the level calculated from the last bar is breached. This level would remain set until it is recalculated on the close of the next bar. I have experimented with different offsets but I am still not seeing any trades.

    Here is the code I am using to enter a long trade. I want to enter a long trade if it reaches the long stop level which was calc'd on the close of the prior bar:

    if(high(1)>= LE && !Strategy.isLong())
    Strategy.doLong("LE",Strategy.STOP,Strategy.NEXTBA R);


    thank you,


    sidenote:
    ?Is the +1 relative offset a postdictive backtesting error?

  • #2
    c_13

    ?Is the +1 relative offset a postdictive backtesting error?

    If I understand the question correctly then yes it is. While it will work in backtesting in the sense that the price of the next bar is known it will not in real time.
    That aside in your Strategy.doLong() you are missing the entry price for the STOP strategy.

    Alex

    Comment


    • #3
      Alexis, the LE is the stop level which is being calculated in my EFS prior to this entry code.

      Comment


      • #4
        c_13
        I understand that but that is not defined in the command itself.
        The "LE" contained in the command is just the text for that type of trade.
        Alex

        Comment


        • #5
          so how do I call this variable to act as the stop level?

          In my function main:

          var LE = 0;

          (...calc for LE stop...)


          if(high(1)>= LE && !Strategy.isLong())
          Strategy.doLong("LE",Strategy.STOP,Strategy.NEXTBA R);

          thanks,

          Comment


          • #6
            c_13
            It would be something like this
            Strategy.doLong("LE", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, LE);
            For more detailed information you may want to view the Guide to Developing EFS Strategies which is in the EFS Help Center & Library
            Alex

            Comment


            • #7
              I changed the offset (to something realistic) and ran the backtest but I don't get any trades. Perhaps I need to setComputOnClose here? Let me know what you think. (Perhaps I didn't apply it correctly in the preMain but setComputeOnClose(true) didn't seem to help).

              if(high()>= LE && !Strategy.isLong())
              Strategy.doLong("LE",Strategy.LIMIT,Strategy.THISB AR,Strategy.DEFAULT,LE);


              I actually want to proactively place these calculated stop levels in the broker's cue so that if the level is breached it will automatically be filled (theoretically).
              Last edited by c_13; 02-25-2004, 08:06 AM.

              Comment


              • #8
                c_13,

                Alex has identified almost all the technical and soft issues already. You are very close, here is what I would recommend. You have to be very careful with the stop limit entry and having thought about it, you will have to do some testing to ensure you can implement with the eSignal strategies.

                Remember that the stop strategy will enter the trade only if the price drops below the specified price, the bar that you specified. For that reason, I would specify the current bar for entry. (if the price is above your stop entry point, it will not enter the trade).The same with strategy.limit, the trade will only be entered if the price is below the limit price. You may also want to put a conditional after the entry statement that if it was not entered and it should have, that you will enter on a market order.

                If you would like, send me your code and I’ll review for you and insert some debugging steps in there to assist.


                Regards,

                Comment


                • #9
                  better yet, post the code, that will really get the ball rolling.

                  Comment


                  • #10
                    thanks Steve,
                    I am considering your words and am really trying to understand this. I'm uncertain if this can even be executed. Perhaps a generic condition that says: "if currenct bar > 1 then doLong at stop" would get the script to generate the stop level. Perhaps: if(high()>=1 then execute stop generation/placement strategy.

                    I don't want to code a stop limit but rather I want eSignal calculate and hold the stop level until a new calculation for the next bar is made. I am using if(high() >= LE && !Strategy.isLong()) but what I really want to do is to have these stops already in the marketplace; even a stop market order would be better than no trades. I don't want EFS to wait until the stop level is breached before it executes the command.


                    My inexperience with EFS is prohibiting my understanding. [translation = will probably post code shortly]


                    c_13
                    Last edited by c_13; 02-25-2004, 02:05 PM.

                    Comment


                    • #11
                      Regarding placing the stop level and/or the limit entry levels and "have them in the marketplace", that can be done if you are using traditional stop or limit entry orders, where the stop is the exit and the limit is the entry. However, to do it the way you want, you will have to take more manual control. There are a number of ways it can be done and I am sure we will be able to figure out, with the assistance of this forum, something that will work for you

                      Regards,

                      Comment


                      • #12
                        c_13,

                        for some reason I could not find where you had posted your code, so I will go ahead and post the markup here. What I did is integrated a debug tool into the code and printed to a file lots of information showing you what the code is doing. (do not load on a chart which is over a thousand bars long, the text file will get very large (about 1 K per bar).

                        I also stuck in several steps to test for getBarState() being equal to BARSTATE_NEWBAR. Everything encompassed by this conditional will only be executed every bar as the chart is being loaded and every time a new bar comes in in real time.

                        I also added some global variables above preMain and a function after main to support the debug tool.

                        You can look at the output of the trace() function in the formula output directory in eSignal directory.

                        I would recommend looking at the output using the SciTE text editor (if not highlighted already, specify java as the language). The java highlighting makes the text file much more readable, and the lines wrap, unlike notepad. Here is a link to my fileshare area which has the instructions and the files for the SciTE Text editor.

                        Take a look at the output, you will see there was at least one trade made (at least in my advanced chart). You can comment out the trace() commands as you troubleshoot, or comment them out to concentrate on a certain area. I think you will see why you did not get very many trades once you look.

                        Remember what I said (probably not well), if the price is above your stop entry point, it will (not enter the trade on a long, enter a trade on a short). The same with strategy.limit, the trade will only be entered if the price is below your limit entry point it will (enter the trade on a long, not enter a trade on a short). Since this is kind of a brain twister, what I would do is if yout test is met, just enter a long or short using your logic and strategy.market , this bar and close as an entry point. It is not perfect, but it is pretty close and it will get you past this confusing part of strategy development. You can refine later once you understand it better.

                        Regards,
                        Attached Files
                        Last edited by Guest; 02-25-2004, 03:07 PM.

                        Comment


                        • #13
                          thanks Steve, I posted the code but then thought I was close to a solution so I pulled it. No solution yet. I started going thru some very remedial process (defining every traded state and called the appropriate stops). It was taking a very long time and I haven't tested it yet. Still working on it -- I will post it when I get to a stopping point (no pun intended) so you can have a look. I would like to get your take on the process as I'm sure there is a better way of handling this.
                          The export code will be very helpful -- I used to code basic performance outputs in EasyLanguage to write csv files. Thanks for this -- sounds like a great tool.

                          Thanks again,

                          Comment


                          • #14
                            still trying to hammer this out...


                            since I want to set a proactive stop and it seems as though the if(high()... is causing and intermediate condition to be satisfied before acting then would something like getMostRecentBid() be used in the if(high()...?


                            is there a way to modify the decimal resolution with the trace function?

                            Last edited by c_13; 02-27-2004, 01:14 PM.

                            Comment

                            Working...
                            X