sascha.dawe
    sascha.dawe's avatar

    Info

    Username:sascha.dawe
    Name:sascha.dawe
    Member since: 11 Feb 2019
    Country:Australia

    Favorite symbols:

    AUDUSD

    About

    trader, programmer, contact at sascha.coding@gmail.com

    Signature

    None

    Last comments

    @Gerbil M5 Scalper: Hi Zaknafein, Great work on this cbot. I have made a slight modification, so that when counting max positions, it only counts the open Gerbil positions. This allows you to open manual trades or run other cbots on the same account concurrently, if the max positions are set to one. I would like to work on this with you further. If you are interested, please contact me via my email account. 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.GMTStandardTime, AccessRights = AccessRights.None)]     public class Gerbil : Robot     {         [Parameter("Trade Start Hour", DefaultValue = 23, MinValue = 0, Step = 1)]         public int TradeStart { get; set; }         [Parameter("Trade End Hour", DefaultValue = 1, MinValue = 0, Step = 1)]         public int TradeEnd { get; set; }         [Parameter("Take Profit (Pips)", DefaultValue = 6, MinValue = 1, Step = 1)]         public int TakeProfit { get; set; }         [Parameter("Stop Loss (Pips)", DefaultValue = 150, MinValue = 1, Step = 1)]         public int StopLoss { get; set; }         [Parameter("Calculate Volume by Percentage?", DefaultValue = false)]         public bool RiskPercent { get; set; }         [Parameter("Quantity (%Risk or Lots)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]         public double Quantity { get; set; }         [Parameter("RSI Source")]         public DataSeries RSISource { get; set; }         [Parameter("RSI Period", DefaultValue = 7, MinValue = 1, Step = 1)]         public int RSIPeriods { get; set; }         [Parameter("RSI Overbought Level", DefaultValue = 80, MinValue = 1, Step = 1)]         public int RSIOverB { get; set; }         [Parameter("RSI Oversold Level", DefaultValue = 40, MinValue = 1, Step = 1)]         public int RSIOverS { get; set; }         [Parameter("ATR Periods", DefaultValue = 15, MinValue = 1, Step = 1)]         public int ATRPeriods { get; set; }         [Parameter("ATR From", DefaultValue = 10, MinValue = 1, Step = 1)]         public int ATRFrom { get; set; }         [Parameter("ATR To", DefaultValue = 100, MinValue = 1, Step = 1)]         public int ATRTo { get; set; }         [Parameter("Max Positions", DefaultValue = 1, MinValue = 1, Step = 1)]         public int MaxPos { get; set; }         [Parameter("Max DD Positions", DefaultValue = 0, MinValue = 0, Step = 1)]         public int MaxDDPos { get; set; }         [Parameter("KillHours", DefaultValue = 0, MinValue = 0, Step = 1)]         public int KillHours { get; set; }         private RelativeStrengthIndex rsi;         private AverageTrueRange atr;         private int DDPos = 0;         protected override void OnStart()         {             rsi = Indicators.RelativeStrengthIndex(RSISource, RSIPeriods);             atr = Indicators.AverageTrueRange(ATRPeriods, MovingAverageType.Simple);         }         protected override void OnBar()         {             if (Time.Hour >= TradeStart || Time.Hour < TradeEnd)             {                 var atrVal = atr.Result.LastValue * 100000;                 if (atrVal > ATRFrom && atrVal < ATRTo)                 {                     var positionsGerbil = Positions.FindAll("Gerbil", Symbol);                     if (positionsGerbil.Length < MaxPos)                     {                         if (rsi.Result.LastValue < RSIOverS)                         {                             Open(TradeType.Buy);                         }                         else if (rsi.Result.LastValue > RSIOverB)                         {                             Open(TradeType.Sell);                         }                     }                 }             }             if (KillHours != 0)             {                 foreach (var position in Positions.FindAll("Gerbil", Symbol))                 {                     if (Time > position.EntryTime.AddMinutes(KillHours * 60))                         ClosePosition(position);                 }             }         }         private void Open(TradeType tradeType)         {             //var position = Positions.Find("SampleRSI", Symbol, tradeType);             var volumeInUnits = CalculateVolume();             ExecuteMarketOrder(tradeType, Symbol, volumeInUnits, "Gerbil", StopLoss, TakeProfit);         }         double CalculateVolume()         {             if (!RiskPercent)             {                 return (Symbol.QuantityToVolumeInUnits(Quantity));             }             else             {                 // Calculate the total risk allowed per trade.                 double riskPerTrade = (Account.Balance * Quantity) / 100;                 double totalSLPipValue = (StopLoss + Symbol.Spread) * Symbol.PipValue;                 double calculatedVolume = riskPerTrade / totalSLPipValue;                 double normalizedCalculatedVolume = Symbol.NormalizeVolumeInUnits(calculatedVolume, RoundingMode.ToNearest);                 return normalizedCalculatedVolume;             }         }     } }
    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.

    No uploaded.