No performance
No performance
07 Sep 2018, 08:23
Hello
Why the robot does not work under the following condition
protected override void OnTick() { if (hivalow.KijunSenMax.Last(0) > hivalow.KijunSenMax.Last(1)) ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "cBotLabel", 20, 20); }
Does the robot understand the following values?
if (hivalow.KijunSenMax.Last(0) > hivalow.KijunSenMax.Last(1))
The indicator
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class hivalow : Indicator { [Parameter(DefaultValue = 26)] public int periodMedium { get; set; } [Output("KijunSenMax", Color = Colors.Blue, LineStyle = LineStyle.Dots)] public IndicatorDataSeries KijunSenMax { get; set; } [Output("KijunSenMin", Color = Colors.Blue, LineStyle = LineStyle.Dots)] public IndicatorDataSeries KijunSenMin { get; set; } double maxmedium, minmedium; public override void Calculate(int index) { maxmedium = MarketSeries.High[index]; minmedium = MarketSeries.Low[index]; for (int i = 0; i < periodMedium; i++) { if (maxmedium < MarketSeries.High[index - i]) { maxmedium = MarketSeries.High[index - i]; } if (minmedium > MarketSeries.Low[index - i]) { minmedium = MarketSeries.Low[index - i]; } } KijunSenMax[index] = maxmedium; KijunSenMin[index] = minmedium; } } }
robot
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 trade : Robot { [Parameter(DefaultValue = 26)] public int periodMedium { get; set; } private hivalow hivalow; protected override void OnStart() { hivalow = Indicators.GetIndicator<hivalow>(periodMedium); } protected override void OnTick() { if (hivalow.KijunSenMax.Last(2) == hivalow.KijunSenMax.Last(1)) if (hivalow.KijunSenMax.Last(0) > hivalow.KijunSenMax.Last(1)) ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "cBotLabel", 20, 20); } protected override void OnStop() { // Put your deinitialization logic here } } }
Replies
alidarvish64@yahoo.com
07 Sep 2018, 08:46
( Updated at: 21 Dec 2023, 09:20 )
@alidarvish64@yahoo.com
PanagiotisCharalampous
07 Sep 2018, 09:39
Hi alidarvish64@yahoo.com,
The error message indicates that there is not enough money in your account to trade. From a brief view in your logic, it seems that you are opening several positions in OnTick() without any check if the position has already been opened. This is also visible in the log you attached. I would suggest to revisit your logic. Probably you should use OnBar() instead of OnTick().
Best Regards
Panagiotis
@PanagiotisCharalampous
alidarvish64@yahoo.com
07 Sep 2018, 10:09
( Updated at: 21 Dec 2023, 09:20 )
Dear Panagiotis
If our bet is changed from bigger to smaller. See the result
protected override void OnTick() { if (hivalow.KijunSenMax.Last(2) == hivalow.KijunSenMax.Last(1)) { if (hivalow.KijunSenMax.Last(0) < hivalow.KijunSenMax.Last(1)) { ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "cBotLabel", 20, 20); } }
But by changing the condition, the robot does not work anymore
if (hivalow.KijunSenMax.Last(0) > hivalow.KijunSenMax.Last(1))
And see the result
Does not run the purchase position.
The first condition is not accepted. That I can apply my next bets.
I need the amount of moment. I can not access the moment at on bar
@alidarvish64@yahoo.com
PanagiotisCharalampous
07 Sep 2018, 10:24
Hi alidarvish64@yahoo.com,
It is not clear to me what is the problem
- Was the NoMoney issue solved?
- What do you expect from the cBot to do? In order to help you, I need to know what is the cBot supposed to do and what it does instead.
Best Regards,
Panagiotis
@PanagiotisCharalampous
alidarvish64@yahoo.com
07 Sep 2018, 10:39
Dear Panagiotis
The result is the same. Even with a million dollars
This is a very simple condition. But I do not know why it does not run.
thanks anyway
@alidarvish64@yahoo.com
alidarvish64@yahoo.com
07 Sep 2018, 08:40 ( Updated at: 21 Dec 2023, 09:20 )
Why does not work?
Thankful
@alidarvish64@yahoo.com