I have a problem with counting pips in cbot
I have a problem with counting pips in cbot
16 Nov 2024, 20:41
Hello Everyone :)
So I have a problem with counting pips in cbot, in the first case if I use pending orders stop and dont give "*pipsSize" in code it gives me the normal result of 200 pips as in the settings
PlaceStopOrder(TradeType.Buy, Symbol, volume, highestHigh, "BuyHigh", StopLoss, TakeProfit);
PlaceStopOrder(TradeType.Sell, Symbol, volume, lowestLow, "SellLow", StopLoss, TakeProfit);
and now if I set everything the same without and with "*pipsSize" when I want to open positions, it still gives me the result of +2k pips on SL and TP
ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "Sell", stopLoss, takeProfit);
It's getting annoying, I don't know if there's some logic behind it or what, but even when I try to divide the SL by 10, it gives me the same result of 2k+ pips.
Replies
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 there,
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;
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
PanagiotisCharalampous
17 Nov 2024, 16:45
RE: RE: I have a problem with counting pips in cbot
kudukmariusz said:
PanagiotisCharalampous said:
Hi there,
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;
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.
Hi there,
The example you provided uses price levels as a stop loss and take profit. If it still doesn't work when you use pips, please share the updated code and screenshots demonstrating what happens.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
17 Nov 2024, 08:47
Hi there,
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
@PanagiotisCharalampous