Twin peaks signals
A buy (sell) signal called the Twin Peaks buy (sell) signal is generated when the histogram is lower (higher) than the zero line, and the last indicator's bottom is higher (last indicator's top is lower) than the preceding one. Between these two bottoms (tops) the histogram can never be higher (lower) than zero:
The Awesome Oscillator Twin Peaks signal
The Twin Peaks buy signal is the only buy signal that is created below the zero line. Similarly, the Twin Peaks sell signal is the only sell signal that is created above the zero line.
Place a Buy Stop (Sell Stop) one tick higher than the top (lower than the bottom) of the signal bar. In the case of a buy signal, histogram “C” bar (a signal one) is always green, otherwise it is red.
Never buy on a red histogram bar and never sell on a green one. If an “unfriendly” histogram bar occurs before the execution of a pending order, which was placed in the direction of the Awesome Oscillator signal, the signal has to be ignored and the order has to be deleted.
================================================== =======
PLEASE correct me if my code is wrong;
To create this in NinjaTrader using the bwAO indicator posted elsewhere on this forum,
protected override void Initialize()
{
Add(bwAO());
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set BUY -- LastBar Red, CurrentBar Green, Value Below 0
if ( bwAO().AOValue[0] < BuyBelow && bwAO().AONeg[1] < 0 && bwAO().AOPos[0] < 0)
{
EnterLong(LotSize, "");
}
if ( bwAO().AOValue[0] > SellAbove && bwAO().AOPos[1] > 0 && bwAO().AONeg[0] > 0 )
{
ExitLong();
}
}
SELL when Green switches to Red above SellAbove (double)
One problem I have had is that the code above arbitrarily sells at the zero line. This may be due to the code in the indicator which states;
if(FirstTickOfBar)
ao1=ao;
AOValue.Set(ao);
1. is the code above correct for buy and sell (positive and negative) ?
2. how do I avoid selling prematurely at the zero line ? (I tried adding: && bwAO().AOValue[0] != 0 to the Sell Condition)

Comment