Announcement

Collapse
No announcement yet.

Help:modified ATR stop does not move in real time

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

  • Help:modified ATR stop does not move in real time

    I am using this code from sharing. I am running it on one minute time frame. It no running in time with my charts. Stops do not move in real time. I have to keep reloading to update. Can this code move in real time.
    Thanks
    Attached Files

  • #2
    Re: Help:modified ATR stop does not move in real time

    sjsr
    See my reply in this thread in response to the same question
    Alex


    Originally posted by sjsr
    I am using this code from sharing. I am running it on one minute time frame. It no running in time with my charts. Stops do not move in real time. I have to keep reloading to update. Can this code move in real time.
    Thanks

    Comment


    • #3
      automatic stops script avail

      I have authored an automated trading script that lets you set pending entries that trigger when a condition is met, or you can simply buy instantly at market.

      Its fully functional with TRAILING STOPS you can edit on the fly, AUTOMATIC STOPS that follow bars up (or down when shorting), STATIC STOPS that you can place under pivots, first objectives for profit taking, etc... comes with bar timers, colored moving average, pivot tools, etc.

      If you want to try it out, email me your eSignal username (not your password, just your username) and I'll send you the scripts.

      Regards,
      Ryan.

      Comment


      • #4
        Thanks got the stop working in real time, Is there a way to change it so it alerts after the close of the bar (-1)

        Comment


        • #5
          Make code alert after candle bar closes

          I am using the Modified ATR stop code, with ur help i got it to work in real time, now it alerts as soon as it breaks the line, how do i change it to go on the close of the last bar -1

          Comment


          • #6
            how do you change the code to alert after close of current bar instead of real time

            how do you change the code to alert after close of current bar instead of real time of the current bar
            attached is code Modidied ATR Trailing Stop

            Thanks
            Steven
            Attached Files

            Comment


            • #7
              how to make alert when current bar closes

              I'm trying to make the Alert ATR script that esignal comes with into after the current bar closes alert. That is it waits for current bar to close above or below the ATR to alert you, right now it will alert you immediately when it goes above and below the ATR in real time. I went it to wait for the current bar to close. I am not very good at scripting so help would be appreciated thank you


              var fpArray = new Array();
              function preMain() {
              setPriceStudy(true);
              setStudyTitle("Modified ATR Trailing Stops");
              setCursorLabelName("Modified ATR TS", 0);
              setShowTitleParameters(false);
              setDefaultBarFgColor(Color.red, 0);
              setPlotType(PLOTTYPE_LINE, 0);
              setDefaultBarThickness(2, 0);
              askForInput();
              var x=0;
              fpArray[x] = new FunctionParameter("nATRPeriod", FunctionParameter.NUMBER);
              with(fpArray[x++]){
              setName("ATR Period");
              setLowerLimit(1);
              setUpperLimit(100);
              setDefault(5);
              }
              fpArray[x] = new FunctionParameter("nATRMultip", FunctionParameter.NUMBER);
              with(fpArray[x++]){
              setName("ATR Multiplication");
              setLowerLimit(1);
              setUpperLimit(10);
              setDefault(3.5);
              }
              fpArray[x] = new FunctionParameter("bShowTS", FunctionParameter.BOOLEAN);
              with(fpArray[x++]){
              setName("Show Line Trailing Stop");
              addOption("true");
              addOption("false");
              setDefault("true");
              }
              fpArray[x] = new FunctionParameter("bShowL", FunctionParameter.BOOLEAN);
              with(fpArray[x++]){
              setName("Show Labels");
              addOption("true");
              addOption("false");
              setDefault("true");
              }
              fpArray[x] = new FunctionParameter("bShowArrows", FunctionParameter.BOOLEAN);
              with(fpArray[x++]){
              setName("Show Arrows");
              addOption("true");
              addOption("false");
              setDefault("true");
              }
              fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN);
              with(fpArray[x++]){
              setName("Display Cursor Labels");
              setDefault(true);
              }
              fpArray[x] = new FunctionParameter("sStrategy", FunctionParameter.STRING);
              with(fpArray[x++]){
              setName("Long or Short");
              addOption("Long");
              addOption("Short");
              setDefault("Long");
              }
              fpArray[x] = new FunctionParameter("cColor", FunctionParameter.COLOR);
              with(fpArray[x++]){
              setName("Line Color");
              setDefault(Color.red);
              }
              }
              var bInit = false;
              var bVersion = null;
              var xATRTrailingStop = null;
              var xClose = null;
              function main(nATRPeriod, nATRMultip, sStrategy, bShowTS, bShowL, bShowArrows, ViewValue, cColor){
              var nClose = 0;
              var nClose1 = 0;
              var nATRTS = 0;
              var nATRTS1 = 0;

              if (bVersion == null) bVersion = verify();
              if (bVersion == false) return;
              if(bInit==false){
              setShowCursorLabel(ViewValue);
              setDefaultBarFgColor(cColor, 0);
              xClose = close();
              xATRTrailingStop = efsInternal("ModifiedATRTrailingStop", nATRPeriod, nATRMultip, xClose);
              bInit=true;
              }
              if(getCurrentBarIndex() == 1) return;
              nClose = xClose.getValue(0);
              nClose1 = xClose.getValue(-1);
              nATRTS = xATRTrailingStop.getValue(0);
              nATRTS1 = xATRTrailingStop.getValue(-1);
              if (nATRTS1 == null) return;
              if (nClose1 < nATRTS1 && nClose > nATRTS1) {
              if (bShowArrows) drawShape( Shape.UPARROW, BelowBar1, Color.green);
              if (sStrategy == "Long") {
              if (bShowL) drawTextRelative(0, BelowBar2, " LONG", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5);
              Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR);
              } else {
              if (bShowL) drawTextRelative(0, BelowBar2, " SELL", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5);
              if (Strategy.isShort()) Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.NEXTBAR);
              }
              }
              if (nClose1 > nATRTS1 && nClose < nATRTS1) {
              if (bShowArrows) drawShape( Shape.DOWNARROW, AboveBar1, Color.red);
              if (sStrategy == "Long") {
              if (bShowL) drawTextRelative(0, AboveBar2, " SELL", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5);
              if (Strategy.isLong()) Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR);
              } else {
              if (bShowL) drawTextRelative(0, AboveBar2, "SHORT", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME , "Arial Black", 10, "b"+(getCurrentBarCount()), -5);
              Strategy.doShort("Short", Strategy.MARKET, Strategy.NEXTBAR);
              }
              }
              if (bShowTS == false) return;
              return xATRTrailingStop.getValue(0);
              }
              var xHigh_Low = null;
              var xATR_Modif = null;
              var nRef = 0;
              var bSecondInit = false;
              function ModifiedATRTrailingStop(nATRPeriod, nATRMultip, xSClose){
              var nBarState = getBarState();
              var nClose = 0;
              var nClose1 = 0;
              var nLoss = 0;
              var nRes = 0;
              var nRef = ref(-1);
              if (bSecondInit == false) {
              xHigh_Low = efsInternal("Calc_High_Low");
              xATR_Modif = efsInternal("Calc_ATRMod", nATRPeriod, nATRMultip, xSClose, xHigh_Low, sma(nATRPeriod, xHigh_Low))
              bSecondInit = true;
              }
              nClose = xSClose.getValue(0);
              nClose1 = xSClose.getValue(-1);
              nLoss = nATRMultip * xATR_Modif.getValue(0);
              if (nLoss == null) return;
              if (nClose > nRef && nClose1 > nRef) {
              nRes = Math.max(nRef, nClose - nLoss);
              } else {
              if (nClose < nRef && nClose1 < nRef) {
              nRes = Math.min(nRef, nClose + nLoss);
              } else {
              if (nClose > nRef) {
              nRes = nClose - nLoss;
              } else {
              nRes = nClose + nLoss;
              }
              }
              }
              return nRes;
              }
              function Calc_High_Low() {
              var nRes = high(0) - low(0);
              if (nRes == null) return;
              return nRes;
              }
              var bThirdInit = false;
              var xHigh = null;
              var xLow = null;
              function Calc_ATRMod(nATRPeriod, nATRMultip, xTClose, xHigh_Low, xMA_High_Low) {
              var nHiLo = 0;
              var nHref = 0;
              var nLref = 0;
              var ndiff1 = 0;
              var ndiff2 = 0;
              var nHigh_Low = 0;
              var nMA_High_Low = 0;
              var nAtrMod = 0;
              if (bThirdInit == false) {
              xHigh = high();
              xLow = low();
              bThirdInit = true;
              }
              var nClose = xTClose.getValue(0);
              var nClose1 = xTClose.getValue(0);
              var nHigh = xHigh.getValue(0);
              var nHigh1 = xHigh.getValue(0);
              var nLow = xLow.getValue(0);
              var nLow1 = xLow.getValue(0);
              nHigh_Low = xHigh_Low.getValue(0);
              nMA_High_Low = xMA_High_Low.getValue(0) * 1.5;
              if (nHigh_Low == null || nMA_High_Low == null) return;
              if (nHigh_Low < nMA_High_Low) {
              nHiLo = nHigh_Low;
              } else {
              nHiLo = nMA_High_Low;
              }
              if (nLow <= nHigh1) {
              nHref = nHigh - nClose1;
              } else {
              nHref = (nHigh - nClose1) - (nLow - nHigh1) / 2;
              }
              if (nHigh >= nLow1) {
              nLref = nClose1 - nLow;
              } else {
              nLref = (nClose1 - nLow) - (nLow1 - nHigh) / 2;
              }
              ndiff1 = Math.max(nHiLo, nHref);
              ndiff2 = Math.max(ndiff1, nLref);
              nAtrMod = (ndiff2 + (nATRPeriod - 1) * ref(-1)) / nATRPeriod;

              if (nAtrMod == null) return;
              return nAtrMod;
              }
              function verify() {
              var b = false;
              if (getBuildNumber() < 779) {
              drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",
              Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOL D|Text.LEFT,
              null, 13, "error");
              drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
              Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOL D|Text.LEFT,
              null, 13, "upgrade");
              return b;
              } else {
              b = true;
              }
              return b;
              }

              Comment


              • #8
                Re: Help:modified ATR stop does not move in real time

                Originally posted by sjsr
                I am using this code from sharing. I am running it on one minute time frame. It no running in time with my charts. Stops do not move in real time. I have to keep reloading to update. Can this code move in real time.
                Thanks
                I brought this up at the Trading Summit in Vegas. They told me the the new 10.5 release has an issue in it that has broken this indicator. I am waiting for a fix. If anyone has any additional info please pass it along.

                Thanks,

                Ed

                Comment


                • #9
                  Re: Re: Help:modified ATR stop does not move in real time

                  Ed
                  What you were told is not correct and the indicator is not broken.
                  The reason it does not work in real time is because the formula was written for back testing use only and includes [as I explain also in a prior reply] the following conditional statement
                  if(getCurrentBarIndex() == 0) return;
                  which stops the efs from executing once it is processing the most recent bar on the chart (ie bar index 0)
                  Alex


                  Originally posted by emorrison
                  I brought this up at the Trading Summit in Vegas. They told me the the new 10.5 release has an issue in it that has broken this indicator. I am waiting for a fix. If anyone has any additional info please pass it along.

                  Thanks,

                  Ed

                  Comment

                  Working...
                  X