Announcement

Collapse
No announcement yet.

Can one auto trade with Papertrader?

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

  • Can one auto trade with Papertrader?

    I have an EFS that I'd like to have auto-trade, but I want to do it on paper. Can the paper trader feature be made to auto trade? I can't seem to get it to work if so...

    Thanks,

    Jonathan

  • #2
    try a search for "esignal paper trade"
    Michael

    Comment


    • #3
      Thanks Michael... unfortunately I'm still stuck. I did find several posts by Brad Metheny that included .efs code to do this, but I'm no coder so can't quite get his code to work with my wizard-generated efs via cut & paste. It does seem to be exactly what I'm looking for, just have to figure out how to make it work with the siganls I'm using already (which are incredibly basic).

      I want to trade on bars with volume higher than the previous bar, and trade in the direction of the price close (long if close higher than previous close, short if lower than previous close, but ONLY on higher volume bars).

      It was incredibly easy to set this up via the wizard, but it's the papertrading component I can't figure out how to integrate.

      Thanks anyway though. Anyone else have a simple explanation of how to integrate the papertrader? I would love to actually understand how it works, rather than just cut & paste code, but in the end I just want it to work so cut & paste is better than nothing...

      Thanks everyone,

      Jonathan

      Comment


      • #4
        Sure...

        I'm helping another esignal user do the same thing.

        Check out this thread and the code examples..

        Automatic Paper Trading Thread

        B
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Thanks Brad... I read the thread and unfortunately did not come away any better informed than I am currently.

          My problem is not (yet anyway) one of time stamping... I can't even figure out how to get my system to USE the papertrader! Perhaps I should attach some code...

          Here is my complete system from the Wizard:

          ************************************************

          //{{EFSWizard_Description
          //
          // This formula was generated by the Alert Wizard
          //
          //}}EFSWizard_Description 7532


          //{{EFSWizard_Declarations

          var vLastAlert = -1;

          //}}EFSWizard_Declarations 2482


          function preMain() {
          /**
          * This function is called only once, before any of the bars are loaded.
          * Place any study or EFS configuration commands here.
          */
          //{{EFSWizard_PreMain
          setPriceStudy(true);
          setStudyTitle("High Volume Move");
          //}}EFSWizard_PreMain 8299

          }

          function main() {
          /**
          * The main() function is called once per bar on all previous bars, once per
          * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
          * in your preMain(), it is also called on every tick.
          */

          //{{EFSWizard_Expressions
          //{{EFSWizard_Expression_1
          if (
          volume() > volume(-1) &&
          close() > close(-1) &&
          Strategy.isLong() < 1
          ) onAction1()
          //}}EFSWizard_Expression_1 13987

          //{{EFSWizard_Expression_2
          else if (
          volume() > volume(-1) &&
          close() < close(-1) &&
          Strategy.isShort() < 1
          ) onAction2();
          //}}EFSWizard_Expression_2 16761

          //}}EFSWizard_Expressions 56586


          //{{EFSWizard_Return
          return null;
          //}}EFSWizard_Return 2256

          }

          function postMain() {
          /**
          * The postMain() function is called only once, when the EFS is no longer used for
          * the current symbol (ie, symbol change, chart closing, or application shutdown).
          */
          }

          //{{EFSWizard_Actions
          //{{EFSWizard_Action_1
          function onAction1() {
          drawShapeRelative(0, high(), Shape.UPARROW, "", Color.RGB(0,192,0), Shape.LEFT);
          Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
          Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
          vLastAlert = 1;
          }
          //}}EFSWizard_Action_1 36651

          //{{EFSWizard_Action_2
          function onAction2() {
          drawShapeRelative(0, low(), Shape.DOWNARROW, "", Color.RGB(155,0,0), Shape.LEFT);
          Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
          Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
          vLastAlert = 2;
          }
          //}}EFSWizard_Action_2 36135

          //}}EFSWizard_Actions 94052

          ************************************************** *8

          It works as desired, but is not ultimately what I plan to use, it is merely the start from where I want to begin refining it. I get my arrows on the chart where they should be, but now I can't figure out how to link those arrows to be trades in papertrader.

          I'm no coder, and usually create things like this via cut & paste semi-haphazardly until they work (and you'd be amazed how often they *do* work! =)

          I have toyed with adding lines from code you supplied someone else:


          var PTtrade = new PaperTradeBroker;

          and later

          PTtrade.Buy(getSymbol(),(Contracts),PaperTradeBrok er.MARKET);
          Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Warning.wav");

          But when I put these lines where they seem to need to go (the first up with the other variable declarations and the second in the long action portion of my strategy), nothing happens. This is what I wound up with that doesn't work:

          function onAction1() {
          drawShapeRelative(0, high(), Shape.UPARROW, "", Color.RGB(0,192,0), Shape.LEFT);
          PTtrade.Buy(getSymbol(),(Contracts),PaperTradeBrok er.MARKET);
          Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Warning.wav");
          vLastAlert = 1;

          Since I really *don't* know what I'm doing, can you point me in the right direction? I would think that within any doLong there would simply be a method to designate to what broker the order was being sent, like:

          Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0, PaperTrader);

          Or somesuch, but that's just my simplified thinking and wishing...

          Thanks for all your help...

          Jonathan

          Comment


          • #6
            Simple Solution..

            Place...

            var PTtrade = new PaperTradeBroker;

            At the very top of your EFS - this line envokes the Paper Trader module. You have to install the Paper Trader Module from the TRADE menu before this will work.

            Now, to issue trades, you have to use the following commands...

            PTtrade.Buy(getSymbol(),Contracts,PaperTradeBroker .MARKET);

            PTtrade.Sell(getSymbol(),0-Contracts,PaperTradeBroker.MARKET);

            "Contracts" is my variable for the number of shares/contracts.

            Notice, you have to SELL "negative" shares and BUY "positive" shares.

            If you wanted to NET REVERSE, you would have to buy or sell 2* the number of shares.

            Hope this helps. That's about it.

            Brad
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #7
              Hi again, and yes it helps tremendoulsy, but I realized after my last post that you'd probably mention declaring PTrade, which I *did* have in my code. Here is the actual code, in its entirety, after I tried cut & pasting it together...

              *************************************

              //{{EFSWizard_Description
              //
              // This formula was generated by the Alert Wizard
              //
              //}}EFSWizard_Description 7532


              //{{EFSWizard_Declarations

              var vLastAlert = -1;
              var PTtrade = new PaperTradeBroker;
              var Contracts = 100;

              //}}EFSWizard_Declarations 2482


              function preMain() {
              /**
              * This function is called only once, before any of the bars are loaded.
              * Place any study or EFS configuration commands here.
              */
              //{{EFSWizard_PreMain
              setPriceStudy(true);
              setStudyTitle("High Volume Autotrader");
              //}}EFSWizard_PreMain 8299

              }

              function main() {
              /**
              * The main() function is called once per bar on all previous bars, once per
              * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
              * in your preMain(), it is also called on every tick.
              */

              //{{EFSWizard_Expressions
              //{{EFSWizard_Expression_1
              if (
              volume() > volume(-1) &&
              close() > close(-1) &&
              Strategy.isLong() < 1
              ) onAction1()
              //}}EFSWizard_Expression_1 13987

              //{{EFSWizard_Expression_2
              else if (
              volume() > volume(-1) &&
              close() < close(-1) &&
              Strategy.isShort() < 1
              ) onAction2();
              //}}EFSWizard_Expression_2 16761

              //}}EFSWizard_Expressions 56586


              //{{EFSWizard_Return
              return null;
              //}}EFSWizard_Return 2256

              }

              function postMain() {
              /**
              * The postMain() function is called only once, when the EFS is no longer used for
              * the current symbol (ie, symbol change, chart closing, or application shutdown).
              */
              }

              //{{EFSWizard_Actions
              //{{EFSWizard_Action_1
              function onAction1() {
              drawShapeRelative(0, high(), Shape.UPARROW, "", Color.RGB(0,192,0), Shape.LEFT);
              Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
              Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
              PTtrade.Buy(getSymbol(),Contracts,PaperTradeBroker .MARKET);
              vLastAlert = 1;
              }
              //}}EFSWizard_Action_1 36651

              //{{EFSWizard_Action_2
              function onAction2() {
              drawShapeRelative(0, low(), Shape.DOWNARROW, "", Color.RGB(155,0,0), Shape.LEFT);
              Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
              Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
              PTtrade.Sell(getSymbol(),0-Contracts,PaperTradeBroker.MARKET);
              vLastAlert = 2;
              }
              //}}EFSWizard_Action_2 36135

              //}}EFSWizard_Actions 94052

              ********************

              So as you can see, I did declare both PTrade and Contracts, but I must be implementing them incorrectly somehow later on, because they don't actually work. Nothing happens at all when a trade signal comes through... No trades, just my bars changing color as expected. Where have I gone wrong?

              Also, how do I actually get it to Net Reverse? If I am currently flat, I would want it to buy 100 contracts for example, which means to reverse I sell 200, but how do I make the system check if I'm flat, or need to reverse?

              Oh also, what do you mean about "installing" the papertrader? I didn't have to do anything like that and it works fine, just not in my system...

              Thanks again, your help is tremendously appreciated by the Esignal novice...

              Jonathan

              Comment


              • #8
                looks good..

                Go ahead and test it..

                B
                Brad Matheny
                eSignal Solution Provider since 2000

                Comment


                • #9
                  I'm afraid I don't understand... test what? My code? I have, believe me, it doesn't work...

                  Was there supposed to be something attached to your post maybe?

                  Jonathan

                  Comment

                  Working...
                  X