The Bollinger Bandit uses one standard deviation above the 50-day moving average as a potential long entry and one standard deviation below the 50-day moving average as a potential short entry.
The longer that we are in a trade, the easier it is to exit the market with a profit. We keep decrementing the number of days in our moving average calculation until we reach ten. From that point on, we do not decrement. There is one more element to our exit technique: the moving average must be below the upper band if we are long and above the lower band if we are short.
This element is to prevent the system from going back into the same trade that we just liquidated. If we hadn’t used this additional condition and we were long and the moving average was above the upper band, the long entry criteria would still be set up and a long trade would be initiated.
One more test must be passed before we initiate a position; the close of today must be greater than the close of 30 days ago for a long position and the close of today must be less than the close of 30 days ago for a short position. This additional requirement is a trend filter. We only want to go long in an uptrend and short in a downtrend.
This system is longer term in nature, so we will use 50 days in our calculations.
Could someone please translate into PRC code ? Thanks
———————————-
Bollinger Bandit Pseudocode
LiqDay is initially set to 50
upBand = Average(Close,50) + StdDev(Close,50) *1.25 dnBand = Average(Close,50) – StdDev(Close,50) *1.25 rocCalc = Close of today – Close of thirty days ago
Set liqLength to 50
If rocCalc is positive, a long position will be initiated when today’s market action >= upBand
If rocCalc is negative, a short position will be initiated when today’s market action <= dnBand
liqPoint = Average(Close, 50)
If liqPoint is above the upBand, we will liquidate a long position if today’s market action <= liqPoint If liqPoint is below the dnBand, we will liquidate a short position if today’s market action >= liqPoint
If we are not stopped out today, then liqLength = liqLength – 1 If we are stopped out today, then reset liqLength to fifty
—————————————-BELOW -TO TRANSLATE——————————————————–
Bollinger Bandit Program
{Uses Bollinger Bands and Rate of change to determine entry points. A trailing stop that is proportional with the amount of time a trade is on is used as the exit technique.}
Inputs: bollingerLengths(50),liqLength(50),rocCalcLength(30); Vars: upBand(0),dnBand(0),liqDays(50),rocCalc(0);
upBand = BollingerBand(Close,bollingerLengths,1.25); dnBand = BollingerBand(Close,bollingerLengths,-1.25);
rocCalc = Close – Close[rocCalcLength-1]; {remember to subtract 1} if(MarketPosition <> 1 and rocCalc > 0) then Buy(“BanditBuy”)tomorrow upBand
stop;
if(MarketPosition <>-1 and rocCalc < 0) then SellShort(“BanditSell”) tomorrow dnBand stop;
if(MarketPosition = 0) then liqDays = liqLength; if(MarketPosition <> 0) then
begin
liqDays = liqDays – 1;
liqDays = MaxList(liqDays,10);
end;
if(MarketPosition = 1 and Average(Close,liqDays) < upBand) then Sell(“Long Liq”) tomorrow Average(Close,liqDays) stop; if(MarketPosition = -1 and Average(Close,liqDays) > dnBand) then BuyToCover(“Short Liq”) tomorrow Average(Close,liqDays) stop;
———————————-THANKS—————————————–