The strategy only had 1 entry order but no exit orders were issued. Much appreciated if someone is able to help me to correct the code:
and here is the quote manager setting:
Price Scale: 1/100000
Min. Movement: 5
Big Point Value: 1
Many thanks!
Code: Select all
Inputs:
BollingerPrice( Close ),
CurrentPrice( Close ),
Length( 20 ),
NumDevsUp( 2 ),
NumDevsDn( -2 ),
TradeAmt(10000),
Threshold (0.0005);
variables:
MidLine ( 0 ),
var0 ( 0 ),
LowerBand ( 0 ),
UpperBand ( 0 ),
UpperPriceThresh ( 0 ),
LowerPriceThresh ( 0 );
{Calculating Bollinger Band}
MidLine = AverageFC( BollingerPrice, Length ) ;
var0 = StandardDev( BollingerPrice, Length, 1) ;
UpperBand = MidLine + NumDevsUp * var0 ;
LowerBand = MidLine + NumDevsDn * var0 ;
{Entry Conditions}
UpperPriceThresh = UpperBand + Threshold; {UpperBand + 5 pips}
LowerPriceThresh = LowerBand - Threshold; {LowerBand - 5 pips}
Condition1 = CurrentPrice < LowerPriceThresh;
Condition2 = CurrentPrice > UpperPriceThresh;
{Long Entry}
if marketposition = 0 and condition1 then
buy TradeAmt contract next bar at market;
{Exit Long}
if marketposition > 0 and CurrentPrice = MidLine then
sell all contract next bar at market;
{Short Entry}
if marketposition = 0 and condition2 then
sellshort TradeAmt contract next bar at market;
{Exit Short}
if marketposition < 0 and CurrentPrice = MidLine then
buytocover all contract next bar at market;