ER
Topics
08 Jun 2016, 10:48
2817
5
29 Feb 2016, 20:38
3634
5
13 Sep 2014, 21:40
3081
3
Replies
Ermisl
23 Feb 2016, 12:25
This is a great platform. It has evolved during its lifetime to a great degree. But it is lacking a visual mode as described. I surely hope that all this time it is taking to appear, is the actual time needed to produce an efficient and innovative visual mode for backtesting to suit the high standards of the rest of the platform. keep up the good work.
@Ermisl
Ermisl
25 Sep 2014, 22:10
Actually that was not the only problem. Made some modifications to your code. Please consider the following :
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Trend : Robot { public int LotSize = 1000; protected override void OnStart() { } protected override void OnTick() { double y_range = (MarketSeries.Close.Last(1) - MarketSeries.Open.Last(1)); double trail_stop = 0.2 * Math.Abs(y_range); double hardstop = 0.5 * Math.Abs(y_range); int total_positions = Positions.Count; if (total_positions < 1) { //Buy market entry with hard stop at 50% of t-1 if (y_range > 0 && Symbol.Bid > MarketSeries.Close.Last(1)) { var b_signal = ExecuteMarketOrder(TradeType.Buy, Symbol, LotSize,"myRobot"); if (b_signal.IsSuccessful) { var position = b_signal.Position; var stopLoss = position.EntryPrice - hardstop; var takeprofit=position.TakeProfit; ModifyPosition(position, stopLoss,takeprofit ); } } //Sell market entry with hard stop at 50% of t-1 else if (MarketSeries.Open.Last(1) < MarketSeries.Close.Last(1) && y_range < 0) { var s_signal = ExecuteMarketOrder(TradeType.Sell, Symbol, LotSize,"myRobot"); if (s_signal.IsSuccessful) { var position = s_signal.Position; var stopLoss = position.EntryPrice + hardstop; ModifyPosition(position, stopLoss,position.TakeProfit); } } } if (total_positions > 0) { var buyPositions = Positions.FindAll("myRobot", Symbol, TradeType.Buy); foreach (var position in buyPositions) { if ( Symbol.Ask - trail_stop > position.StopLoss) { var trailer_b = Symbol.Ask - trail_stop; ModifyPosition(position, trailer_b, position.TakeProfit); } } var positions = Positions.FindAll("myRobot", Symbol, TradeType.Sell); foreach (var position in positions) { if (Symbol.Bid + trail_stop > position.StopLoss) { var trailer_s = Symbol.Bid + trail_stop; ModifyPosition(position, trailer_s, position.TakeProfit); } } } } protected override void OnStop() { // Put your deinitialization logic here } } }
Hope that helps.
@Ermisl
Ermisl
08 Jun 2016, 23:07
Thank you for your prompt answer.
I hope those are implemented as soon as possible so as to provide an undistorted view of the efficiency of trader's strategies.
Keep up the good work.
@Ermisl