Anyway, the price value for a long profit target would then be LongEntry+(LongEntry-Stop Loss). Profit:Loss=1:1 Here is my code:
protected override void OnBarUpdate()
{
// Assign Long Stop Entry Price
double LongStopEntry=(SMA(5)[0]<Close[0]? SMA(5)[0]: Close[0]);
// Assign Short Stop Entry Price
double ShortStopEntry= (SMA(5)[0]>Close[0]? SMA(5)[0]: Close[0]);
// Assign Profit Targets
double LongProfitTarget=LongStopEntry+(LongStopEntry-MIN(Low, 10)[0]);
double ShortProfitTarget=ShortStopEntry-(MAX(High, 10)[0]-ShortStopEntry);
// Assign Stop Losses
double LongStopLoss=LongStopEntry-(LongProfitTarget-LongStopEntry);
double ShortStopLoss=ShortStopEntry+(ShortStopEntry-ShortProfitTarget);
SetProfitTarget("Enter LONG", CalculationMode.Price, LongProfitTarget);
SetProfitTarget("Enter SHORT", CalculationMode.Price, ShortProfitTarget);
My problem is that the profit target values don't calculate correctly at all when I backtest with no apparent pattern and I can't figure out why. It works for entries but not profit targets.
Do I need to declare a method in order for it to calculate? I can only go off what Help says.
Would be glad to hear your suggestions.
Comment