protected VFXExpression CalculateVolumeFactor(PositionMode positionMode, VFXExpression radius, VFXExpression thickness) { VFXExpression factor = VFXValue.Constant(0.0f); switch (positionMode) { case PositionMode.Surface: factor = VFXValue.Constant(0.0f); break; case PositionMode.Volume: factor = VFXValue.Constant(1.0f); break; case PositionMode.ThicknessAbsolute: case PositionMode.ThicknessRelative: { if (positionMode == PositionMode.ThicknessAbsolute) { thickness = thickness / radius; } factor = VFXOperatorUtility.Saturate(thickness); break; } } return(new VFXExpressionPow(VFXValue.Constant(1.0f) - factor, VFXValue.Constant(thicknessDimensions))); }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && adx.PlusDI() < adx.MinusDI()) || (position == PositionMode.Short && adx.PlusDI() > adx.MinusDI())) { Exit(); } }
private void OnEntrySignal(long sequence, PositionMode position) { if (SignalOpenPosition != null) { SignalOpenPosition(accountId, tickerType, position, dataFeeder.LastPrice.Close, dataFeeder.LastPrice.Close, dataFeeder.LastPrice); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if (signal.IsOutPosition) { Exit(); } }
public SignalDataItem(long sequence, DateTime closingBarTime, PositionMode position, DateTime signalTime) { this.sequence = sequence; this.closingBarTime = closingBarTime; this.position = position; this.signalTime = signalTime; }
public StrategyDataItem(long sequence, DateTime closingBarTime, PositionMode position, DateTime executionTime) { this.sequence = sequence; this.closingBarTime = closingBarTime; this.position = position; this.executionTime = executionTime; }
protected VFXExpression CalculateVolumeFactor(PositionMode positionMode, int radiusIndex, int thicknessIndex) { VFXExpression factor = VFXValue.Constant(0.0f); switch (positionMode) { case PositionMode.Surface: factor = VFXValue.Constant(0.0f); break; case PositionMode.Volume: factor = VFXValue.Constant(1.0f); break; case PositionMode.ThicknessAbsolute: case PositionMode.ThicknessRelative: { var thickness = inputSlots[thicknessIndex].GetExpression(); if (positionMode == PositionMode.ThicknessAbsolute) { var radius = inputSlots[radiusIndex][1].GetExpression(); thickness = thickness / radius; } factor = VFXOperatorUtility.Saturate(thickness); break; } } return(new VFXExpressionPow(VFXValue.Constant(1.0f) - factor, VFXValue.Constant(thicknessDimensions))); }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && psar.Direction() == -1) || (position == PositionMode.Short && psar.Direction() == 1)) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if (priceBar.LastItem.Low < bb.LowerBand() || priceBar.LastItem.High > bb.UpperBand()) { Exit(); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { PositionMode mode = (PositionMode)value; return(mode == PositionMode.UserDefined ? Visibility.Visible : Visibility.Collapsed); }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && CrossesBelow(stoch.PercentK(1), stoch.PercentK(), stoch.PercentD(1), stoch.PercentD())) || (position == PositionMode.Short && CrossesAbove(stoch.PercentK(1), stoch.PercentK(), stoch.PercentD(1), stoch.PercentD()))) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && (CrossesBelow(sma7.Value(1), sma7.Value(), sma14.Value(1), sma14.Value()) || CrossesBelow(sma7.Value(1), sma7.Value(), sma21.Value(1), sma21.Value())) || (position == PositionMode.Short && (CrossesAbove(sma7.Value(1), sma7.Value(), sma14.Value(1), sma14.Value()) || CrossesAbove(sma7.Value(1), sma7.Value(), sma21.Value(1), sma21.Value()))))) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && IsShortSetup(priceBar)) || (position == PositionMode.Short && IsLongSetup(priceBar))) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && rsi.Value() >= 70) || (position == PositionMode.Short && rsi.Value() <= 30)) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && ((CrossesBelow(ema5.Value(2), ema5.Value(1), ema10.Value(2), ema10.Value(1)) && ema10.Value() > ema5.Value()) || rsi.Value() < 50)) || (position == PositionMode.Short && ((CrossesAbove(ema5.Value(2), ema5.Value(1), ema10.Value(2), ema10.Value(1)) && ema10.Value() < ema5.Value()) || rsi.Value() > 50))) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && CrossesBelow(macd.MACDValue(1), macd.MACDValue(), macd.SignalLine(1), macd.SignalLine())) || (position == PositionMode.Short && CrossesAbove(macd.MACDValue(1), macd.MACDValue(), macd.SignalLine(1), macd.SignalLine()))) { Exit(); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && stoch.PercentD() >= 80) || (position == PositionMode.Short && stoch.PercentD() <= 20)) { Exit(); } }
private void OnEntryStrategy(IStrategy source, long sequence, PositionMode position) { UpdateStrategyCache(source.IdentityCode, source.BarType, sequence, position); if (EntryPosition != null) { EntryPosition(sequence, position); } }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if ((position == PositionMode.Long && (priceBar.LastItem.Close < sma28.Value() || priceBar.LastItem.Close <= stopLossPrice)) || (position == PositionMode.Short && (priceBar.LastItem.Close > sma28.Value() || priceBar.LastItem.Close >= stopLossPrice))) { lastPosition = position; Exit(); } }
public void Position_PositionModeTest() { PositionStyle target = new PositionStyle(); //Default PositionMode expected = PositionMode.Block; Assert.AreEqual(expected, target.PositionMode); //Set value expected = PositionMode.Absolute; PositionMode actual; target.PositionMode = expected; actual = target.PositionMode; Assert.AreEqual(expected, actual); // Change Value expected = PositionMode.Relative; target.PositionMode = expected; actual = target.PositionMode; Assert.AreEqual(expected, actual); //Remove value expected = PositionMode.Block; target.RemovePositionMode(); actual = target.PositionMode; Assert.AreEqual(expected, actual); // Check the X or Y setting to relative expected = PositionMode.Relative; target = new PositionStyle(); target.X = 20; actual = target.PositionMode; Assert.AreEqual(expected, actual); target.RemoveX(); target.Y = 40; actual = target.PositionMode; Assert.AreEqual(expected, actual); //set both target.X = 50; actual = target.PositionMode; Assert.AreEqual(expected, actual); //explicit override even if X or Y is set expected = PositionMode.Absolute; target.PositionMode = expected; actual = target.PositionMode; Assert.AreEqual(expected, actual); }
private void OnEntrySignal(ISignal source, long sequence, PositionMode position) { UpdateSignalCache(source.IdentityCode, source.BarType, sequence, position); if (EntrySignal != null) { EntrySignal(sequence, position); } }
protected void Enter(PositionMode position) { if (EnterPosition != null) { signalCounter++; EnterPosition(this, signalCounter, position); this.position = position; this.isInPosition = true; } }
public void PositionMode_ReadsCorrectValue() { var host = IntCodeComputer.FromCommaSeparated("1,0,4,0,3"); var sut = new PositionMode(); Assert.Equal(0, sut.ReadValue(0, host)); Assert.Equal(1, sut.ReadValue(1, host)); Assert.Equal(3, sut.ReadValue(2, host)); }
/// <summary> /// Creates a new PDFLayoutRegion. /// </summary> /// <param name="block"></param> /// <param name="columnindex"></param> /// <param name="contentbounds"></param> public PDFLayoutRegion(PDFLayoutBlock block, IPDFComponent owner, PDFRect contentbounds, int columnindex, HorizontalAlignment halign, VerticalAlignment valign, PositionMode mode) : base(block, owner) { this.UsedSize = PDFSize.Empty; this.ColumnIndex = columnindex; this.TotalBounds = contentbounds; this.HAlignment = halign; this.VAlignment = valign; this.PositionMode = mode; }
protected override void InPosition(PositionMode position, PriceBars priceBar, BarItemType barType) { if (priceBar.LastItem.Time >= new DateTime(2012, 8, 2, 4, 0, 0)) { } if ((position == PositionMode.Long && psar.Direction() == -1) || (position == PositionMode.Short && psar.Direction() == 1)) { Exit(); } }
/// <summary> /// Determines if the given value represents a valid state of this property. /// </summary> /// <param name="value">The state that should be used.</param> /// <returns>True if the state is valid, otherwise false.</returns> protected override Boolean IsValid(CSSValue value) { PositionMode mode; if (value is CSSIdentifierValue && modes.TryGetValue(((CSSIdentifierValue)value).Value, out mode)) _mode = mode; else if (value != CSSValue.Inherit) return false; return true; }
/// <summary> /// Determines if the given value represents a valid state of this property. /// </summary> /// <param name="value">The state that should be used.</param> /// <returns>True if the state is valid, otherwise false.</returns> protected override Boolean IsValid(CSSValue value) { PositionMode mode; if (modes.TryGetValue(value, out mode)) { _mode = mode; return(true); } return(false); }
public void WillSetYOffsetFromShortcut(string statedOffset, PositionMode expectedPositionMode, int expectedOffset) { var css = @" .LocalNavigation .TabOn,.LocalNavigation .TabOn:hover {{ background: url(""http://i3.social.microsoft.com/contentservice/1f22465a-498c-46f1-83d3-9dad00d8a950/subnav_on_technet.png"") no-repeat center {0}; }}"; var testable = new BackgroundImageClass(string.Format(css, statedOffset), "http://server/content/style.css"); Assert.Equal(expectedPositionMode, testable.YOffset.PositionMode); Assert.Equal(expectedOffset, expectedPositionMode == PositionMode.Direction ? (int)testable.YOffset.Direction : testable.YOffset.Offset); }
private void SolveWindowPosition(Gtk.Window parent) { int x, y, cw, ch, pw, ph, px, py; PositionMode wp = (ShellObject as Window).PositionMode; //if center parent and parent is null, center screen instead if (parent == null && wp == PositionMode.CenterParent) { wp = PositionMode.CenterScreen; } switch (wp) { case PositionMode.Manual: //HACK: we have to move the window to the position it already is for some stupid gtk-reason //an GetPosition doesnt work (in windows at least) int wx, wy, w, h, d; window.GdkWindow.GetGeometry(out wx, out wy, out w, out h, out d); Margin m = GetDecorationSize(); window.Move(wx - m.Left, wy - m.Top); return; //done already case PositionMode.CenterParent: parent.GetSize(out pw, out ph); parent.GetPosition(out px, out py); window.GetSize(out cw, out ch); var c = window.WindowPosition; x = px + pw / 2 - cw / 2; y = py + ph / 2 - ch / 2; window.Move(x, y); break; case PositionMode.CenterScreen: Gdk.Screen scr = window.Screen; // ?? Gdk.Screen.Default window.GetSize(out cw, out ch); x = scr.Width / 2 - cw / 2; y = scr.Height / 2 - ch / 2; window.Move(x, y); break; case PositionMode.MouseCursor: Gdk.Screen scr2 = window.Screen; scr2.Display.GetPointer(out x, out y); window.Move(x, y); break; default: throw new Exception("GtkSharp driver does not know how to position screen at " + wp.ToString()); } }
/// <summary> /// Overrides the base implementation to set the explict position mode before /// continuing on as normal /// </summary> /// <param name="comp"></param> /// <param name="full"></param> protected override void DoLayoutAChild(IPDFComponent comp, Styles.Style full) { //For each child if there is not an explict Absolute setting then //we should treat them as relative Styles.PositionStyle pos = full.Position; PositionMode mode = pos.PositionMode; if (mode != PositionMode.Absolute) { pos.PositionMode = PositionMode.Relative; } base.DoLayoutAChild(comp, full); }
public void WillSetSecondOffsetAsXOffsetWhenFirstOffsetIsBottom(string statedOffset, PositionMode expectedPositionMode, int expectedOffset) { var css = @" .LocalNavigation .TabOn,.LocalNavigation .TabOn:hover {{ background: url(""http://i3.social.microsoft.com/contentservice/1f22465a-498c-46f1-83d3-9dad00d8a950/subnav_on_technet.png"") no-repeat; background-position: bottom {0}; }}"; var testable = new BackgroundImageClass(string.Format(css, statedOffset), "http://server/content/style.css"); Assert.Equal(expectedPositionMode, testable.XOffset.PositionMode); Assert.Equal(expectedOffset, expectedPositionMode == PositionMode.Direction ? (int)testable.XOffset.Direction : testable.XOffset.Offset); }
public void PositionMode_WritesValue_ToCorrectAddress() { var host = IntCodeComputer.FromCommaSeparated("1,2,3,4"); var sut = new PositionMode(); sut.WriteValue(0, 96, host); sut.WriteValue(2, 42, host); Assert.Equal(1, host.Registers[0]); Assert.Equal(96, host.Registers[1]); Assert.Equal(3, host.Registers[2]); Assert.Equal(42, host.Registers[3]); }
internal CSSPositionProperty() : base(PropertyNames.Position) { _mode = modes["static"]; _inherited = false; }
public void WillSetFirstOffsetAsYOffsetFromShortcutWhenSecondOffsetIsRight(string statedOffset, PositionMode expectedPositionMode, int expectedOffset) { var css = @" .LocalNavigation .TabOn,.LocalNavigation .TabOn:hover {{ background: url(""http://i3.social.microsoft.com/contentservice/1f22465a-498c-46f1-83d3-9dad00d8a950/subnav_on_technet.png"") no-repeat {0} right; }}"; var testable = new BackgroundImageClass(string.Format(css, statedOffset), 0); Assert.Equal(expectedPositionMode, testable.YOffset.PositionMode); Assert.Equal(expectedOffset, expectedPositionMode == PositionMode.Direction ? (int)testable.YOffset.Direction : testable.YOffset.Offset); }