I am running a 1min strategy.
I simply want to enter long if the last primary 1min bar(High[0]) on current day crosses above the previous days high(Highs[1][0]).
I want to set the Profit target on Entry as ATR(20) Daily bars (ATR(BarsArray[1],20)[0])
I can plot the correct entry/exit/target levels via an Indicator but when I try to run the same code in a Strategy it gives me garbage.
Thanks for any assistance.
public class EnterOnPrevDailyHigh : Strategy
{
protected override void Initialize()
{
Add(PeriodType.Day, 1);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
// Ensure at least 50 Days lookback
if (CurrentBar < 72000) //50D*24Hrs*60min
return;
if (BarsInProgress != 0)
return;
double LongStopIn = Highs[1][0];
double LongTarget = LongStopIn + (ATR(BarsArray[1],20)[0]);
double LongStopLoss = LongStopIn - (ATR(BarsArray[1],20)[0]);
if ((High[0] > LongStopIn) && (Position.MarketPosition == MarketPosition.Flat))
{
EnterLong(1000, "Enter Long");
SetStopLoss(LongStopLoss);
SetProfitTarget(LongTarget);
}
}

Comment