Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 public void refersTo(Position position)
 {
     position_ = position;
     if (position.direction().Equals(direction))
     {
         enterExit_ = "Scale up";
     }
     else
     {
         enterExit_ = position.size.Equals(size) ? "Exit" : "Scale down";
     }
 }
Ejemplo n.º 3
0
 public Position(Position position) : this(position.symbol, position.size, position.direction())
 {
     each(position.trades(), trade => addTrade(new Trade(trade)));
 }