Cbot renko chart entry point
Cbot renko chart entry point
18 Jun 2021, 13:52
I built a ctrader bot that is working well but am unable to program it to enter trade at exactly the close of a brick or formation of a new one(am using renko chart).
Replies
danieleyube
06 Feb 2022, 19:59
Multiple Entry Bot
Whenever a trade move from the entry point +5 or -5pips it should enter a new trade, please help i don't know how to go about it.
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.EasternStandardTime, AccessRights = AccessRights.FullAccess)]
public class AUDJPY : Robot
{
[Parameter("Trade Size", DefaultValue = 1000, MinValue = 0.01)]
public double Size { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)]
public int SL { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)]
public int TP { get; set; }
protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 0, 10);
}
protected override void OnTick()
{
var position2 = Positions[0];
if (position2.EntryPrice - Symbol.Bid == -0.0005)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Size, SymbolName, 0, 10);
}
if (position2.EntryPrice - Symbol.Bid == 0.0005)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 0, 10);
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
@danieleyube
amusleh
07 Feb 2022, 08:56
Hi,
You can use Position Pips property to get the current Pips amount of Position, ex:
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.FullAccess)]
public class AUDJPY : Robot
{
[Parameter("Trade Size", DefaultValue = 1000, MinValue = 0.01)]
public double Size { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)]
public int SL { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)]
public int TP { get; set; }
protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 0, 10);
}
protected override void OnTick()
{
// It iterates over all positions
foreach (var position in Positions)
{
// if position is 5 pips in profit
if (position.Pips == 5)
{
// Do something here, ex: execute a new order
}
// if position is 5 pips in lose
else if (position.Pips == -5)
{
// Do something here, ex: execute a new order
}
}
}
}
}
@amusleh
danieleyube
07 Feb 2022, 10:26
RE:
amusleh said:
Hi,
You can use Position Pips property to get the current Pips amount of Position, ex:
using cAlgo.API; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.FullAccess)] public class AUDJPY : Robot { [Parameter("Trade Size", DefaultValue = 1000, MinValue = 0.01)] public double Size { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)] public int SL { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)] public int TP { get; set; } protected override void OnStart() { ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 0, 10); } protected override void OnTick() { // It iterates over all positions foreach (var position in Positions) { // if position is 5 pips in profit if (position.Pips == 5) { // Do something here, ex: execute a new order } // if position is 5 pips in lose else if (position.Pips == -5) { // Do something here, ex: execute a new order } } } } }
Thank you so much sir! I'll try it out and give you feedback.
@danieleyube
danieleyube
07 Feb 2022, 14:52
RE: RE:
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("Trade Size", DefaultValue = 1000, MinValue = 0.01)]
public double Size { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)]
public int SL { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)]
public int TP { get; set; }
protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 10, 10);
}
protected override void OnTick()
{
// It iterates over all positions
foreach (var position in Positions)
{
// if position is 5 pips in profit
if (Positions[0].Pips == 5)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Size, SymbolName, 0, 10);
}
// if position is 5 pips in lose
else if (Positions[0].Pips == -5)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 0, 10);
}
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
is anything Wrong with the above code?
@danieleyube
amusleh
08 Feb 2022, 08:36
RE: RE: RE:
danieleyube said:
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("Trade Size", DefaultValue = 1000, MinValue = 0.01)]
public double Size { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)]
public int SL { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)]
public int TP { get; set; }
protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 10, 10);
}
protected override void OnTick()
{
// It iterates over all positions
foreach (var position in Positions)
{
// if position is 5 pips in profit
if (Positions[0].Pips == 5)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Size, SymbolName, 0, 10);
}
// if position is 5 pips in lose
else if (Positions[0].Pips == -5)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, 0, 10);
}
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
is anything Wrong with the above code?
Hi,
Why you are using Positions[0].Pips?
Here is the correct version:
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter("Trade Size", DefaultValue = 1000, MinValue = 0.01)]
public double Size { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)]
public int SL { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)]
public int TP { get; set; }
protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, SL, TP);
}
protected override void OnTick()
{
// It iterates over all positions
foreach (var position in Positions)
{
// if position is 5 pips in profit
if (position.Pips >= 5)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Size, SymbolName, SL, TP);
}
// if position is 5 pips in lose
else if (position.Pips <= -5)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, SL, TP);
}
}
}
}
}
@amusleh
amusleh
09 Feb 2022, 09:00
Hi,
Here is the new code, it stored the covered positions IDs on a list and it will use the list to avoid re opening a new position for an already covered position.
using cAlgo.API;
using System.Collections.Generic;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
private readonly List<int> _coveredPositions = new List<int>(100);
[Parameter("Trade Size", DefaultValue = 1000, MinValue = 0.01)]
public double Size { get; set; }
[Parameter("Stop Loss (Pips)", DefaultValue = 15, MinValue = 2)]
public int SL { get; set; }
[Parameter("Take Profit (Pips)", DefaultValue = 35, MinValue = 2)]
public int TP { get; set; }
protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, SL, TP);
}
protected override void OnTick()
{
// It iterates over all positions
foreach (var position in Positions)
{
// If position is already covered, continue
if (_coveredPositions.Contains(position.Id)) continue;
// if position is 5 or more pips in profit
if (position.Pips >= 5)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Size, SymbolName, SL, TP);
_coveredPositions.Add(position.Id);
}
// if position is 5 or more pips in lose
else if (position.Pips <= -5)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Size, SymbolName, SL, TP);
_coveredPositions.Add(position.Id);
}
}
}
}
}
@amusleh
PanagiotisCharalampous
18 Jun 2021, 13:58
Hi danieleyube,
You need to provide more information about your problem. We need the following
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous