Description
By ForexCove. Ride the trend at the earliest moment. Combine slow MA, with a tight 1 or 5 brick Renko brick for best results.
This robot is a free module from our upcoming advanced Renko trading algo, which is slated for release Q2 2020. We have found that combining a slow moving average, with small renko bricks, can generate very interesting results. As always, for any trend trading algo, go for currency pairs that historically have been most likely to trend.
******************************
JUST ANNOUNCED OUR ADAPTIVE GRID BLAZER FOREX ROBOT - INTRO OFFER - LEARN MORE HERE
******************************
MA Crossing Renko Trading logic
When Renko brick closes above MA, open buy position
When Renko brick closes below MA, open sell position
When fixed TP is disabled, the bot will hold position until brick closes on opposite side of MA. This free module also allows for trailing SL.
Suggested settings
MA: 800 - 1200
Renko size: 1 or 5
Snapshots 01 EURUSD
Snapshots 02 EURUSD
Be sure to visit ForexCove for free downloads and discounts on commercially available Forex Trading Algos.
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 MA_Crossing_cBot : Robot
{
[Parameter(DefaultValue = "MA_Crossing_Renko_cBot")]
public string cBotLabel { get; set; }
[Parameter("Currency pair", DefaultValue = "EURUSD")]
public string TradeSymbol { get; set; }
[Parameter("Lot Size", DefaultValue = 0.1, MinValue = 0.01, Step = 0.01)]
public double LotSize { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MAType { get; set; }
[Parameter("MA Period", DefaultValue = 14)]
public int MAPeriod { get; set; }
[Parameter("Signal candle,in bars", DefaultValue = 1, MinValue = 0)]
public int SignalCandle { get; set; }
[Parameter("Fixed TP", DefaultValue = false)]
public bool UseTP { get; set; }
[Parameter("TP Level", DefaultValue = 40.0)]
public double TakeProfit { get; set; }
[Parameter("TrailingStop", DefaultValue = false)]
public bool UseTS { get; set; }
[Parameter("Trailing Trigger", DefaultValue = 15.0)]
public double TrailingTrigger { get; set; }
[Parameter("Trailing Pips", DefaultValue = 4.0)]
public double TrailingPips { get; set; }
private MovingAverage MA;
protected override void OnStart()
{
//check symbol
Symbol CurrentSymbol = Symbols.GetSymbol(TradeSymbol);
if (CurrentSymbol == null)
{
Print("Currency pair is not supported,please check!");
OnStop();
}
MA = Indicators.MovingAverage(MarketSeries.Close, MAPeriod, MAType);
}
protected override void OnBar()
{
if (MA.Result.Last(SignalCandle) < MarketSeries.Close.Last(SignalCandle) && MA.Result.Last(SignalCandle) > MarketSeries.Low.Last(SignalCandle) && Positions.FindAll(cBotLabel, TradeSymbol, TradeType.Buy).Length == 0)
{
ClosePosition(TradeType.Sell);
OpenMarketOrder(TradeType.Buy, TradeSymbol, LotSize);
}
else if (MA.Result.Last(SignalCandle) > MarketSeries.Close.Last(SignalCandle) && MA.Result.Last(SignalCandle) < MarketSeries.High.Last(SignalCandle) && Positions.FindAll(cBotLabel, TradeSymbol, TradeType.Sell).Length == 0)
{
ClosePosition(TradeType.Buy);
OpenMarketOrder(TradeType.Sell, TradeSymbol, LotSize);
}
}
protected override void OnTick()
{
if (UseTS == true && Positions.FindAll(cBotLabel, TradeSymbol).Length > 0)
DoTrailingStop();
}
private void ClosePosition(TradeType tradeType)
{
foreach (var position in Positions.FindAll(cBotLabel, TradeSymbol, tradeType))
{
var result = ClosePosition(position);
if (!result.IsSuccessful)
{
Print("Closing market order error: {0}", result.Error);
OnStop();
}
}
}
private void OpenMarketOrder(TradeType tradeType, string strSymbol, double dLots)
{
var volumeInUnits = Symbol.QuantityToVolumeInUnits(dLots);
volumeInUnits = Symbol.NormalizeVolumeInUnits(volumeInUnits, RoundingMode.Down);
double TP_in_pips = 0.0;
if (UseTP == true)
TP_in_pips = TakeProfit;
var result = ExecuteMarketOrder(tradeType, strSymbol, volumeInUnits, cBotLabel, 0, TP_in_pips);
if (!result.IsSuccessful)
{
Print("Execute Market Order Error: {0}", result.Error.Value);
OnStop();
}
}
private void DoTrailingStop()
{
var cBotPositions = Positions.FindAll(cBotLabel, TradeSymbol);
foreach (var position in cBotPositions)
{
if (position.TradeType == TradeType.Buy && position.Pips >= TrailingTrigger && position.HasTrailingStop == false)
{
var NewSL = position.TradeType == TradeType.Buy ? (position.EntryPrice + (TrailingPips * Symbol.PipSize)) : (position.EntryPrice - (TrailingPips * Symbol.PipSize));
ModifyPosition(position, NewSL, position.TakeProfit, true);
}
}
}
protected override void OnStop()
{
}
}
}
ctid1731325
Joined on 10.01.2020 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: MA_Crossing_Renko_cBot.algo
- Rating: 5
- Installs: 3461
- Modified: 13/10/2021 09:54
Comments
Olá
Tenho testado o robô, mas as estradas são bastante atrasadas em relação a indicação da média, (uso Hull), e por não ter SL não há banca que aguente. Pode melhorar isso, por favor? Obrigado.
Hello
I have tested the robot, but the roads are quite delayed in relation to the average indication, (I use Hull), and because there is no SL there is no bank that can handle it. Can you improve this, please? Thank you.
hello! currently i operate with a renko candles strategy that i have developed myself over the last year, but i would like to try to implement it in a robot but i don't know how to program it well. Write to me if you are interested and I will email you the strategy.
I like this robot. Please also add a standard SL function
I am backtesting it. Looks nice. tks
Hi,
Is there are limitation on the number trades taken by this cbot?
I tried a 24 hour test on this and it stopped after 10 losses in a row where it met the MA line in congestion!
Thanks
O