Profile Picture

BB cross

Posted By lfrisch 5 Years Ago
Message
Posted Tuesday July 24 2012

Hi

I am new to RE and am looking to create a simple trading system.

when last price (real time) crosses above (daily) upper Bollinger band 14 (standard deviation 1) go short at market.

when last price (real time) crosses below the (daily) lower Bollinger band 14 (standard deviation 1) go long at market.

Thanks very much,
Posted Thursday July 26 2012
This should get you started.  Note that there is no position management.  Here is the meat of the system.  I've attached the project as well if you find the code useful and want to continue building.  Also note this is not tested.

public class MySymbolScript : MySymbolScriptBase

{

      BollingerBandUpper bbu;

      BollingerBandLower bbl;

     

      public override void Startup()

      {

            // Perform initialization here.

            bbu = new BollingerBandUpper(14, 1);

            bbl = new BollingerBandLower(14, 1);

      }

 

      public override void NewTick(BarData partialBar, TickData tick)

      {

            if (double.IsNaN(bbu.Current) || double.IsNaN(bbl.Current))

            {

                  // not enough bars for bollinger calculation yet.

                  return;

            }

           

            if (tick.price > bbu.Current)

            {

                  OpenPosition(PositionType.Short, OrderType.Market);

            }

           

            if (tick.price < bbl.Current)

            {

                  OpenPosition(PositionType.Long, OrderType.Market);

            }

      }

}


Attachments
BBSample.zip (161 views, 2.00 KB)
Posted Monday August 06 2012
You should also check if the tick is a trade tick, ie:

if (tick.tickType != TickType.Trade)
{
//   Not a trade tick
return;
}

Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems