private bool IsSampleWithLongTail(DataSample sample, PositionDirection direction, decimal deltaPercentage) { var result = false; if (direction == PositionDirection.Long && sample.CandleColor == Common.CandleColor.Green) { result = Math.Abs(sample.Candle.Open - sample.Candle.Low) / Math.Abs(sample.Candle.Low - sample.Candle.High) > deltaPercentage; } else if (direction == PositionDirection.Long && sample.CandleColor == Common.CandleColor.Red) { result = Math.Abs(sample.Candle.Close - sample.Candle.Low) / Math.Abs(sample.Candle.Low - sample.Candle.High) > deltaPercentage; } else if (direction == PositionDirection.Short && sample.CandleColor == Common.CandleColor.Green) { result = Math.Abs(sample.Candle.Close - sample.Candle.High) / Math.Abs(sample.Candle.Low - sample.Candle.High) > deltaPercentage; } else if (direction == PositionDirection.Short && sample.CandleColor == Common.CandleColor.Red) { result = Math.Abs(sample.Candle.Open - sample.Candle.High) / Math.Abs(sample.Candle.Low - sample.Candle.High) > deltaPercentage; } else { result = false; } return(result); }
public override double GetExit(PositionDirection pd, double entry, IEnumerable <Bar> dailyBarsFromNow, out DateTime exitTime) { var todayBar = dailyBarsFromNow.First(); exitTime = todayBar.Timestamp.AddHours(16); if (_StopLimit == null) { return(todayBar.Close); } if (pd == PositionDirection.Long) { Debug.Assert(_StopLimit < entry); if (todayBar.Low <= _StopLimit) { return(_StopLimit.Value); } } else if (pd == PositionDirection.Short) { Debug.Assert(_StopLimit > entry); if (todayBar.High >= _StopLimit) { return(_StopLimit.Value); } } return(todayBar.Close); }
private void OpenPosition(string currencyPair, double amount, double price, PositionDirection pd) { if (position_dic.ContainsKey(currencyPair)) { if (position_dic[currencyPair].Direction == PositionDirection.Long) { position_dic[currencyPair].LongNotional += amount; position_dic[currencyPair].NetNotional = position_dic[currencyPair].LongNotional; } else if (position_dic[currencyPair].Direction == PositionDirection.Short) { position_dic[currencyPair].ShortNotional += amount; position_dic[currencyPair].NetNotional = -position_dic[currencyPair].ShortNotional; } else { Position newPosition = new Position(pd, currencyPair, amount, price); position_dic[currencyPair] = newPosition; } position_dic[currencyPair].CostPrice = (position_dic[currencyPair].NetNotional * position_dic[currencyPair].CostPrice + amount * price) / (position_dic[currencyPair].NetNotional + amount); position_dic[currencyPair].CurrentPrice = price; } else { Position newPosition = new Position(pd, currencyPair, amount, price); position_dic.Add(currencyPair, newPosition); } }
public Deal([NotNull] string dealId, DateTime created, [NotNull] string accountId, [NotNull] string assetPairId, [NotNull] string openTradeId, OrderType openOrderType, decimal openOrderVolume, decimal?openOrderExpectedPrice, [NotNull] string closeTradeId, OrderType closeOrderType, decimal closeOrderVolume, decimal?closeOrderExpectedPrice, PositionDirection direction, decimal volume, OriginatorType originator, decimal openPrice, decimal openFxPrice, decimal closePrice, decimal closeFxPrice, decimal fpl, string additionalInfo, decimal pnlOfTheLastDay, string correlationId) { DealId = dealId ?? throw new ArgumentNullException(nameof(dealId)); Created = created; AccountId = accountId ?? throw new ArgumentNullException(nameof(accountId)); AssetPairId = assetPairId ?? throw new ArgumentNullException(nameof(assetPairId)); OpenTradeId = openTradeId ?? throw new ArgumentNullException(nameof(openTradeId)); OpenOrderType = openOrderType; OpenOrderVolume = openOrderVolume; OpenOrderExpectedPrice = openOrderExpectedPrice; CloseTradeId = closeTradeId ?? throw new ArgumentNullException(nameof(closeTradeId)); CloseOrderType = closeOrderType; CloseOrderVolume = closeOrderVolume; CloseOrderExpectedPrice = closeOrderExpectedPrice; Direction = direction; Volume = volume; Originator = originator; OpenPrice = openPrice; OpenFxPrice = openFxPrice; ClosePrice = closePrice; CloseFxPrice = closeFxPrice; Fpl = fpl; AdditionalInfo = additionalInfo; PnlOfTheLastDay = pnlOfTheLastDay; CorrelationId = correlationId; }
public void TestEnumToInt() { TradeActionBuySell enum1 = TradeActionBuySell.Buy; PositionDirection enum2 = PositionDirection.LongPosition; Assert.AreEqual(enum1.ToInt(), enum2.ToInt()); }
public Degree(PositionDirection dir, int deg, int min, int sec) { this.dir = dir; this.deg = deg; this.min = min; this.sec = sec; }
private void ClosePosition(PositionDirection direction, bool byStopLoss, DataSample sample) { Position.ClosePrice = sample.Candle.Close; Position.CloseTimestamp = sample.Candle.Timestamp; PlayedPositions.Add(Position); this.OnClosePosition(Position); Position = null; }
public override decimal StoplossPrice(Security security, DateTime AsOf, PositionDirection positionDirection, decimal referencePrice) { var atr = security.GetPriceBar(AsOf).AverageTrueRange(AtrPeriod); var stopDif = (atr * AtrStopMultiple); // Subtract diff from close for long trades, add for short trades decimal ret = (referencePrice - (stopDif * (int)positionDirection)); return(Math.Round(ret, 2)); }
private void OpenPosition(PositionDirection direction, DataSample sample, string ticker, decimal amount) { Position = new Position { OpenPrice = sample.Candle.Close, Direction = direction, OpenTimestamp = sample.Candle.Timestamp, Ticker = ticker, Amount = amount }; this.OnOpenPosition(Position); }
public TradeRecord(string symbol, PositionDirection direction, double entry, double stopLimit, double exit, double unstoppedExitPrice, DateTime entryTime, DateTime exitTime, long size, double profit, double accountValueBeforeTrade, double accountValueAfterTrade) { Symbol = symbol; PositionDirection = direction; Entry = entry; StopLimit = stopLimit; Exit = exit; UnstoppedExitPrice = unstoppedExitPrice; EntryTime = entryTime; ExitTime = exitTime; Size = size; Profit = profit; AccountValueBeforeTrade = accountValueBeforeTrade; AccountValueAfterTrade = accountValueAfterTrade; }
public override void Move(CharacterController controller) { switch (Axis) { case MoveAxis.X: PositionDirection.Set(speed, 0, 0); break; case MoveAxis.Y: PositionDirection.Set(0, speed, 0); break; case MoveAxis.Z: PositionDirection.Set(0, 0, speed); break; } controller.Move(PositionDirection * Time.deltaTime); }
public Position(PositionDirection direction_ ,string currencyPair_, double notional_, double price_) { this.CurrencyPair = currencyPair_; this.Direction = direction_; this.CostPrice = price_; this.RealizedNetProfit = 0; this.CurrentPrice = CostPrice; if (direction_ == PositionDirection.Long) { this.LongNotional = notional_; this.ShortNotional = 0; this.NetNotional = LongNotional; } else { this.LongNotional = 0; this.ShortNotional = notional_; this.NetNotional = ShortNotional; } }
/// <summary> /// Calculates the average basis cost of a sequence of trades /// </summary> /// <param name="trades">Ordered list of trades. Reordered in ascending date order upon entry.</param> /// <param name="direction">Calculates for a long position or short. Throws an exception if the first trade in the sequence does not match</param> /// <returns>The average cost per share of remaining shares at the end of the trade sequence. Throws an exception if the position ever flips long/short</returns> public static decimal AverageCost(this List <Trade> trades, PositionDirection direction) { // Order the trades trades = new List <Trade>(trades).OrderBy(x => x.TradeDate).ToList(); // Check direction if ((int)trades.FirstOrDefault().TradeActionBuySell != (int)direction) { throw new InvalidTradeForPositionException(); } // Iterate through the trades and compute average cost int sharesOpen = 0; decimal averageCost = 0; foreach (var trd in trades) { // Buy trades increase position and update average price // Sell trades reduce position if (trd.TradeActionBuySell.ToInt() == direction.ToInt()) { averageCost = ((averageCost * sharesOpen) + (trd.TotalCashImpactAbsolute)) / (sharesOpen += trd.Quantity); } else if (trd.TradeActionBuySell.ToInt() == -direction.ToInt()) { sharesOpen -= trd.Quantity; } // sharesOpen should always be positive, otherwise we have flipped long/short if (sharesOpen < 0) { throw new InvalidTradeForPositionException(); } } return(Math.Round(averageCost, 3)); }
public override void Move(CharacterController controller) { PositionDirection.Set(0, 0, speed * Input.GetAxis(vAxis)); rotateDirection.y = rotateSpeed * Input.GetAxis(hAxis); controller.transform.Rotate(rotateDirection); PositionDirection = controller.transform.TransformDirection(PositionDirection); if (controller.isGrounded) { PositionDirection.y = 0; jumpCount = 0; } if (jumpCount < jumpCountMax && Input.GetButtonDown("Jump")) { PositionDirection.y = jumpForce; jumpCount++; } PositionDirection.y -= gravity; controller.Move(PositionDirection * Time.deltaTime); }
/** * Ensure direction corresponds to longitude direction. */ private void CheckIsLongitude(PositionDirection dir) { if ((dir != PositionDirection.East) && (dir != PositionDirection.West)) { throw new ArgumentException( string.Format("Bad direction for longitude: {0}", dir)); } }
/** * Ensure direction corresponds to latitude direction. */ private void CheckIsLatitude(PositionDirection dir) { if ((dir != PositionDirection.North) && (dir != PositionDirection.South)) { throw new ArgumentException( string.Format("Bad direction for latitude: {0}", dir)); } }
/** * Normalize integer position to decimal value. */ public static int CollapsePositionUnits(PositionDirection dir, int deg, int min, int sec) { int multiplier = ( (dir == LATITUDE_NEG) || (dir == LONGITUDE_NEG) ? -1 : 1 ); return ( multiplier * ( Math.Abs(deg) * 3600 + ( Math.Abs(min) * 60) + ( Math.Abs(sec) ) )); }
public Position(PositionDirection ladir, int ladeg, int lamin, int lasec, PositionDirection lodir, int lodeg, int lomin, int losec) { latitude_int = CollapsePositionUnits(ladir, ladeg, lamin, lasec); longitude_int = CollapsePositionUnits(lodir, lodeg, lomin, losec); CheckIsLatitude(ladir); CheckIsLongitude(lodir); CheckLatitudeVal(latitude_int); CheckLongitudeVal(longitude_int); longitude_int = InvertLongitude(longitude_int); latitude = latitude_int / 3600.0; longitude = longitude_int / 3600.0; latitude = AdjustLatitude(latitude); }
/// <summary> /// Adjusts a players position with the given direction and amount. /// </summary> /// <param name="dir"></param> /// <param name="fAmount"></param> public static void AdjustPosition(PositionDirection dir, float fAmount) { // Cancel adjustment if we are detected and auto-disabled.. if (Player.IsDetectingPlayer && Player.AutoDisablePositionHacks) return; // Get the player pointer.. var mobPtr = Player.GetPointer(); if (mobPtr == IntPtr.Zero) return; // Read the warp struct pointer.. var warpPtr = new byte[4]; if (!Memory.Peek(Globals.Instance.CurrentProcess, mobPtr + Globals.Instance.GetOffset("MOB_WARP"), warpPtr)) return; // Read the players current position.. var tempPosition = new byte[4]; if (!Memory.Peek(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), tempPosition)) return; var fPositionX = BitConverter.ToSingle(tempPosition, 0); if (!Memory.Peek(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), tempPosition)) return; var fPositionY = BitConverter.ToSingle(tempPosition, 0); if (!Memory.Peek(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_1"), tempPosition)) return; var fPositionZ = BitConverter.ToSingle(tempPosition, 0); switch (dir) { case PositionDirection.N: { var adjustment = BitConverter.GetBytes(fPositionY + fAmount); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustment); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustment); break; } case PositionDirection.S: { var adjustment = BitConverter.GetBytes(fPositionY - fAmount); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustment); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustment); break; } case PositionDirection.E: { var adjustment = BitConverter.GetBytes(fPositionX + fAmount); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustment); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustment); break; } case PositionDirection.W: { var adjustment = BitConverter.GetBytes(fPositionX - fAmount); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustment); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustment); break; } case PositionDirection.NW: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX - fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY + fDistance); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.NE: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX + fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY + fDistance); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.SW: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX - fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY - fDistance); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.SE: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX + fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY - fDistance); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.Up: { var adjustment = BitConverter.GetBytes(fPositionZ - fAmount); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_1"), adjustment); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_2"), adjustment); break; } case PositionDirection.Down: { var adjustment = BitConverter.GetBytes(fPositionZ + fAmount); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_1"), adjustment); Memory.Poke(Globals.Instance.CurrentProcess, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_2"), adjustment); break; } } }
/// <summary> /// Adjusts a players position with the given direction and amount. /// </summary> /// <param name="dir"></param> /// <param name="fAmount"></param> public void AdjustPosition(PositionDirection dir, float fAmount) { // Cancel adjustment if we are detected and auto-disabled.. if (IsDetectingPlayer && AutoDisablePositionHacks) { return; } // Get the player pointer.. var mobPtr = GetPointer(); if (mobPtr == IntPtr.Zero) { return; } // Read the warp struct pointer.. var warpPtr = new byte[4]; if (!Memory.Peek(process, mobPtr + Globals.Instance.GetOffset("MOB_WARP"), warpPtr)) { return; } // Read the players current position.. var tempPosition = new byte[4]; if (!Memory.Peek(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), tempPosition)) { return; } var fPositionX = BitConverter.ToSingle(tempPosition, 0); if (!Memory.Peek(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), tempPosition)) { return; } var fPositionY = BitConverter.ToSingle(tempPosition, 0); if (!Memory.Peek(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_1"), tempPosition)) { return; } var fPositionZ = BitConverter.ToSingle(tempPosition, 0); switch (dir) { case PositionDirection.N: { var adjustment = BitConverter.GetBytes(fPositionY + fAmount); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustment); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustment); break; } case PositionDirection.S: { var adjustment = BitConverter.GetBytes(fPositionY - fAmount); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustment); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustment); break; } case PositionDirection.E: { var adjustment = BitConverter.GetBytes(fPositionX + fAmount); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustment); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustment); break; } case PositionDirection.W: { var adjustment = BitConverter.GetBytes(fPositionX - fAmount); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustment); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustment); break; } case PositionDirection.NW: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX - fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY + fDistance); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.NE: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX + fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY + fDistance); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.SW: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX - fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY - fDistance); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.SE: { var fDistance = ((int)Math.Floor(fAmount % 2) == 0) ? fAmount / 2 : fAmount / 2 + 1; var adjustmentX = BitConverter.GetBytes(fPositionX + fDistance); var adjustmentY = BitConverter.GetBytes(fPositionY - fDistance); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_1"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSX_2"), adjustmentX); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_1"), adjustmentY); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSY_2"), adjustmentY); break; } case PositionDirection.Up: { var adjustment = BitConverter.GetBytes(fPositionZ - fAmount); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_1"), adjustment); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_2"), adjustment); break; } case PositionDirection.Down: { var adjustment = BitConverter.GetBytes(fPositionZ + fAmount); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_1"), adjustment); Memory.Poke(process, (IntPtr)BitConverter.ToInt32(warpPtr, 0) + Globals.Instance.GetOffset("WARP_POSZ_2"), adjustment); break; } } }
public static ExtremumArea GetLastExtremumForPriceBeforeSample(IList <ExtremumArea> extremums, DataSample sample, decimal price, PositionDirection direction) { return(extremums.LastOrDefault(m => m.CurrentExtremum.Candle.Timestamp < sample.Candle.Timestamp && direction == PositionDirection.Long ? m.CurrentExtremum.Candle.High < price : m.CurrentExtremum.Candle.Low < price)); }
public abstract decimal StoplossPrice(Security security, DateTime AsOf, PositionDirection positionDirection, decimal referencePrice);
public abstract double GetExit(PositionDirection pd, double entry, IEnumerable <Bar> dailyBarsFromNow, out DateTime exitTime);
public Position(string currencyPair_) { this.Direction = PositionDirection.None; this.CurrencyPair = currencyPair_; this.LongNotional = this.NetNotional = this.ShortNotional = 0; }