示例#1
0
        protected override void onNewBar()
        {
            //Remove this code later
            if (parabolicStop != null)
            {
                if (parabolicStop.positionClosed())
                {
                    parabolicStop = null;
                }
                else
                {
                    stopIndicator.set(parabolicStop);
                }
            }
            if (parabolicStop == null)
            {
                stopIndicator.set(bars[0].close);
            }
            //*****************************************************************

            //Setup from prior bar, now in confirm
            if (inConfirm)
            {
                confirmBarCount++;
                if (confirmBarCount <= entryBarWindow)
                {
                    placeEntryOrders();
                }
                else
                {
                    inConfirm = false;
                }
            }
            if (inConfirm)
            {
                return;
            }

            //Not in confirm from prior bar, so check for setup
            setup = tradeSetup();
            if (!hasPosition() && (setup != null))
            {
                tradeSize       = (long)Math.Max(Math.Round(riskDollars / ((nATRStopStart * atr) * bigPointValue()), 0), 1);
                atrAtEntry      = atr;
                longEntryPrice  = entryLowestLow[1] + atr * nATREntry;
                shortEntryPrice = entryHighestHigh[1] - atr * nATREntry;
                placeEntryOrders();
                inConfirm       = true;
                confirmBarCount = 1;
            }

            //Currently in position, submit exit orders
            if (hasPosition())
            {
                placeExitOrders();
            }
        }