Topics
Replies
Waxy
12 Jul 2016, 06:05
look it up with history, you can do:
foreach (var hist in History) { if (hist.ClosingPrice == 1) { //Do Stuff } } // HistoricalTrade _hist = History.FindLast("Label"); Print(_hist.ClosingPrice); // HistoricalTrade[] _histlist = History.FindAll("Label"); Print(_hist.ClosingPrice);
@Waxy
Waxy
24 May 2016, 05:49
Thank you galafrin, can't believe I had no idea of this.
So my purpose was to use a function for a range (day) and skip the weekends, I had to find a more reliable source code, tho not efficient it works, anyway I'll post it here.
DayOfWeek _ref = MarketSeries.OpenTime.LastValue.DayOfWeek; int i = 0; int _auxday = 1; while (_auxday < _DaysToCompute) { if (MarketSeries.OpenTime.Last(i).DayOfWeek == _ref) { i++; } else { _ref = MarketSeries.OpenTime.Last(i).DayOfWeek; UseFunctionForDayBack(_auxday); _auxday++; } }
@Waxy
Waxy
06 Apr 2016, 21:13
Hello fcomanjoncabeza
Even easier, just do:
var _CurrentTF = MarketSeries.TimeFrame;
@Waxy
Waxy
01 Apr 2016, 06:09
Use a random label generator function and run it before placing the first trade, here's mine:
protected string GetLabel(string _TType) { Random rn = new Random(10); int x = rn.Next(100, 10000); _Label = _TType + x.ToString(); var _CLD = History.FindLast(_Label); var _CLO = Positions.Find(_Label); while (_CLD != null || _CLO != null) { x++; _Label = _TType + x.ToString(); _CLD = History.FindLast(_Label); _CLO = Positions.Find(_Label); //Theres a duplicated Label, finding another one } return _Label; }
Then do something like
string Label = GetLabel(Symbol.Code);
@Waxy
Waxy
01 Apr 2016, 06:01
This code has some bugs
First: You can't close a position that's already closed, most of your code happens when a position is closed, so you can't ask it to close it again, you could check it throws an error with: "Entity not found"
TradeResult OperationResult = ClosePosition(position); if (!OperationResult.IsSuccessful) { Print("Operation could not be done, error: {0}",OperationResult.Error); }
Second: You don't reset the counter if the last position is profitable, btw if you want to check the losers in a row do this.
int losercount = 0; //declare it earlier foreach (var hist in History) { if (hist.Label == "Martingale") //within your bot trade history { if (hist.NetProfit < 0) { losercount++; if (losercount == 3) Stop(); } else { losercount = 0; } } }
@Waxy
Waxy
25 Mar 2016, 17:38
( Updated at: 29 Mar 2016, 12:45 )
Hello
Since last update I'm having some trouble with some bots while optimizing, the platform crashes and closes without reporting any error, I would like to know how to fix this issue and I don't know if it's the platform or these bots, I don't have the source code.
The error:
System.StackOverflowException was unhandled
Message: An unhandled exception of type 'System.StackOverflowException' occurred in System.dll
@Waxy
Waxy
20 Mar 2017, 04:30
Thank you Lucian,
I drop this in case someone else needs it,
@Waxy