I'm a NT7 new user and developing a new strategy. Now, I'm facing a problem with stop loss order placements when I enter a position.
For example, in a long position, I want to set a stop loss order 2 ticks below the lowest low of last 3 bars [since today].
Here is a part of my script :
#region Variables
// User defined variables (add any user defined variables below)
private int stochaMin = 20; // Default setting for StochaMin
private int quantity = 1; // Valeur par Default setting for Quantity
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, 2);
}
else if(Position.MarketPosition == MarketPosition.Long)
{
if (Close[0]!=Low[0])
SetStopLoss("Long", CalculationMode.Ticks, MIN(Low,3)[0] - 1*TickSize,true);
//Buying condition
if (Close[0] < Bollinger(2, 14).Lower[0] && Stochastics(5, 14, 3).K[0] < stochaMin)
{
EnterLong(quantity, "Long");
}
...
I was told that I was wrong if I wrote that script. In your opinion, does that code work? Please, can anyone help me?
Thank you in advance!

Comment