Announcement

Collapse
No announcement yet.

paper trading

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

  • paper trading

    i made a simple strategy that is in the market 100% or the time so i could test the esignal paper trading system, and i used the generic broker functions buyMarket(getSymbol(),10) and sellShortMarket(getSymbol(),10) expecting that when the sell short order is placed, it would automatically close the long position, however the paper trading account manager is telling me the "order has been rejected: you cannot place an open order at the moment. Please close an existing opposite side position first" so i was wondering, what generic broker functions do i use to close a short order?

  • #2
    In the current version of esignal (10.x), I believe you have to use a few extra parameters with the calls, like this..

    // Buy example
    buyMarket(getSymbol() , 10, "Account Manager", 473851, SB_DAY);


    // Sell example
    sellMarket(getSymbol() , 10, "Account Manager", 473851, SB_DAY);

    473851 is the ACCOUNT that was created when I initialized the papertrader system in esignal. You can check your account # by clicking on TRADE, then PAPER TRADER, then ACCOUNT MANAGER, then on the ACCOUNTS tab.

    I know you have to keep track of your fired orders (or positions) in EFS for this to work. There is no way to call "how many contracts/shares do I have". So you have to create a "running total" of "activecontracts", then sell the right amount to GO FLAT.

    If you go long 2, then you need to sell 2 to get flat. If you want to reverse, then you have to sell 4 - get it?
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      i understand, your initial trade will be half the size of following trades if you intend to reverse your position on the next action, ive grown accustomed to needing to keep track of your own information with efs, if for example you want to alter your strategy based on how much profit you have, you have to keep track of that profit yourself.

      ive figured out how the orders work, ive gotten the program shown below to work just fine without the extra parameters thanks for the reply though : ) im going to fiddle with the extra parameters, you gave me an idea to fix a problem im having sending orders to my broker through efs.. maybe you can help me out with another problem though, why does this program work, yet my other program, the one i mentioned in the original post, wont place orders still? im thinking it has to do with my conditions and not the order itself but im not sure.. the script in question is the second php block

      PHP Code:
      var LastEntry 0;

      function 
      preMain() {
          
      setPriceStudy(true);
          
      setColorPriceBars(false);
          
      setStudyTitle("mouse");
          
      setCursorLabelName("Side",0)
          
      setPlotType(PLOTTYPE_LINE0)
          
      setPlotType(PLOTTYPE_LINE1)
          
      setDefaultBarThickness(20);
          
      setDefaultBarThickness(21);
          
      setDefaultBarFgColor(Color.RGB(0,0,255), 0);
          
      setDefaultBarFgColor(Color.RGB(255,0,0), 1);
          
      //setPlotType(PLOTTYPE_DOT, 0)
      }

      function 
      main() {
      drawLineRelative(1close(), 40close(), PS_SOLID2Color.RGB(255,0,255), 1)
      drawLineRelative(1100010PS_SOLID1Color.RGB(255,0,255), 2)
      return 
      String(LastEntry)
      }
      function 
      onLButtonDblClkbarIndexyValuexy) {
         
          if (     
      barIndex >= && yValue close() && LastEntry ==  1) {
              
      buyMarket(getSymbol(), 100000)
              
      LastEntry 1
          
      }
          else if (
      barIndex >= && yValue close() && LastEntry ==  0) {
              
      buyMarket(getSymbol(), 100000)
              
      LastEntry 1
          
      }
          else if (
      barIndex >= && yValue close() && LastEntry == -1) {
              
      closePosition(getSymbol())
              
      LastEntry 0
          
      }
          
      ////
          
      else if (     barIndex >= && yValue close() && LastEntry ==  1) {
              
      sellMarket(getSymbol(), 100000)
              
      LastEntry 0
          
      }
          else if (
      barIndex >= && yValue close() && LastEntry ==  0) {
              
      sellShortMarket(getSymbol(), 100000)
              
      LastEntry = -1
          
      }
          else if (
      barIndex >= && yValue close() && LastEntry == -1) {
              
      sellShortMarket(getSymbol(), 100000)
              
      LastEntry = -1
          

          


      PHP Code:
      if(Conditions == true) {
              
      Strategy.doLong(""Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, close())
              if (
      getCurrentBarIndex()==&& getBarState()==BARSTATE_ALLBARSclosePosition(getSymbol())
              if (
      getCurrentBarIndex()==&& getBarState()==BARSTATE_ALLBARSbuyMarket(getSymbol(),100000)
              
      LastEntry close()
          } 
      the backtesting doLong() works, but not the paper trading order
      Last edited by kalzenith; 09-29-2009, 10:27 AM.

      Comment

      Working...
      X