I am just learning ninjascript and only understand the very "VERY" basics around it. I am hoping you can all help me.
I am trying to automate this simple strategy that enters trades on pivots i.e if the PP is touched and does not break through, i.e falling for two bars then enter short.
If it touches and brakes through 2 bars ago enter long. And the same for s1,s2,s3,r1,r2,r3.
I am trying to avoid entry when the price is bumping around the pivot, I am not sure if
I am also having an issue where the strategy disables itself and says the orders have been rejected, could anyone explain why so I can fix it?
Thank you.
protected override void OnBarUpdate()
{
//
{
// Once the price is greater than entry price by 20 ticks, set stop loss to BE + 5
if (GetCurrentBid() > Position.AvgPrice + 20 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 5 * TickSize);
}
// Once the price is less than entry price by 12 ticks, set stop loss to BE + 5
if (GetCurrentBid() Close[barsAgoCheck + 2]));
{
EnterLong(2, "PP Long");
}
// Condition set 2
if (CrossBelow(Close, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP, 1) && (Close[barsAgoCheck] Close[barsAgoCheck + 2]));