Information
Username: | fouadmail |
Member since: | 21 Dec 2016 |
Last login: | 21 Dec 2016 |
Status: | Active |
Activity
Where | Created | Comments |
---|---|---|
Algorithms | 0 | 3 |
Forum Topics | 0 | 0 |
Jobs | 0 | 0 |
Last Algorithm Comments
Great Indicator ! Thank you
However, cannot get it to work in the tester using my cBot ...
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 RenkoBot : Robot
{
[Parameter("RenkoPips", DefaultValue = 10, MinValue = 2, Step = 2)]
public double RenkoPips { get; set; }
[Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
private Renko mr_indi;
protected override void OnStart()
{
mr_indi = Indicators.GetIndicator<Renko>(RenkoPips, 100, 3, "SeaGreen", "Tomato");
}
protected override void OnTick()
{
var longPosition = Positions.Find("Renko", Symbol, TradeType.Buy);
var shortPosition = Positions.Find("Renko", Symbol, TradeType.Sell);
bool lastTwoBarsBullish = mr_indi.Open.Last(1) < mr_indi.Close.Last(1);
bool lastTwoBarsBearish = mr_indi.Open.Last(1) > mr_indi.Close.Last(1);
if (lastTwoBarsBullish && longPosition == null)
{
if (shortPosition != null)
ClosePosition(shortPosition);
ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "Renko");
}
else if (lastTwoBarsBearish && shortPosition == null)
{
if (longPosition != null)
ClosePosition(longPosition);
ExecuteMarketOrder(TradeType.Sell, Symbol, 10000, "Renko");
}
}
}
}
A very valuable job, thank you!
It Repaints ?