Topics
Replies
alexsanramon
10 Jul 2019, 01:26
Go to this chat and request.
https://discord.gg/5GAPMtp
@alexsanramon
alexsanramon
10 Jul 2019, 01:26
I know a chat room that can help with this. Go to this chat and ask this.
https://discord.gg/5GAPMtp
@alexsanramon
alexsanramon
09 Jul 2019, 10:35
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 RelativeMomentum : Robot { [Parameter("Instance", DefaultValue = "001")] public string InstanceName { get; set; } [Parameter("Lot Size", DefaultValue = 0.01)] public double LotSize { get; set; } [Parameter("BandDistance", DefaultValue = 2.4)] public double Band { get; set; } [Parameter("Include Trailing Stop", DefaultValue = false)] public bool IncludeTrailingStop { get; set; } [Parameter("Trailing Stop Trigger (pips)", DefaultValue = 20)] public int TrailingStopTrigger { get; set; } [Parameter("Trailing Stop Step (pips)", DefaultValue = 10)] public int TrailingStopStep { get; set; } [Parameter("Take Profit (Pips)", DefaultValue = 6, MinValue = 1, Step = 1)] public int TakeProfit { get; set; } [Parameter("Stop Loss (Pips)", DefaultValue = 150, MinValue = 1, Step = 1)] public int StopLoss { get; set; } private RelativeStrengthIndex RSSI; private MomentumOscillator Mom; protected override void OnStart() { RSSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14); Mom = Indicators.MomentumOscillator(MarketSeries.Close, 14); } protected override void OnTick() { } protected override void OnBar() { ManagePositions(); SetTrailingStop(); } protected override void OnStop() { // unused } private void ManagePositions() { if ((RSSI.Result.LastValue > 50) & (Mom.Result.LastValue > 100) & (Positions.Count() == 0)) { if (!IsPositionOpenByType(TradeType.Buy)) { OpenPosition(TradeType.Buy); } ClosePosition(TradeType.Sell); } if ((RSSI.Result.LastValue < 50) & (Mom.Result.LastValue < 100) & (Positions.Count() == 0)) { if (!IsPositionOpenByType(TradeType.Sell)) { OpenPosition(TradeType.Sell); } ClosePosition(TradeType.Buy); } } private void SetTrailingStop() { var sellPositions = Positions.FindAll(InstanceName, Symbol, TradeType.Sell); foreach (Position position in sellPositions) { double distance = position.EntryPrice - Symbol.Ask; if (distance < TrailingStopTrigger * Symbol.PipSize) continue; double newStopLossPrice = Symbol.Ask + TrailingStopStep * Symbol.PipSize; if (position.StopLoss == null || newStopLossPrice < position.StopLoss) { ModifyPosition(position, newStopLossPrice, position.TakeProfit); } } var buyPositions = Positions.FindAll(InstanceName, Symbol, TradeType.Buy); foreach (Position position in buyPositions) { double distance = Symbol.Bid - position.EntryPrice; if (distance < TrailingStopTrigger * Symbol.PipSize) continue; double newStopLossPrice = Symbol.Bid - TrailingStopStep * Symbol.PipSize; if (position.StopLoss == null || newStopLossPrice > position.StopLoss) { ModifyPosition(position, newStopLossPrice, position.TakeProfit); } } } private void OpenPosition(TradeType type) { long volume = Symbol.QuantityToVolume(LotSize); ExecuteMarketOrder(type, this.Symbol, volume, InstanceName, StopLoss, TakeProfit); } private void ClosePosition(TradeType type) { var p = Positions.Find(InstanceName, this.Symbol, type); if (p != null) { ClosePosition(p); } } private bool IsPositionOpenByType(TradeType type) { var p = Positions.FindAll(InstanceName, Symbol, type); if (p.Count() >= 1) { return true; } return false; } } }
@alexsanramon
alexsanramon
09 Jul 2019, 02:20
Ok. So after a very long agonizing monitoring for the sake of troubleshooting, here's what happens. I turned on my bot about 10pm Singapore time, all 28 pairs on range bars. At the time I opened the cbot I got atleast one order filled after about 15 minutes when I came back after a shower. And when I woke up at about 6am Singapore time, all of my cbot have nothing on the charts. You can tell that it is was dead for a while because no orders were made except the earlier order. You can also tell because the bid and ask line is gone. I have to reload or refresh the charts to get it going.
There is really a big issue here. I have other renko cbots running in the background ( 28x2 pairs with 2 different brokers) and none have issue.
Please fix this issue.
Thank you kind developers.
Alexis.
@alexsanramon
alexsanramon
05 Jul 2019, 04:01
I do not get this issue with regular time based charts. How is the data being processed in renko and range bar charts? Does the broker provides the data then our machine converts it to bars in ctrader? If so there is an issue right there.
Please look into this since most traders use cTrader because of its supremacy of the renko and range bar charts.
@alexsanramon
alexsanramon
04 Jul 2019, 14:11
mine too. Always has refresh issue. I believe this happens if you have multiple charts per workspace in play.
@alexsanramon
alexsanramon
01 Jul 2019, 13:13
Hello Panagiotis,
When will be the planned date to backtest renko and range bar charts?
Thank you,
Alexis
@alexsanramon
alexsanramon
01 Jul 2019, 13:11
Hi Paul,
Glad to see you are still helping out even though you sell great products.
Do you still update your cBot tutorial site? I am interested to see how you can build cBot in VS in your tutorial.
Thanks.
-Alexis
@alexsanramon
alexsanramon
22 Jun 2019, 02:45
I voted yes because it sounds nice. Can you please post images as an example for others to understand better and therefore have many votes? Thank you.
@alexsanramon
alexsanramon
10 Jul 2019, 01:51
I think I got it.
((Positions.Count(x => x.SymbolCode == Symbol.Code)) == 0))
@alexsanramon