I am a beginner in programming and have several days to bother with software lines.
If you look at my code I have problems breakeven stop loss.
I tried three different ways and do not succeed. Can you tell me what I'm doing wrong.
Im using Renko BAR Candlestick
1.Example:
if (Close [0]> Position.AvgPrice + 6 * TickSize)
(
SetStopLoss (CalculationMode.Price, Position.AvgPrice);
)
2.Example
if (Close [0] == Position.AvgPrice + (6 * TickSize))
(
SetStopLoss ("", CalculationMode.Price, Position.AvgPrice, false);
)
3 my whole code :
protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, TP);
SetStopLoss("", CalculationMode.Ticks, SL, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossBelow(RSI(14, 3).Avg, 60, 1))
{
DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.DimGray);
EnterLong(1, "");
}
// Once the price is greater than entry price +6 ticks, set stop loss to breakeven
//Here I have the problem............????
if (Close[0] == Position.AvgPrice + (6 * TickSize))
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
}
Comment