Announcement

Collapse
No announcement yet.

Fill Type/ Fill Bar

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

  • Fill Type/ Fill Bar

    While reading the guide to developing efs strategies and this board

    “If your system generates a trade on a bar, we won’t know the entry price of this trade until the next bar.”

    “When back testing, the Strategy Analyzer only processes completed bars.”


    a question came ahead:

    Is it possible to test a condition like “buy this bar at the previous bar´s high”?

    So what I want to simulate is an order like: buy on stop at yesterdays high.

    or something like: if the market crosses a certain, for example pivot level, buy on stop at this (pivot-) level, not waiting to the close of this bar.

  • #2
    helmutw
    Yes you can using Strategy.STOP or Strategy.LIMIT and use a defined price as the entry/exit price
    If you run a search for either you should find some examples on how to do it.
    Alex

    Comment


    • #3
      Alex, please have a look at my efs strategy.

      The trades are closed at the opening of the next bar. Is it possible and in case how can I code it, the trades to being closed at the close of this bar or a certain level?


      function main() {



      //Long

      if (Strategy.isLong() == true )

      Strategy.doSell("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT); // Sell exist. Long @Open


      if ( high () > high (-1) && close(-1) > open(-1) && open() < high(-1) && Strategy.isLong() == false )

      Strategy.doLong("", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, high(-1));

      //Short

      if (Strategy.isShort()== true )

      Strategy.doCover("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT); // Cover exist. short @Open


      if ( low() < low(-1) && close(-1) < open(-1) && open(0) > low(-1) && Strategy.isShort() == false )

      Strategy.doShort("", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, low(-1));



      if(Strategy.isLong()) setPriceBarColor(Color.lime);
      if(Strategy.isShort()) setPriceBarColor(Color.red);

      return
      Attached Files

      Comment


      • #4
        Helmut
        When you run an efs through the back tester it executes only once per bar. Therefore since the exit commands are set before the entry commands the back tester does not know on that same bar that the strategy is long/short. It will however know it is long/short on the next bar at which point it executes the exit trades.
        If you want the commands that exit a trade to be executed on the same bar you will need to reverse the logic ie first enter the long/short trade and then check if long/short and exit the trade.
        At that point you can use either Strategy.CLOSE and Strategy.THISBAR if you want to exit on the Close or Strategy.STOP and Strategy.THISBAR and set an exit price. In the latter condition you will also need to check if your exit price has actually been breached by the bar.
        As suggested in my prior reply if you run a search for Strategy.LIMIT or Strategy.STOP you should find some examples that show you how to do this
        Alex

        Comment

        Working...
        X