Basic Help Please
Basic Help Please
25 Apr 2018, 19:29
Hi Guys, sorry if this is ridiculouly easy but we all have to start somewhere.
I am simply trying to place the bollinger band indicator straight from the API into cAlgo. Which is the quickest and easiest way to do so?
I am then looking for a bit of a nudge in the right direction on how to code - 'when the bb's top and bottom band >= 10pip then it can trade, breakout of bottom = buy, breakout top = sell'
All advice will be taken on board and thanks
Replies
alexanderearle16@googlemail.com
26 Apr 2018, 21:30
RE:
Panagiotis Charalampous said:
Hi Alexander,
See below an example of how to initialize a Bollinger Bands indicator in cAlgo and check the difference between the Top and Bottom bands
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } BollingerBands _bb; protected override void OnStart() { _bb = Indicators.BollingerBands(MarketSeries.Close, 20, 2, MovingAverageType.Simple); } protected override void OnTick() { if ((_bb.Top.LastValue - _bb.Bottom.LastValue) > Symbol.PipSize * 10) { // Trade... } } protected override void OnStop() { // Put your deinitialization logic here } } }Let me know if this helps,
Best Regards,
Panagiotis
Thank you very much to go to that extent to help me, it was a great help. I have one more problem that I am now encountering, would it be possible to get your email adress to pass it on?
Alexander
@alexanderearle16@googlemail.com
alexanderearle16@googlemail.com
26 Apr 2018, 22:41
RE: RE:
alexanderearle16@googlemail.com said:
Panagiotis Charalampous said:
Hi Alexander,
See below an example of how to initialize a Bollinger Bands indicator in cAlgo and check the difference between the Top and Bottom bands
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } BollingerBands _bb; protected override void OnStart() { _bb = Indicators.BollingerBands(MarketSeries.Close, 20, 2, MovingAverageType.Simple); } protected override void OnTick() { if ((_bb.Top.LastValue - _bb.Bottom.LastValue) > Symbol.PipSize * 10) { // Trade... } } protected override void OnStop() { // Put your deinitialization logic here } } }Let me know if this helps,
Best Regards,
Panagiotis
Thank you very much to go to that extent to help me, it was a great help. I have one more problem that I am now encountering, would it be possible to get your email adress to pass it on?
Alexander
Sorry, I should've added this...
[Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } BollingerBands _bb; [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)] public double Quantity { get; set; } [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 1)] public int StopLossInPips { get; set; } [Parameter("Take Profit (pips)", DefaultValue = 40, MinValue = 1)] public int TakeProfitInPips { get; set; } public double Ask { get; set; } public double Bid { get; set; } #region on start up of bot protected override void OnStart() { _bb = Indicators.BollingerBands(MarketSeries.Close, 20, 2, MovingAverageType.Simple); } #endregion #region on every change in price protected override void OnTick() { if ((_bb.Top.LastValue - _bb.Bottom.LastValue) >= Symbol.PipSize * 10) { // Trade... if (Symbol.Bid > _bb.Top) { ExecuteMarketOrder(TradeType.Sell, Symbol, Quantity, label, StopLossInPips, TakeProfitInPips); } else (Symbol.Ask < _bb.Bottom) { ExecuteMarketOrder(TradeType.Buy, Symbol, Quantity, label, StopLossInPips, TakeProfitInPips); }
@alexanderearle16@googlemail.com
PanagiotisCharalampous
26 Apr 2018, 12:04
Hi Alexander,
See below an example of how to initialize a Bollinger Bands indicator in cAlgo and check the difference between the Top and Bottom bands
Let me know if this helps,
Best Regards,
Panagiotis
@PanagiotisCharalampous