Topics
Replies
vtx101
10 Mar 2021, 17:10
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi arunsub321,
I have explained to you why this happens. As per the log, you are sending three orders to close the same position at the same time
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to serverIf you cannot spot the problem in your code, please share the source code and we will try to find the problem for you.
Best Regards,
Panagiotis
here's the source code and screenshot of the program:
using System;
using cAlgo.API;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class MoneyBreakEven : Robot
{
#region Enums
public enum MyColors
{
AliceBlue,
AntiqueWhite,
Aqua,
Aquamarine,
Azure,
Beige,
Bisque,
Black,
BlanchedAlmond,
Blue,
BlueViolet,
Brown,
BurlyWood,
CadetBlue,
Chartreuse,
Chocolate,
Coral,
CornflowerBlue,
Cornsilk,
Crimson,
Cyan,
DarkBlue,
DarkCyan,
DarkGoldenrod,
DarkGray,
DarkGreen,
DarkKhaki,
DarkMagenta,
DarkOliveGreen,
DarkOrange,
DarkOrchid,
DarkRed,
DarkSalmon,
DarkSeaGreen,
DarkSlateBlue,
DarkSlateGray,
DarkTurquoise,
DarkViolet,
DeepPink,
DeepSkyBlue,
DimGray,
DodgerBlue,
Firebrick,
FloralWhite,
ForestGreen,
Fuchsia,
Gainsboro,
GhostWhite,
Gold,
Goldenrod,
Gray,
Green,
GreenYellow,
Honeydew,
HotPink,
IndianRed,
Indigo,
Ivory,
Khaki,
Lavender,
LavenderBlush,
LawnGreen,
LemonChiffon,
LightBlue,
LightCoral,
LightCyan,
LightGoldenrodYellow,
LightGray,
LightGreen,
LightPink,
LightSalmon,
LightSeaGreen,
LightSkyBlue,
LightSlateGray,
LightSteelBlue,
LightYellow,
Lime,
LimeGreen,
Linen,
Magenta,
Maroon,
MediumAquamarine,
MediumBlue,
MediumOrchid,
MediumPurple,
MediumSeaGreen,
MediumSlateBlue,
MediumSpringGreen,
MediumTurquoise,
MediumVioletRed,
MidnightBlue,
MintCream,
MistyRose,
Moccasin,
NavajoWhite,
Navy,
OldLace,
Olive,
OliveDrab,
Orange,
OrangeRed,
Orchid,
PaleGoldenrod,
PaleGreen,
PaleTurquoise,
PaleVioletRed,
PapayaWhip,
PeachPuff,
Peru,
Pink,
Plum,
PowderBlue,
Purple,
Red,
RosyBrown,
RoyalBlue,
SaddleBrown,
Salmon,
SandyBrown,
SeaGreen,
SeaShell,
Sienna,
Silver,
SkyBlue,
SlateBlue,
SlateGray,
Snow,
SpringGreen,
SteelBlue,
Tan,
Teal,
Thistle,
Tomato,
Transparent,
Turquoise,
Violet,
Wheat,
White,
WhiteSmoke,
Yellow,
YellowGreen
}
public enum CalcMode
{
Money,
Percentage
}
#endregion
#region Identity
/// <summary>
/// Nome del prodotto, identificativo, da modificare con il nome della propria creazione
/// </summary>
public const string NAME = "Money Break Even";
/// <summary>
/// La versione del prodotto, progressivo, utilie per controllare gli aggiornamenti se viene reso disponibile sul sito ctrader.guru
/// </summary>
public const string VERSION = "1.0.8";
#endregion
#region Params
[Parameter(NAME + " " + VERSION, Group = "Identity", DefaultValue = "https://ctrader.guru/product/money-break-even/")]
public string ProductInfo { get; set; }
[Parameter("Mode", Group = "Params", DefaultValue = CalcMode.Percentage)]
public CalcMode MyCalcMode { get; set; }
[Parameter("Net Profit Activation ( $ | % )", Group = "Params", DefaultValue = 10.0)]
public double BEfrom { get; set; }
[Parameter("Net Profit Target ( $ | % )", Group = "Params", DefaultValue = 3.0)]
public double BE { get; set; }
[Parameter("All Cross ?", Group = "Options", DefaultValue = false)]
public bool GlobalTarget { get; set; }
[Parameter("Auto Stop ?", Group = "Options", DefaultValue = true)]
public bool AutoStop { get; set; }
[Parameter("Remove Pending Orders ?", Group = "Options", DefaultValue = true)]
public bool RemovePO { get; set; }
[Parameter("Color Target Logic", Group = "Styles", DefaultValue = MyColors.Magenta)]
public MyColors Boxcolortarget { get; set; }
[Parameter("Color Positive Logic", Group = "Styles", DefaultValue = MyColors.DodgerBlue)]
public MyColors Boxcolorpositive { get; set; }
[Parameter("Color Negative Logic", Group = "Styles", DefaultValue = MyColors.Orange)]
public MyColors Boxcolornegative { get; set; }
[Parameter("Color Activated", Group = "Styles", DefaultValue = MyColors.DarkViolet)]
public MyColors Boxcoloractive { get; set; }
/// <summary>
/// Opzione per la posizione del box info in verticale
/// </summary>
[Parameter("Vertical Position", Group = "Styles", DefaultValue = VerticalAlignment.Top)]
public VerticalAlignment VAlign { get; set; }
/// <summary>
/// Opzione per la posizione del box info in orizontale
/// </summary>
[Parameter("Horizontal Position", Group = "Styles", DefaultValue = HorizontalAlignment.Left)]
public HorizontalAlignment HAlign { get; set; }
#endregion
#region Property
private bool Activated;
private double FixedBEfrom = 0;
private double FixedBE = 0;
private double FixedBalance = 0;
#endregion
#region cBot Events
protected override void OnStart()
{
// --> Stampo nei log la versione corrente
Print("{0} : {1}", NAME, VERSION);
FixedBEfrom = BEfrom;
FixedBE = BE;
FixedBalance = Account.Balance;
Activated = false;
OnTick();
}
protected override void OnTick()
{
_monitoring();
}
#endregion
#region Private Methods
void _monitoring()
{
// --> Controllo se calcolare la percentuale sul bilancio
if (MyCalcMode == CalcMode.Percentage)
{
BEfrom = Math.Round((FixedBalance / 100) * FixedBEfrom, 2);
BE = Math.Round((FixedBalance / 100) * FixedBE, 2);
}
// --> Raccolgo tutte le operazioni su questo simbolo
int nPositions = 0;
double ttnp = 0.0;
foreach (var Position in Positions)
{
if (!GlobalTarget && Position.SymbolName != SymbolName)
continue;
ttnp += Position.NetProfit;
nPositions++;
}
// --> Se non ci sono trade da monitorare deattivo e basta
if (nPositions < 1)
{
// --> Disattivo
Activated = false;
// --> Resetto il nuovo bilancio
FixedBalance = Account.Balance;
}
// --> Se selezionato e se non ci sono trade, fermo il cBot
if (AutoStop && nPositions < 1)
Stop();
// --> Valorizzo l'attivazione se raggiunto
if (!Activated && ((BEfrom > BE && ttnp >= BEfrom) || (BEfrom < BE && ttnp <= BEfrom)))
Activated = true;
// --> Stampo a video alcune informazioni
string scope = (GlobalTarget) ? "all cross" : "the current cross";
string logica = (BEfrom == BE) ? "target" : (BEfrom > BE) ? "positive" : "negative";
string direction = (BEfrom > BE) ? "less" : "greater";
string netpt = String.Format("{0:0.00}", ttnp);
string phrase = (Activated) ? string.Format("Activated, I will close all trades for\r\n{0} if net profit is {1} or equal {2}", scope, direction, BE) : string.Format("Relax, I'm monitoring {0} for\r\n{1} logic and waiting net profit reaches {2}", scope, logica, BEfrom);
string[] items =
{
"MONEY BREAK EVEN\r\n",
phrase,
"\r\nNET PROFIT\r\n{0}"
};
string info = string.Join("\r\n", items);
info = string.Format(info, netpt);
MyColors mycolor = (BEfrom == BE) ? Boxcolortarget : (BEfrom > BE) ? Boxcolorpositive : Boxcolornegative;
if (Activated)
mycolor = Boxcoloractive;
Chart.DrawStaticText("BoxMBE", info, VAlign, HAlign, Color.FromName(mycolor.ToString("G")));
// --> Se attivato e se sono la soglia di BE chiudo tutto
if ((Activated && ((BEfrom > BE && ttnp <= BE) || (BEfrom < BE && ttnp >= BE))) || (BEfrom == BE && ((BE >= 0 && ttnp >= BE) || (BE < 0 && ttnp <= BE))))
{
// --> Chiudo tutti i trade
foreach (var Position in Positions)
{
if (!GlobalTarget && Position.SymbolName != SymbolName)
continue;
ClosePositionAsync(Position);
}
// --> Chiudo tutti gli ordini pendenti se richiesto
if (RemovePO)
{
foreach (var order in PendingOrders)
{
if (!GlobalTarget && order.SymbolName != SymbolName)
continue;
CancelPendingOrderAsync(order);
}
}
// --> Resetto il flag
Activated = false;
}
}
#endregion
}
}
the program can be downloaded and tested here: https://ctrader.guru/product/money-break-even/
@vtx101
vtx101
10 Mar 2021, 16:19
( Updated at: 10 Mar 2021, 16:22 )
RE:
PanagiotisCharalampous said:
Hi arunsub321,
I have explained to you why this happens. As per the log, you are sending three orders to close the same position at the same time
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to serverIf you cannot stop the problem in your code, please share the source code and we will try to find the problem for you.
Best Regards,
Panagiotis
Well there were times where the request was sent once to close and the error occurred:
2021.03.04 08:52:12.314 | → Order OID312026614 is FILLED at 0.77961, position PID213032943 (04/03/2021 08:52:12.193 UTC+0)
2021.03.04 08:52:14.455 | Request to close position PID213032943 is sent to server
2021.03.04 08:52:14.767 | → Failed to close position PID213032943 with error "POSITION_LOCKED"
2021.03.04 08:52:14.939 | → Order OID312026619 is FILLED at 0.77967, position PID213032943 closed (04/03/2021 08:52:14.773 UTC+0)
2021.03.04 08:52:56.752 | Request to Buy 2.50 Lots GBPUSD (TP: 0.2) is sent to server
i'll have to get in contact with a programmer to provide the source code...
@vtx101
vtx101
10 Mar 2021, 16:05
( Updated at: 10 Mar 2021, 16:10 )
RE: RE:
arunsub321 said:
PanagiotisCharalampous said:
Hi arunsub321,
POSITION_LOCKED means that the server is trying to close the position i.e. sent the order to LP and waiting a response. Make sure you are not trying to modify/close a position after you have already sent an order to close it.
Best Regards,
Panagiotis
Ridiculous, this only happens when my robot is activated. it's a simple code to immediately close the position once a certain level is reached. If i was to manually close the trade myself i wont get the error.
This problem is continuously happening when using a robot....what is going on ?? it's a simple code Does my broker have a delay on cTrader robots ??
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.349 | Request to close position PID71780050 is sent to server
2021.03.10 14:01:41.521 | → Request to close position PID71780050 is ACCEPTED, order OID131242881 created (10/03/2021 14:01:41.429 UTC+0)
2021.03.10 14:01:41.709 | → Failed to close position PID71780050 with error "POSITION_LOCKED"
2021.03.10 14:01:41.709 | → Failed to close position PID71780050 with error "POSITION_LOCKED"
2021.03.10 14:01:41.927 | → Order OID131242881 is FILLED at 2132.15, position PID71780050 closed (10/03/2021 14:01:41.805 UTC+0)
2021.03.10 14:01:42.240 | cBot "Money Break Even" was stopped for SE30, h8.
2021.03.10 14:01:42.256 | cBot "Money Break Even" was stopped for SE30, h8.
2021.03.10 14:01:42.271 | cBot "Money Break Even" was stopped for SE30, h8.
2021.03.10 14:01:42.287 | cBot "Money Break Even" was stopped for SE30, h8.
2021.03.10 14:01:42.302 | cBot "Money Break Even" was stopped for SE30, h8.
2021.03.10 14:01:41.916 | → Order OID131242881 is FILLED at 2132.15, position PID71780050 closed (10/03/2021 14:01:41.805 UTC+0)
@vtx101
vtx101
09 Mar 2021, 20:58
RE: RE:
bnlf said:
yuval.ein said:
Hello
I am trying to copy the strategy Relax/Relax1 using live account. However it allows me to do so using OctaFX broker only, and not Pepperstone. When I try to use Pepperstone, the option in the combo box is grayed out.
Thanks
Pepperstone doesn't allow copy trading. Use another broker.
terrible
@vtx101
vtx101
09 Mar 2021, 20:53
( Updated at: 21 Dec 2023, 09:22 )
can ya'll also investigate "complex" strategy provider. I think crazy and complex had similar trading strategies both basically blew their accounts by trading on red bar news...hmmm. Why would experience traders place trade on such a serious news events ?
@vtx101
vtx101
09 Mar 2021, 20:42
( Updated at: 21 Dec 2023, 09:22 )
RE: reply to Ikares92 - Best trader Urai Failed
AlienTechnology said:
Urai / Relax was using a cBot cTrader . ( a robot )
You can see this by yourself. Click on the Strategy provider and you'll see it under ''Channel '' .
He had many other strategies with the same cBot. Stable, 1, .. But the cBot was set to open bigger positions. Bigger risk.
I think his cBot was just trading the daily, weekly, monthly support and resistance bounce.
I was copying them all with my real and demo accounts. I could see the eur/usd positions were being opened and closed at the same time.
I think he still has one strategy: '' complex ''
This is a screenshot of where you can see a cBot cTrader is trading and not a person.. :
complex was also another %#$%$# to blow his account by trading on red bar news !!
@vtx101
vtx101
09 Mar 2021, 20:35
RE:
PanagiotisCharalampous said:
Hi Professional,
The next version of cTrader Copy will have an additional option in that drawdown list where the strategy provider will be able to hide the open positions from everybody. Therefore to change these conditions a restart of the strategy will be required.
Best Regards,
Panagiotis
not cool...how will we know when to stop copying positions from providers when they make clearly poor trades ? example: trading on red bar news !!
@vtx101
vtx101
09 Mar 2021, 18:06
RE:
PanagiotisCharalampous said:
Hi arunsub321,
POSITION_LOCKED means that the server is trying to close the position i.e. sent the order to LP and waiting a response. Make sure you are not trying to modify/close a position after you have already sent an order to close it.
Best Regards,
Panagiotis
Ridiculous, this only happens when my robot is activated. it's a simple code to immediately close the position once a certain level is reached. If i was to manually close the trade myself i wont get the error.
@vtx101
vtx101
09 Mar 2021, 14:09
RE:
Spotware said:
This issue has been fixed.
now i'm getting this problem with my robot!! i'm guessing ya'll or the brokers want to keep trading difficult. The robot is designed to close the trade immediately. Ever since using my robot am getting this error!
2021.03.08 20:01:24.836 | → Failed to close position PID71524136 with error "POSITION_LOCKED"
it's making my copy trading account look bad. i suffered my first major loss today!!!
@vtx101
vtx101
14 Jun 2021, 14:16
RE:
PanagiotisCharalampous said:
That seemed to work...Strategy age changed though..
@vtx101