Malchow (Meckl.)
Experience: Intermediate
Platform: NinjaTrader, TWS
Trading: Stocks
Posts: 17 since Mar 2011
Thanks Given: 15
Thanks Received: 0
|
Hallo,
in my strategy I am looking for a possibility to automatic change the stoploss on the last swinghigh or low. Do you have a code snippet für me?
My trail:
#region Variables
private IOrder _long_order = null;
private bool _long_sent = false;
private IOrder _short_order = null;
private bool _short_sent = false;
double swinghigh_value = 0;
double swinglow_value = 0;
protected override void OnBarUpdate()
{
// Condition set 1 (LONG)
if (ToTime(Time[0]) >= 80000 && ToTime(Time[0]) <= 220000
&& WMA(Weighted, 20)[0] > WMA(Weighted, 50)[0]
&& Low[0] > WMA(Weighted, 20)[0]
&& WMA(Weighted, 20)[0] > WMA(Weighted, 20)[4]
&& Close[0] > Swing(5).SwingHigh[0])
{
_long_order=EnterLong(DefaultQuantity, "Long");
}
// set swinglow_value:
swinglow_value = Swing(5).SwingLow[0];
// set the stop loss to swinglow_value:
SetStopLoss("Long", CalculationMode.Ticks, swinglow_value, false);
But nothing change ... Where is the error?
Thanks Blackburn
|