Announcement

Collapse
No announcement yet.

My swing indicator

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

  • My swing indicator

    Hi,

    I've develped a quite simple swing indicator and can't program it into the esignal efs system. I've tried lots of time and didn't came to the right context.

    The formulas of the swing indicator is as follows:

    buy: Cross((Mov(Close,17,S)-Mov(Close,18,S)),(Mov(Mov(Close,17,S)-Mov(Close,21,S),35,S))).
    Sell: Cross((Mov(Mov(Close,17,S)-Mov(Close,21,S),35,S)),(Mov(C,17,S)-Mov(Close,18,S)))

    its quite simple indicator but very usefull.
    Pls help me to sort this out.

    Kindly Regards,
    Danny Peretz
    Tel: 972-364510465
    Email: [email protected]
    Danny Peretz
    Tel: 972-64510465
    E-mail: [email protected]

  • #2
    Danny:

    Script attached.

    Chris
    Attached Files

    Comment


    • #3
      Originally posted by ckryza
      Danny:

      Script attached.

      Chris
      it works good in historic mode, but real time long and short follow trend up and chart

      Comment


      • #4
        pbohm
        As far as I can see it is running correctly also in real time.
        If you want to visualize how the signals are generated run the attached efs in addition to Chris'.
        The Long and Shrt signals on the price chart should appear on the bar following the crossovers that are highlighted by a lime or magenta background in the indicator pane.
        Alex

        Attached Files

        Comment


        • #5
          SIMPLECROSS

          ALEX, COULD YOU LOOK AS THIS FILE IN REAL TIME AND HISTORIC.
          /************************************************** ******************
          Title: Simple Crossover Script for eSignal 7.x
          By: Chris D. Kryza (Divergence Software, Inc.)
          Email: [email protected]
          Incept: 09/20/2003
          Version: 1.0.0


          ================================================== ===================
          Fix History:

          09/20 - Initial Release
          1.0.0

          ================================================== ===================
          Project Description:

          User-requested script:

          buy: Cross((Mov(Close,17,S)-Mov(Close,18,S)),(Mov(Mov(Close,17,S)-Mov(Close,21,S),35,S))).
          Sell: Cross((Mov(Mov(Close,17,S)-Mov(Close,21,S),35,S)),(Mov(C,17,S)-Mov(Close,18,S)))


          Dislaimer: For educational purposes only! Obviously, no guarantees
          whatsoever and use at your own risk.

          ************************************************** ********************/


          //Global Variables
          var grID = 0;
          var nAdj = 0;
          var nBarCounter = 0;
          var nStatus = 0;
          var nVal1 = null;
          var nVal2 = null;
          var nVal1_1 = null;
          var nVal2_1 = null;
          var aMAArray = new Array();
          var aFPArray = new Array();
          var nStudy1 = new MAStudy( 4, -7, "close", MAStudy.SIMPLE );
          var nStudy2 = new MAStudy( 30, 0, "close", MAStudy.SIMPLE );
          var nStudy3 = new MAStudy( 15, 0, "close", MAStudy.SIMPLE );

          var nFontSize = 12;


          //== PreMain function required by eSignal to set things up
          function preMain() {
          var x;

          setPriceStudy(true);
          setStudyTitle("Simple Crossover");
          setShowCursorLabel(false);

          //unrem this if you don't want the study to update on every tick
          //setComputeOnHgh();
          grID = 0;

          for (x=0; x<100; x++) {
          aMAArray[x] = 0.0;
          }
          }

          //== Main processing function
          function main( Param1, Param2 ) {
          var x;
          var nMA1;
          var nMA2;
          var nMA3;

          //script is initializing
          if ( getBarState() == BARSTATE_ALLBARS ) {
          return null;
          }

          //called on each new bar
          if ( getBarState() == BARSTATE_NEWBAR ) {

          nAdj = close() * 0.0005;

          nBarCounter++;
          aMAArray.pop();
          aMAArray.unshift(-1);

          nVal1_1 = nVal1;
          nVal2_1 = nVal2;

          }

          nMA1 = nStudy1.getValue( MAStudy.MA ); //5,0 period
          nMA2 = nStudy2.getValue( MAStudy.MA ); //9,0period
          nMA3 = nStudy3.getValue( MAStudy.MA ); //14,0 period

          nVal1 = nMA1 - nMA2; //10period -11 period
          aMAArray[-1] = nMA1 - nMA3; //25 period - 15 period
          nVal2 = arrayAverage( 10, aMAArray ); //get the 10 bar average

          //signal logic
          if ( nStatus <= 0 && nVal1 > nVal2 && nVal1_1 <= nVal2_1 ) {
          goLong();
          }
          else if ( nStatus >= 0 && nVal1 < nVal2 && nVal1_1 >= nVal2_1 ) {
          goShort();
          }


          }


          /*************************************************
          SUPPORT FUNCTIONS
          **************************************************/

          function drawBuySell( sText, nDir, nColor, nPrice ) {
          var nOffset;

          nOffset = getCurrentBarIndex()==0 ? 0 : 1;

          //buy or cover
          if ( nDir==1 ) {
          drawShapeRelative(1, low(nOffset)-nAdj, Shape.UPARROW, "", Color.magenta, Shape.TOP | Shape.ONTOP , gID());
          drawTextRelative(1, low(nOffset)-(nAdj*1.5), sText, nColor, null, Text.CENTER | Text.TOP | Text.BOLD | Text.ONTOP, null, nFontSize, gID());
          return( true );
          }

          //short or sell
          if ( nDir==-1 ) {
          drawShapeRelative(1, high(nOffset)+nAdj, Shape.DOWNARROW, "", Color.maroon, Shape.BOTTOM | Shape.ONTOP , gID());
          drawTextRelative(1, high(nOffset)+(nAdj*1.5), sText, nColor, null, Text.BOTTOM | Text.CENTER | Text.BOLD | Text.ONTOP, null, nFontSize, gID());
          return( true );
          }
          }

          //== initiate a long trade
          function goLong() {
          nStatus = 1;
          drawBuySell( "Long", 1, Color.green, open(1) );
          Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT );
          }

          //== initiate a short trade
          function goShort() {
          nStatus = -1;
          drawBuySell( "Shrt", -1, Color.red, open(1) );
          Strategy.doShort("Short", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT );
          }


          function arrayAverage( nBars, aArray ) {
          var x=0;
          var nTmp = 0;

          while( x<nBars ) {
          nTmp += aArray[x];
          x++;
          }

          return( nTmp/nBars );
          }

          //== gID function assigns unique identifier to graphic/text routines
          function gID() {
          grID ++;
          return( grID );
          }

          Comment


          • #6
            pbohm
            The script you posted is the same one written by Chris which I have been running alongside to mine (as can be seen in the image in my prior message). The only difference is that you have changed the parameters.
            Anyhow I have been running Chris' efs again on a 3T chart of the DAX in real time and as far as I can see the signals it generates are correct (see image enclosed here)
            Alex

            Last edited by ACM; 09-25-2003, 07:14 AM.

            Comment


            • #7
              SIMPLECROSS

              THANKS FOR LOOKING AGAIN, WHEN THE 1 MINUTE ADVANCE CHART MOVES EITHER A LONG OR SHRT MOVES WITH IT. IT APPEARS IT IS FOLLOWING EACH TICK.

              Comment


              • #8
                pbohm
                What exactly are the parameters you are using for the moving averages. The problem could be caused by some condition not being true in real time but correct when the historical data is present.
                Alex

                Comment


                • #9
                  SIMPLECROSS

                  IAM USING
                  var nStudy1 = new MAStudy( 4, -10, "close", MAStudy.SIMPLE );
                  var nStudy2 = new MAStudy( 25, -4, "close", MAStudy.SIMPLE );
                  var nStudy3 = new MAStudy( 30, -4, "close", MAStudy.SIMPLE );

                  AND ALSO
                  var nStudy1 = new MAStudy( 4, -7, "close", MAStudy.SIMPLE );
                  var nStudy2 = new MAStudy( 30, 0, "close", MAStudy.SIMPLE );
                  var nStudy3 = new MAStudy( 15, 0, "close", MAStudy.SIMPLE );

                  Comment


                  • #10
                    pbohm
                    The problem is caused by your settings.
                    You are using a negative offset ie you are shifting the moving average(s) backwards hence there is no value to use for calculations on the current bar.
                    To see what I mean load a simple MA from Basic Studies and set the offset to a negative value.
                    If your intention was to displace the MA forward then use a positive number ie var nStudy1 = new MAStudy( 4, 10, "close", MAStudy.SIMPLE ); to use one of your settings as an example.
                    Alex
                    Last edited by ACM; 09-26-2003, 06:25 AM.

                    Comment

                    Working...
                    X