示例#1
0
        public ParabolicStop(
            Position position, BarSpud bars, double initialStopPrice, double afStep,
            double afMax, int lookbackBars, string name
            ) : base(position, name, PROTECTIVE_STOP, bars.manager)
        {
            this.initialStopPrice = initialStopPrice;
            this.afStep           = afStep;
            this.afMax            = afMax;
            this.bars             = bars;
            af = dependsOn(new RootSpud <double>(manager));
            af.set(afStep);

            extreme = dependsOn(position.longShort(bars.high, bars.low));
            var extremeSide = position.longShort(MinMax <double> .MAX, MinMax <double> .MIN);

            maxExtreme            = dependsOn(extreme.minMax(extremeSide));
            opposite              = position.direction().isLong() ? bars.low : bars.high;
            recentOppositeExtreme = dependsOn(position.direction().isLong() ? opposite.lowest(lookbackBars) : opposite.highest(lookbackBars));
            numBars = dependsOn(new BarCounter(bars));
        }
示例#2
0
 void setStopLevel(Position position, ComparableSpud <double> close, double dollarStop)
 {
     currentStopLevel = close - position.direction() * (dollarStop / (position.size * bigPointValue()));
 }