The strategy logic is quite simple: Enter the market if a custom indicator holds true, and exit after 10 bars (or stop loss at 10%)
However, I found some orders entered the market even the indicator is false (Please refer to screen cap)
In the screen cap, the green box denoted a correct order: indicator (shown as small blue triangle) holds true and entering the market
the red box denoted a wrong order: indicator is false but still entered the market.
Both custom indicator and strategy code is attached below.
Any idea please ?
------------------------------------
public class MyCustomStrategy1103 : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#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()
{
SetStopLoss("", CalculationMode.Percent, 0.1, true);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (AAALowDownBuy(1.75, 1.75).Plot0[0] == 1)
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (BarsSinceEntry() == 10)
{
ExitLong("", "");
}
}
#region Properties
#endregion
}
-------custom indicator--------------
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
if (CurrentBar < 10) return;
if (Low[0] < Low[1] && Low[1] < Low[2] && Low[2] < Low[3] && (Low[2] - Low[0])/Low[2]>= percentage1/100 && (Low[3] - Low[1])/Low[3]>= percentage2/100 && Low[0] < MIN(Low,5)[1]){
Plot0.Set(1);
}
}
Comment