Announcement

Collapse
No announcement yet.

Stop Orders / Limit Orders

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

  • Stop Orders / Limit Orders

    Is there a way to insert a trailing Stop or even just a stop loss into the Formula Wizard set at a specific number of points after an entry signal is received.
    Example, I have a formula that signals a long entry for the eMini SP... say the strategy goes long at 1280.00. How can I input a stop loss and/or limit order into the Wizard.
    The only option I have now is to enter a specific price for this orders however I dont know the price at which the strategy will start...

    thanks

  • #2
    Hello AOV,

    There are a few creative options you can implement through the wizard. For one, see Alex's parabolic SAR solution for a trailing stop in this thread.

    For the most part, the formula wizard has limitations when it comes to designing this type of logic because it does not allow you to create custom variables to assign values to, such as the initial entry price. Because of this limitation, you might want to try creating your strategies through the EFS Editor. To help get you started, please read our Guide to Developing EFS Strategies.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thank you Jason,

      I did try to figure out how to write a stop using the EFS Editor but I really dont have the smallest clue... Everything I try is incorrect.

      My formula is working just fine and takes long and short entries using DMI indicator but I have no idea how to place a stop.

      Example, if a DMI cross over triggers a long position, I would like to know how to place a specific point stop loss after it.

      Thank you for having taken the time to respond to my questions...

      Kind regards,

      Andy

      Comment


      • #4
        Hello Andy,

        The guide I pointed you to will give you some examples on how to code stops and trailing stops. Please read the guide and try some of those methods. Or try to implement the parabolic sar solution I pointed you to. If you continue to have trouble, post your code so that I or other members may help provide additional guidance.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Dear Jason,

          I once again thank you for your great support !
          However, after hours of trying to get stop loss order in place as well as a profit target to my code I still cant get it to work... I used the files you sent me and still unable to get it to work.

          I am posting my code below. All it has is entry functions based on DMI cross overs and RSI...

          I am trying to add a stop loss order and also a take profit order based on point change from the entry price. In other words, IF long eMini S&P at 1300.00 then a 3 point stop at 1297.00 and 3 point profit target at 1303.00.

          I would be most thankful if you could help me further with it.

          Thanks again,

          Andy

          PHP Code:
          //{{EFSWizard_Description
          //
          //    This formula was generated by the Alert Wizard
          //
          //}}EFSWizard_Description


          //{{EFSWizard_Declarations
          var vADXDM = new ADXDMStudy(7);
          var 
          vRSI9 = new RSIStudy(9"Close");
          var 
          vLastAlert = -1;
          //}}EFSWizard_Declarations


          function preMain() {
          //{{EFSWizard_Code_PreMain_setPriceBarColor
          setColorPriceBars(true);
          //}}EFSWizard_Code_PreMain_setPriceBarColor
             /**
              *  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("");
          //}}EFSWizard_PreMain

          }

          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 (
                      
          vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI) &&
                      
          getHour() >= 11 &&
                      
          getHour() <= 11 &&
                      
          vRSI9.getValue(RSIStudy.RSI) < 60
                  
          onAction1()
              
          //}}EFSWizard_Expression_1
              
              //{{EFSWizard_Expression_2
                  
          else if (
                      
          vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI) &&
                      
          getHour() >= 11 &&
                      
          getHour() <= 11 &&
                      
          vRSI9.getValue(RSIStudy.RSI) > 40
                  
          onAction2()
              
          //}}EFSWizard_Expression_2
              
              //{{EFSWizard_Expression_3
                  
          else if (
                      
          getHour() == 16 &&
                      
          Strategy.isInTrade() == Strategy.isLong()
                  ) 
          onAction3()
              
          //}}EFSWizard_Expression_3
              
              //{{EFSWizard_Expression_4
                  
          else if (
                      
          getHour() == 16 &&
                      
          Strategy.isInTrade() == Strategy.isShort()
                  ) 
          onAction4();
              
          //}}EFSWizard_Expression_4
              
          //}}EFSWizard_Expressions


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

          }

          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() {
                  if (
          vLastAlert != 1Strategy.doLong(""Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                  if (
          vLastAlert != 1Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Blip.wav");
                  if (
          vLastAlert != 1setPriceBarColor(Color.RGB(0,128,0));
                  
          vLastAlert 1;
              }
              
          //}}EFSWizard_Action_1
              
              //{{EFSWizard_Action_2
              
          function onAction2() {
                  if (
          vLastAlert != 2Strategy.doShort(""Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                  if (
          vLastAlert != 2Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Laser.wav");
                  if (
          vLastAlert != 2setPriceBarColor(Color.RGB(155,0,0));
                  
          vLastAlert 2;
              }
              
          //}}EFSWizard_Action_2
              
              //{{EFSWizard_Action_3
              
          function onAction3() {
                  if (
          vLastAlert != 3Strategy.doSell(""Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                  
          vLastAlert 3;
              }
              
          //}}EFSWizard_Action_3
              
              //{{EFSWizard_Action_4
              
          function onAction4() {
                  if (
          vLastAlert != 4Strategy.doCover(""Strategy.MARKETStrategy.THISBARStrategy.DEFAULT, 0);
                  
          vLastAlert 4;
              }
              
          //}}EFSWizard_Action_4
              
          //}}EFSWizard_Actions 

          Comment


          • #6
            Hello Andy,

            Its unfortunate that you did not post your code that shows what you attempted to do. It would be more beneficial for your learning experience if you did as I would be able to more easily point out the particulars of where you may be going wrong. At any rate, here are a few suggestions and some of the next steps to help get you going in the right direction.

            1 - (Suggestion) Since all the indicators you're using share the same scale and are non-price studies, I would recommend setting your formula up as a non-price study and return the three indicators to the chart. In the formula wizard, change the Formula Configuration settings to something like the following.



            Then add your indicators to their respective container in the Returned Data Points section as follows.



            This helps you during the development process because you have some visual references as to what is happening in your strategy.

            2. To use the parabolic study for the trailing stop, you will first need to add the study to your formula.



            Then add two more conditional sets (Set 5 and Set 6) like below.





            Save the changes and test it out. If you have any trouble, post your modified formula.
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Jason, Once again I would like to thank you for lending a hand...
              However, I wanted to let you know that I am still having problems with my formula and getting it to work.

              Fortunately I was able to add trail stops using PAR - however, I am still trying to get it to execute stop loss and profit exits based on a specific number of points from the original position entry price.

              I am enclosing my "little mess". I added what part of the examples which I thought would make it work but unfortunately for me it just doesnt do it.

              I am sorry for coming back to you again with the same issue but at this point I really dont have any other choice...

              If you find any errors or have any suggestions to what I have put together so far please let me know...

              Thanking you in advance for you help and great support

              Andy

              ______________________________________
              The info that I added is basically as "var" and also just about the first have of the "function main" until it gets to wizard stuff - thanks !!
              ______________________________________

              PHP Code:
              //{{EFSWizard_Description
              //
              //    This formula was generated by the Alert Wizard
              //
              //}}EFSWizard_Description


              //{{EFSWizard_Declarations
              var vADXDM = new ADXDMStudy(7);
              var 
              vRSI9 = new RSIStudy(9"Close");
              var 
              vParSAR = new ParabolicStudy(0.0050.0050.05);
              var 
              vLastAlert = -1;

              var 
              nNewTrade// New Trade Trigger 0 = OFF / 1 = ON
              var nsignal// returns the direction of the trading signal
              var nTradeEntryPrice
              var 
              ProfitTarget1 5.0;
              var 
              nStopLevel;
              //}}EFSWizard_Declarations


              function preMain() {
              //{{EFSWizard_Code_PreMain_setPriceBarColor
              setColorPriceBars(true);
              //}}EFSWizard_Code_PreMain_setPriceBarColor
                 /**
                  *  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("");
                  
                  var 
              fp1 = new FunctionParameter("nProfitAmt"FunctionParameter.NUMBER); //ADDED
                  
              fp1.setName("Profit Target Amount"); //ADDED
                  
              fp1.setLowerLimit(0.01); //ADDED
                  
              fp1.setDefault(3); //ADDED

                  
              var fp2 = new FunctionParameter("nStopAmt"FunctionParameter.NUMBER); //ADDED
                  
              fp2.setName("Stop Target Amount"); //ADDED
                  
              fp2.setLowerLimit(0.01); //ADDED
                  
              fp2.setDefault(1); //ADDED
                  
              //}}EFSWizard_PreMain

              }

              function 
              main(nProfitAmtnStopAmt) {
                  
              ProfitTarget1 nProfitAmt//ADDED
                  
                  
              /*----------------------------------------------------------------
              // If new trade, get entry price - used for our profit target
              ----------------------------------------------------------
              This portion of the code identifies if a new trade has been issued 
              and records the entry price of our trade. If no new trade has been 
              triggered (nNewTrade == 1), then this portion of the code is ignored.
              ----------------------------------------------------------*/

                  
              var bPosition false;  //ADDED
                  
              if (Strategy.isInTrade() == true && (nNewTrade == 1)) {
                      
              // This sets the expected entry price of the current short trade
                      
              nTradeEntryPrice open();
                      
              // This switches off the nNewTrade variable
                      
              nNewTrade 0// Turn off NEW TRADE switch
                      
              bPosition true// ADDED
                  
              }

                  var 
              nDisplayStop null//ADDED
                  
              if (Strategy.isInTrade() == true) {  //ADDED
                      
              nDisplayStop nStopLevel;  //ADDED
                      //var bPosition = true;
                      
              if (Strategy.isLong() == truesetPriceBarColor(Color.green);  //ADDED
                      
              if (Strategy.isShort() == truesetPriceBarColor(Color.red);  //ADDED
                  
              } else {  //ADDED
                      
              nStopLevel null;  //ADDED
                  
              }  //ADDED

                  /*----------------------------------------------------------------
                  // Test for Profit Target Breach (ProfitTarget1)
                  ----------------------------------------------------------
                  This portion of the code identifies if our profit target has 
                  been reached and exits our trades.
                  ----------------------------------------------------------*/

                  
              if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
                      
              // Check if the profit target has been reached/breached
                      
              if (low() <= (nTradeEntryPrice ProfitTarget1)) {
                          
              // Profit Target Breached, Execute Cover order.
                          
              Strategy.doCover("Short PT1 Exit"Strategy.STOPStrategy.THISBAR
                              
              Strategy.getDefaultLotSize(), Math.min(open(0), (nTradeEntryPrice ProfitTarget1)));
                      }
                  }

                  if (
              Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
                      
              // Check if the profit target has been reached/breached
                      
              if (high() >= (nTradeEntryPrice ProfitTarget1)) {
                          
              // Profit Target Breached, Execute Sell order.
                          
              Strategy.doSell("Long PT1 Exit"Strategy.STOPStrategy.THISBAR
                              
              Strategy.getDefaultLotSize(), Math.max(open(0), (nTradeEntryPrice ProfitTarget1)));
                      }
                  }


                  
              /*----------------------------------------------------------
                  This portion of the code tests for a stop level breach and 
                  executes trades accordingly.
                  ----------------------------------------------------------*/
                  
              if (Strategy.isInTrade() == true && (Strategy.isShort() == true)) {
                      
              // Check if the profit target has been reached/breached
                      
              if (high() >= nStopLevel) {
                          
              // Stop Breached, Execute Cover order.
                          
              Strategy.doCover("Short Stop Exit"Strategy.STOPStrategy.THISBAR
                              
              Strategy.getDefaultLotSize(), nStopLevel);
                      }
                  }

                  if (
              Strategy.isInTrade() == true && (Strategy.isLong() == true)) {
                      
              // Check if the profit target has been reached/breached
                      
              if (low() <= nStopLevel) {
                          
              // Stop Breached, Execute Sell order.
                          
              Strategy.doSell("Long Stop Exit"Strategy.STOPStrategy.THISBAR
                              
              Strategy.getDefaultLotSize(),nStopLevel);
                      }
                  }


                  

                  
              /*----------------------------------------------------------------
                  // Execute Trades ONLY if nNewTrade is triggered ....
                  ----------------------------------------------------------------- */

                  
              if (nNewTrade == 1) { //Execute New Trade
                      // new or reversed trade position
                      
              if (Strategy.isInTrade() == true) {
                          if ((
              nsignal 0) && (Strategy.isShort() == true)) {
                              
              Strategy.doLong("Rev Long"Strategy.MARKETStrategy.NEXTBAR);
                              
              nStopLevel low(0) - nStopAmt;
                          }
                          if ((
              nsignal 0) && (Strategy.isLong() == true)) {
                              
              Strategy.doShort("Rev Short"Strategy.MARKETStrategy.NEXTBAR);
                              
              nStopLevel high(0) + nStopAmt;
                          }
                      } else {
                          if ((
              nsignal 0)) {
                              
              Strategy.doLong("Go Long"Strategy.MARKETStrategy.NEXTBAR);
                              
              nStopLevel low(0) - nStopAmt;
                          }
                          if ((
              nsignal 0)) {
                              
              Strategy.doShort("Go Short"Strategy.MARKETStrategy.NEXTBAR);
                              
              nStopLevel high(0) + nStopAmt;
                          }
                      } 
              // end if IN TRADE
                  
              // END EXECUTE NEW TRADE
                  
                  
              var nDisplayProfit null;  //ADDED
                  
              if (Strategy.isLong() == true && nNewTrade == 0nDisplayProfit = (nTradeEntryPrice ProfitTarget1);  //ADDED
                  
              if (Strategy.isShort() == true && nNewTrade == 0nDisplayProfit = (nTradeEntryPrice ProfitTarget1);  //ADDED
                  
                  
              }

              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 (
                          
              vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI) &&
                          
              getHour() >= 11 &&
                          
              getHour() <= 11 &&
                          
              vRSI9.getValue(RSIStudy.RSI) < 60 &&
                          
              getMinute() >= 20
                      
              onAction1()
                  
              //}}EFSWizard_Expression_1
                  
                  //{{EFSWizard_Expression_2
                      
              else if (
                          
              vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI) &&
                          
              getHour() >= 11 &&
                          
              getHour() <= 11 &&
                          
              vRSI9.getValue(RSIStudy.RSI) > 40 &&
                          
              getMinute() >= 20
                      
              onAction2()
                  
              //}}EFSWizard_Expression_2
                  
                  //{{EFSWizard_Expression_3
                      
              else if (
                          
              getHour() == 16 &&
                          
              Strategy.isInTrade() == Strategy.isLong()
                      ) 
              onAction3()
                  
              //}}EFSWizard_Expression_3
                  
                  //{{EFSWizard_Expression_4
                      
              else if (
                          
              getHour() == 16 &&
                          
              Strategy.isInTrade() == Strategy.isShort()
                      ) 
              onAction4()
                  
              //}}EFSWizard_Expression_4
                  
                  //{{EFSWizard_Expression_5
                      
              else if (
                          
              vRSI9.getValue(RSIStudy.RSI) < 15 &&
                          
              Strategy.isInTrade() == Strategy.isShort() &&
                          
              getHour() >= 12
                      
              onAction5()
                  
              //}}EFSWizard_Expression_5
                  
                  //{{EFSWizard_Expression_6
                      
              else if (
                          
              vRSI9.getValue(RSIStudy.RSI) > 85 &&
                          
              Strategy.isInTrade() == Strategy.isLong() &&
                          
              getHour() >= 12
                      
              onAction6()
                  
              //}}EFSWizard_Expression_6
                  
                  //{{EFSWizard_Expression_7
                      
              else if (
                          
              Strategy.isInTrade() == Strategy.isLong() &&
                          
              vParSAR.getValue(ParabolicStudy.STOP) > close(0) &&
                          
              getHour() >= 15 &&
                          
              vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI)
                      ) 
              onAction7()
                  
              //}}EFSWizard_Expression_7
                  
                  //{{EFSWizard_Expression_8
                      
              else if (
                          
              Strategy.isInTrade() == Strategy.isShort() &&
                          
              vParSAR.getValue(ParabolicStudy.STOP) < close() &&
                          
              getHour() >= 15 &&
                          
              vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI)
                      ) 
              onAction8();
                  
              //}}EFSWizard_Expression_8
                  
              //}}EFSWizard_Expressions


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

              }

              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() {
                      if (
              vLastAlert != 1Strategy.doLong("Open Long"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      if (
              vLastAlert != 1setPriceBarColor(Color.RGB(0,128,0));
                      
              vLastAlert 1;
                  }
                  
              //}}EFSWizard_Action_1
                  
                  //{{EFSWizard_Action_2
                  
              function onAction2() {
                      if (
              vLastAlert != 2Strategy.doShort("Open Short"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      if (
              vLastAlert != 2setPriceBarColor(Color.RGB(155,0,0));
                      
              vLastAlert 2;
                  }
                  
              //}}EFSWizard_Action_2
                  
                  //{{EFSWizard_Action_3
                  
              function onAction3() {
                      if (
              vLastAlert != 3Strategy.doSell("Close X Long"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      
              vLastAlert 3;
                  }
                  
              //}}EFSWizard_Action_3
                  
                  //{{EFSWizard_Action_4
                  
              function onAction4() {
                      if (
              vLastAlert != 4Strategy.doCover("Close X Short"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      
              vLastAlert 4;
                  }
                  
              //}}EFSWizard_Action_4
                  
                  //{{EFSWizard_Action_5
                  
              function onAction5() {
                      if (
              vLastAlert != 5Strategy.doCover("RSI X Short"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      if (
              vLastAlert != 5setBarBgColor(Color.RGB(0,0,255));
                      
              vLastAlert 5;
                  }
                  
              //}}EFSWizard_Action_5
                  
                  //{{EFSWizard_Action_6
                  
              function onAction6() {
                      if (
              vLastAlert != 6Strategy.doSell("RSI X Long"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      if (
              vLastAlert != 6setBarBgColor(Color.RGB(255,0,0));
                      
              vLastAlert 6;
                  }
                  
              //}}EFSWizard_Action_6
                  
                  //{{EFSWizard_Action_7
                  
              function onAction7() {
                      if (
              vLastAlert != 7Strategy.doSell("PAR X Long"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      
              vLastAlert 7;
                  }
                  
              //}}EFSWizard_Action_7
                  
                  //{{EFSWizard_Action_8
                  
              function onAction8() {
                      if (
              vLastAlert != 8Strategy.doCover("PAR X Short"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT, 0);
                      
              vLastAlert 8;
                  }
                  
              //}}EFSWizard_Action_8
                  
              //}}EFSWizard_Actions 

              Comment


              • #8
                Hello Andy,

                The current problem with your code is that you have two main() functions. You can only have one. The new main() that you have pasted into your study contains the logic for the stops from the sample code, but that's it. You need to incorporate the entry conditions from your original main() into the new main() or vise versa. Then get rid of the other main() function.

                If you move your wizard conditions into the new main(), copy the code example for the entry conditions from the sample formula back in and replace the conditions (i.e. "vMA1_1 < vMA2_1 && vMA1 > vMA2" ) with the entry conditions from your wizard code.

                ... from Sample_TargetStop.efs
                PHP Code:
                    /*----------------------------------------------------------------
                    // Identify new trade signals
                    ----------------------------------------------------------------- */

                    //ADDED - bPostion logic to the following line to prevent new entry
                    //        on the same bar that an exit trade occured.
                    
                if (bPosition == false) {
                        
                //if (/*Buy Condition*/)) {
                        
                if (vMA1_1 vMA2_1 && vMA1 vMA2) {  //ADDED
                            
                nNewTrade 1// New Trade Trigger
                            
                nsignal 1// Buy Signal - Trade Type
                        
                }
                        
                //if (/*Sell Condition*/) {
                        
                if (vMA1_1 vMA2_1 && vMA1 vMA2) {  //ADDED
                            
                nNewTrade 1// New Trade Trigger
                            
                nsignal = -1// Sell Signal - Trade Type
                        
                }
                    } 
                Keep in mind, the sample code entry logic is also considering reversal entries. You may not want that. If that is the case, just use the else portion of the "New Trade" code block as a separate if statement instead of an else and get rid of the initial if statement that the else was attached to. Something like below.

                PHP Code:
                    /*----------------------------------------------------------------
                    // Execute Trades ONLY if nNewTrade is triggered ....
                    ----------------------------------------------------------------- */

                    
                if (nNewTrade == 1) { //Execute New Trade
                        // new or reversed trade position
                        //if (Strategy.isInTrade() == true) {
                            //if ((nsignal > 0) && (Strategy.isShort() == true)) {
                                //Strategy.doLong("Rev Long", Strategy.MARKET, Strategy.NEXTBAR);
                                //nStopLevel = low(0) - nStopAmt;
                            //}
                            //if ((nsignal < 0) && (Strategy.isLong() == true)) {
                                //Strategy.doShort("Rev Short", Strategy.MARKET, Strategy.NEXTBAR);
                                //nStopLevel = high(0) + nStopAmt;
                            //}
                        //} else {
                            
                if ((nsignal 0)) {
                                
                Strategy.doLong("Go Long"Strategy.MARKETStrategy.NEXTBAR);
                                
                nStopLevel low(0) - nStopAmt;
                            }
                            if ((
                nsignal 0)) {
                                
                Strategy.doShort("Go Short"Strategy.MARKETStrategy.NEXTBAR);
                                
                nStopLevel high(0) + nStopAmt;
                            }
                        
                //} // end if IN TRADE
                    
                // END EXECUTE NEW TRADE 
                I think this would be the easier route to go. Make these changes and see how it turns out. If you need more help, just post your new code.
                Jason K.
                Project Manager
                eSignal - an Interactive Data company

                EFS KnowledgeBase
                JavaScript for EFS Video Series
                EFS Beginner Tutorial Series
                EFS Glossary
                Custom EFS Development Policy

                New User Orientation

                Comment

                Working...
                X