Topics
Replies
diegorcirelli
25 Jun 2019, 19:33
( Updated at: 21 Dec 2023, 09:21 )
Good afternoon ... The Margin is totally out of the picture, is there anything I can do to fix it ?? Apparently it occurs when I make a change in position.
@diegorcirelli
diegorcirelli
19 Jun 2019, 16:00
( Updated at: 21 Dec 2023, 09:21 )
Good Morning, I'm having a problem at the margin, it's out of the real, print follows.
@diegorcirelli
diegorcirelli
14 Jun 2019, 23:33
Good afternoon...
I was able ... I wonder if it is possible to simulate monthly, weekly or even daily withdrawal, just for testing.
@diegorcirelli
diegorcirelli
14 Jun 2019, 13:52
Good Morning,
I have a problem that I can not solve.
How I wish the strategy worked:
TP = 1 Average = 20
Symbol = 1000 open Position 1 = Volume 1.00 / EntryPrice 1000 / TP 1001
Symbol = 980 Modify Position 1 = Volume 2.00 / EntryPrice 990 ((1000 + 980) / 2) / TP 991
Okay
How is he working?
Symbol = 1000 open Position 1 = Volume 1.00 / EntryPrice 1000 / TP 1001
Symbol = 980 Modify Position 1 = Volume 2.00 / EntryPrice 990 ((1000 + 980) / 2) / TP 1001
I added in the Modify TP the formula ((Average / 2) + TP)
So he works as follows
Symbol = 1000 open Position 1 = Volume 1.00 / EntryPrice 1000 / TP 1001
Symbol = 980 Modify Position 1 = Volume 1.00 / EntryPrice 1000 / TP 996 & Volume 1.00 / EntryPrice 980 / TP 981
I'm not sure how to solve it, could you help me?
foreach (var position in Positions) { if (position.TradeType == TradeType.Buy && position.EntryPrice > Symbol.Bid + (Symbol.PipValue * Average)) { ModifyPosition(position, position.VolumeInUnits * (1 + Exp)); } }
foreach (var position in Positions) { if (position.TradeType == TradeType.Buy && position.EntryPrice > Symbol.Bid + (Symbol.PipValue * Average)) { ModifyPosition(position, position.VolumeInUnits * (1 + Exp), (Average/2)+TP); } }
@diegorcirelli
diegorcirelli
13 Jun 2019, 14:59
( Updated at: 21 Dec 2023, 09:21 )
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 MeuMesmo : Robot { [Parameter("Volume", DefaultValue = 1)] public double Vol { get; set; } [Parameter("StopLoss", DefaultValue = 1000)] public double SL { get; set; } [Parameter("TakeProfit", DefaultValue = 100)] public double TP { get; set; } [Parameter("Distância", DefaultValue = 100)] public double Pips { get; set; } private readonly string Label = "MeuMesmo"; protected override void OnStart() { ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); } protected override void OnBar() { if (Positions.Count(x => x.SymbolCode == Symbol.Code && x.Label == Label && x.TradeType == TradeType.Buy) > 0) { var highestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Max(x => x.EntryPrice); if (highestPriceBuy + (Symbol.PipValue * Pips) <= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); var lowestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Min(x => x.EntryPrice); if (lowestPriceBuy - (Symbol.PipValue * Pips) >= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); } } protected override void OnStop() { // Put your deinitialization logic here } } }
@diegorcirelli
diegorcirelli
13 Jun 2019, 14:13
Good morning ... yesterday I did the tests only in XAUUSD and worked as expected, however when testing in EURUSD, GBPUSD and others, nothing happened, can you tell me what could be wrong in the code ??
@diegorcirelli
diegorcirelli
13 Jun 2019, 00:42
Good night my friend...
I did the proper tests and really for the purpose it worked. And before testing I would like to add a code to modify the Position Volume when it reaches a certain distance from the current value, it follows the "faulty" code, thank you again if you can help me.
[Parameter("Média", DefaultValue = 1000)] public double Average { get; set; } var AverageBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Max(x => x.EntryPrice); if (AverageBuy - (Symbol.PipValue * Average) <= Symbol.Bid) ModifyPosition(AverageBuy, (Positions.FindAll(Label, Symbol, TradeType.Buy).Max(x => x.VolumeInUnits)) * 2, TP);
@diegorcirelli
diegorcirelli
12 Jun 2019, 15:55
Could it be configured to count only the purchase positions ??
@diegorcirelli
diegorcirelli
12 Jun 2019, 15:50
Excellent ... It worked ...
I'll do some tests and comeback if there are more problems ...
@diegorcirelli
diegorcirelli
12 Jun 2019, 15:07
( Updated at: 21 Dec 2023, 09:21 )
I already did this test and also did not work, he buys several ...
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 MeuMesmo : Robot { [Parameter("Volume", DefaultValue = 1)] public double Vol { get; set; } [Parameter("StopLoss", DefaultValue = 1000)] public double SL { get; set; } [Parameter("TakeProfit", DefaultValue = 100)] public double TP { get; set; } [Parameter("Distância", DefaultValue = 100)] public double Pips { get; set; } private readonly string Label = "MeuMesmo"; protected override void OnStart() { ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); } protected override void OnTick() { var highestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Max(x => x.EntryPrice); if (highestPriceBuy + Pips <= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); var lowestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Min(x => x.EntryPrice); if (lowestPriceBuy - Pips <= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); } protected override void OnStop() { // Put your deinitialization logic here } } }
@diegorcirelli
diegorcirelli
12 Jun 2019, 14:47
( Updated at: 21 Dec 2023, 09:21 )
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 MeuMesmo : Robot { [Parameter("Volume", DefaultValue = 1)] public double Vol { get; set; } [Parameter("StopLoss", DefaultValue = 1000)] public double SL { get; set; } [Parameter("TakeProfit", DefaultValue = 100)] public double TP { get; set; } [Parameter("Distância", DefaultValue = 100)] public double Pips { get; set; } private readonly string Label = "MeuMesmo"; protected override void OnStart() { } protected override void OnTick() { var highestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Max(x => x.EntryPrice); if (highestPriceBuy + Pips <= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); var lowestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Min(x => x.EntryPrice); if (lowestPriceBuy - Pips <= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); } protected override void OnStop() { // Put your deinitialization logic here } } }
@diegorcirelli
diegorcirelli
12 Jun 2019, 14:32
Good morning then...
It is not running ... the idea is that when symbol.bid is "x" pips above the largest existing position, it executes the order ...
Example:
Existing positions
1010
1005
1000
Using 5 pips, when the highest position (which is 1010) added to the pips (which is 5) is less than or equal to symbol.bid, it should run.
But it is not running, it does nothing.
@diegorcirelli
diegorcirelli
12 Jun 2019, 01:24
Good evening ... now a little developed this code, but also did not work, could you help me ??
protected override void OnTick() { var highestPriceBuy = Positions.FindAll(Label, Symbol, TradeType.Buy).Max(x => x.EntryPrice); if (highestPriceBuy + Pips <= Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); }
@diegorcirelli
diegorcirelli
11 Jun 2019, 13:18
Good Morning... I would like you to return the position with the biggest entryprice. Example I have positions 1010 1005 1000 I would like you to return the 1010
private double FindHighestPositionPrice(TradeType tradeType) { double highestPriceBuy = 0; foreach (var position in Positions) { if (position.Label == Label && position.SymbolCode == Symbol.Code) { if (position.TradeType == tradeType) { if (highestPriceBuy == 0) { highestPriceBuy = position.EntryPrice; continue; } if (position.EntryPrice > highestPriceBuy) highestPriceBuy = position.EntryPrice; } } } return highestPriceBuy; }
@diegorcirelli
diegorcirelli
10 Jun 2019, 19:56
Good afternoon... I'm trying to do my project and something is not working, could you help me, code follows.
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 MeuMesmo : Robot { [Parameter("Volume", DefaultValue = 0)] public double Vol { get; set; } [Parameter("StopLoss", DefaultValue = 0)] public double SL { get; set; } [Parameter("TakeProfit", DefaultValue = 0)] public double TP { get; set; } [Parameter(DefaultValue = 0)] public double Pips { get; set; } private readonly string Label = "MeuMesmo"; private double FindLowestPositionPrice(TradeType tradeType) { double lowestPriceBuy = 0; foreach (var position in Positions) { if (position.Label == Label && position.SymbolCode == Symbol.Code) { if (position.TradeType == tradeType) { if (lowestPriceBuy == 0) { lowestPriceBuy = position.EntryPrice; continue; } if (position.EntryPrice < lowestPriceBuy) lowestPriceBuy = position.EntryPrice; } } } return lowestPriceBuy; } private double FindHighestPositionPrice(TradeType tradeType) { double highestPriceBuy = 0; foreach (var position in Positions) { if (position.Label == Label && position.SymbolCode == Symbol.Code) { if (position.TradeType == tradeType) { if (highestPriceBuy == 0) { highestPriceBuy = position.EntryPrice; continue; } if (position.EntryPrice > highestPriceBuy) highestPriceBuy = position.EntryPrice; } } } return highestPriceBuy; } protected override void OnStart() { } protected override void OnTick() { if (highestPriceBuy + Pips < Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); if (lowestPriceBuy - Pips < Symbol.Bid) ExecuteMarketOrder(TradeType.Buy, Symbol, Vol, Label, SL, TP); } protected override void OnStop() { // Put your deinitialization logic here } } }
@diegorcirelli
diegorcirelli
26 Jun 2019, 15:36
I have a total of 560Oz purchase positions and 570Oz in sales positions, using $ 3991 of Margin, and my capital added to the net profit does not even come close to this value ... That is, it is opening new positions that in a real account will be impossible to open.
@diegorcirelli