Please provide your complete code and explain to us how we can see what you are looking at. Also explain what you would expect to see instead.
Best regards,
Panagiotis
Hi, so the problem only occurs when I open positions, even when I tried to take the easiest example from the Internet where in the video it works normally, it doesn't work for me :( setting up pending positions works normally and I can set SL and TP as I like
using System; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals;
namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class ThreeWhiteSoldiersAndThreeBlackCrows : Robot { [Parameter(DefaultValue = 1)] public double Volume { get; set; }
[Parameter(DefaultValue = 200)] public double TakeProfit { get; set; }
[Parameter(DefaultValue = 300)] public double StopLoss { get; set; }
protected override void OnBar() {
// Check if there are open positions if (HasOpenPositions()) return;
kudukmariusz
17 Nov 2024, 13:20 ( Updated at: 17 Nov 2024, 16:38 )
RE: I have a problem with counting pips in cbot
PanagiotisCharalampous said:
Hi, so the problem only occurs when I open positions, even when I tried to take the easiest example from the Internet where in the video it works normally, it doesn't work for me :( setting up pending positions works normally and I can set SL and TP as I like
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ThreeWhiteSoldiersAndThreeBlackCrows : Robot
{
[Parameter(DefaultValue = 1)]
public double Volume { get; set; }
[Parameter(DefaultValue = 200)]
public double TakeProfit { get; set; }
[Parameter(DefaultValue = 300)]
public double StopLoss { get; set; }
protected override void OnBar()
{
// Check if there are open positions
if (HasOpenPositions())
return;
double Price_mine = Bars.ClosePrices.Last(1);
// Three White Soldiers
if (Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1) &&
Bars.ClosePrices.Last(2) > Bars.OpenPrices.Last(2) &&
Bars.ClosePrices.Last(3) > Bars.OpenPrices.Last(3))
{
double stopLoss = Price_mine - (StopLoss * Symbol.PipSize);
double takeProfit = Price_mine + (TakeProfit * Symbol.PipSize);
ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, "ThreeWhiteSoldiers", stopLoss, takeProfit);
}
// Three Black Crows
if (Bars.ClosePrices.Last(1) < Bars.OpenPrices.Last(1) &&
Bars.ClosePrices.Last(2) < Bars.OpenPrices.Last(2) &&
Bars.ClosePrices.Last(3) < Bars.OpenPrices.Last(3))
{
double stopLoss = Price_mine + (StopLoss * Symbol.PipSize);
double takeProfit = Price_mine - (TakeProfit * Symbol.PipSize);
ExecuteMarketOrder(TradeType.Sell, SymbolName, Volume, "ThreeBlackCrows", stopLoss, takeProfit);
}
}
private bool HasOpenPositions()
{
foreach (var position in Positions)
{
if (position.SymbolName == SymbolName)
return true;
}
return false;
}
}
}
Even if I enter the number of pips directly into the Execute Order function, the bot still sets my SL and TP to over 2k pips.
@kudukmariusz