How do I repeat a Raise Stop Loss statement? I understand the SetTrailStop() will do the trick but:
1. I'm using a SetStopLoss() order for the entry (@ -6 ticks from entry)
2. You can't use a both a SetTrailStop() & SetStopLoss together &
3. I'm trying to raise the initial SetStopLoss() at 6 ticks, then raise it to: 1 tick, then 5 ticks, then change the code to repeat by 5 ticks instead of adding unnecessary lines of codes every 5 tick as example below
- Unless I change the code to a SetTrailStop?
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
// Set stop loss to x point in case of entry reversals
SetStopLoss("LongEntry", CalculationMode.Ticks, 6, false);
}
else if (Position.MarketPosition == MarketPosition.Long)
{
// if price is over entry by 5 ticks (1.25 points), raise Stop Loss to 1 tick
if (Close[0] >= Position.AveragePrice + (5 * TickSize))
{
SetStopLoss("LongEntry", CalculationMode.Ticks, -1, false);
}
// if price is over entry by 9 ticks (2.25 points), raise Stop Loss to 1.25 points (5 ticks)
if (Close[0] >= Position.AveragePrice + (9 * TickSize))
// I imagine this is where you change it to a SetTrailStop? But then how do you repeat the code that's based on the 9 tick rule?
{
SetStopLoss("LongEntry", CalculationMode.Ticks, -5, false);
}
}
// First Statement - Going Long
if (CrossAbove(EMA1, SMA1, 1))
{
// Enter Long
EnterLong(Convert.ToInt32(DefaultQuantity), "LongEntry");
}
Question 2.
In addition to the code above, I want the available option to exit if price is >= from entry of 5 ticks (So price has the option of either exiting by the stop loss or a Crossunder)
I know this code doesn't compile correctly, but to further explain what I'm trying to accomplish
// Something that combines these statements together
if (Close[0] >= Position.AveragePrice, EnterLong("LongEntry");
if (Close[0] >= Position.AveragePrice + (5 * TickSize))
{
// If the Crossunder appears when price is over entry by 5+ ticks, allow it
if (CrossBelow(EMA1, SMA1, 1)) = true;
{
ExitLong(Convert.ToInt32(DefaultQuantity), "LongEntry");
}
}
Thanks in advance.

Comment