bave.rowe28
bave.rowe28's avatar

Info

Username:bave.rowe28
Name:bave.rowe28
Member since: 23 Jul 2020

About

None

Signature

None

Last comments

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
EMA┬┤s cross Bot
  1
  0
  332
free  28 Oct 2020
A coding modification is required, i hope someone could assist in doing tow things:  changing the simple SL to trailing SL. adding trading hours parameter ( trading can be like between two fixed hours ) I am using a cross of two EMA ( fast and medium)  with a condition of being above or below the major EMA ( like 200 or so - here it is named as slow) this bot gave me great result while back testing it, looking into it.  an example of a good back test results is:  GBPUSD:  timeframe: 15 minutes  Slow period: 190 Medium:50 fast:14 SL:70 TP: 105   Note: This is a modified version by me on the bot done by https://ctrader.com/forum/cbot-support/10910 all credit goes to the original bot.    following is the code ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo {     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]     public class EMACross_RSI : Robot     {         [Parameter("Source")]         public DataSeries SourceSeries { get; set; }         [Parameter("Label", DefaultValue = "EMA")]         public string label { get; set; }         [Parameter("Slow Periods", DefaultValue = 30)]         public int SlowPeriods { get; set; }         [Parameter("Medium Periods", DefaultValue = 12)]         public int MediumPeriods { get; set; }         [Parameter("Fast Periods", DefaultValue = 5)]         public int FastPeriods { get; set; }         [Parameter("Stop Loss", DefaultValue = 10)]         public int SL { get; set; }         [Parameter("Take Profit", DefaultValue = 10)]         public double TP { get; set; }         [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]         public double Quantity { get; set; }         private ExponentialMovingAverage slowMa;         private ExponentialMovingAverage mediumMa;         private ExponentialMovingAverage fastMa;         protected override void OnStart()         {             fastMa = Indicators.ExponentialMovingAverage(SourceSeries, FastPeriods);             mediumMa = Indicators.ExponentialMovingAverage(SourceSeries, MediumPeriods);             slowMa = Indicators.ExponentialMovingAverage(SourceSeries, SlowPeriods);         }         protected override void OnBar()         {             int index = MarketSeries.OpenTime.Count - 2;             var longPosition = Positions.Find(label, SymbolName, TradeType.Buy);             var shortPosition = Positions.Find(label, SymbolName, TradeType.Sell);             if ((fastMa.Result[index] > slowMa.Result[index]) && (mediumMa.Result[index] > slowMa.Result[index]) && (fastMa.Result[index - 1] < mediumMa.Result[index - 1]) && longPosition == null)             {                 if (longPosition != null)                     ClosePosition(longPosition);                 ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, SL, TP);             }             else if ((fastMa.Result[index] < slowMa.Result[index]) && (mediumMa.Result[index] < slowMa.Result[index]) && (fastMa.Result[index - 1] > mediumMa.Result[index - 1]) && shortPosition == null)             {                 if (shortPosition != null)                     ClosePosition(shortPosition);                 ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, SL, TP);             }         }         private long VolumeInUnits         {             get { return Symbol.QuantityToVolume(Quantity); }         }     } }