MA TYPE PARAMETERS IN THE CLOUD
MA TYPE PARAMETERS IN THE CLOUD
22 Oct 2024, 05:37
Hi. I am having problems, selecting the MA TYPE when running my bot in the cloud.
The MA TYPE works when local. But in the cloud it only shows numbers from 0 to 7. Which I thought were the corresponding positions for the written parameters. But even if.it was. I does not select any other number only 0.
using cAlgo.API;
using cAlgo.API.Indicators;
using System.Collections.Generic;
using System;
namespace cAlgo.Robots
{
public static class MathUtils
{
public static double Max(double a, double b)
{
return a > b ? a : b;
}
public static double Min(double a, double b)
{
return a < b ? a : b;
}
}
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, AddIndicators = true)]
public class BB_RSI_TradeBot : Robot
{
private double _volumeInUnits;
private BollingerBands _bollingerBands;
private RelativeStrengthIndex _rsi;
private DirectionalMovementSystem _adx;
[Parameter("Volume (Lots)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
public double VolumeInLots { get; set; }
[Parameter("Label", DefaultValue = "BB_RSI_TradeBot")]
public string Label { get; set; }
[Parameter("Source", Group = "Bollinger Bands")]
public DataSeries Source { get; set; }
[Parameter("Periods", DefaultValue = 20, MinValue = 1, Group = "Bollinger Bands")]
public int Periods { get; set; }
[Parameter("Standard Deviation", DefaultValue = 2.0, MinValue = 0.0001, MaxValue = 10, Group = "Bollinger Bands")]
public double StandardDeviations { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple, Group = "Bollinger Bands")]
public MovingAverageType MAType { get; set; }
[Parameter("Shift", DefaultValue = 0, MinValue = -1000, MaxValue = 1000, Group = "Bollinger Bands")]
public int Shift { get; set; }
[Parameter("RSI Periods", DefaultValue = 14, MinValue = 1, Group = "RSI")]
public int RsiPeriods { get; set; }
[Parameter("RSI Overbought Level", DefaultValue = 70, MinValue = 0, MaxValue = 100, Group = "RSI")]
public double RsiOverbought { get; set; }
[Parameter("RSI Oversold Level", DefaultValue = 30, MinValue = 0, MaxValue = 100, Group = "RSI")]
public double RsiOversold { get; set; }
[Parameter("ADX Period", DefaultValue = 14, MinValue = 1)]
public int AdxPeriod { get; set; }
[Parameter("ADX Threshold", DefaultValue = 25, MinValue = 1)]
public double AdxThreshold { get; set; }
[Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 0)]
public int StopLossPips { get; set; }
[Parameter("Take Profit (pips)", DefaultValue = 20, MinValue = 0)]
public int TakeProfitPips { get; set; }
[Parameter("Max Open Orders", DefaultValue = 5)]
public int MaxOpenOrders { get; set; }
private Dictionary<string, ChartObject> _chartObjects = new Dictionary<string, ChartObject>();
protected override void OnStart()
{
_volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
_bollingerBands = Indicators.BollingerBands(Source, Periods, StandardDeviations, MAType);
_rsi = Indicators.RelativeStrengthIndex(Source, RsiPeriods);
_adx = Indicators.DirectionalMovementSystem(AdxPeriod);
}
protected override void OnBarClosed()
{
// Find positions for this bot by label and check if maximum open orders limit is reached
var botPositions = Positions.FindAll(Label);
if (botPositions.Length >= MaxOpenOrders)
{
Print("Maximum open orders reached, skipping trade.");
return;
}
var currentPrice = Symbol.Bid;
var bollingerBottom = _bollingerBands.Bottom.Last(0);
var bollingerTop = _bollingerBands.Top.Last(0);
var rsiCurrentValue = _rsi.Result.Last(0);
var adxValue = _adx.ADX.Last(0);
Print("ADX Value: ", adxValue);
if (adxValue > AdxThreshold)
{
Print("Market is trending, skipping trade entry.");
return;
}
TradeType? tradeTypeToExecute = null;
if (Bars.LowPrices.Last(0) <= bollingerBottom && Bars.LowPrices.Last(1) > bollingerBottom)
{
if (rsiCurrentValue < RsiOversold)
{
tradeTypeToExecute = TradeType.Buy;
}
}
else if (Bars.HighPrices.Last(0) >= bollingerTop && Bars.HighPrices.Last(1) < bollingerTop)
{
if (rsiCurrentValue > RsiOverbought)
{
tradeTypeToExecute = TradeType.Sell;
}
}
if (tradeTypeToExecute.HasValue)
{
double? stopLoss = StopLossPips > 0 ? (double?)StopLossPips : null;
double? takeProfit = TakeProfitPips > 0 ? (double?)TakeProfitPips : null;
var result = ExecuteMarketOrder(tradeTypeToExecute.Value, SymbolName, _volumeInUnits, Label, stopLoss, takeProfit);
if (result.IsSuccessful)
{
var position = result.Position;
if (position != null)
{
DrawTradeMarker(position, tradeTypeToExecute.Value);
}
}
else
{
Print("Error executing market order: ", result.Error);
}
}
}
private void DrawTradeMarker(Position position, TradeType tradeType)
{
string markerId = $"TradeMarker_{position.Id}";
double price = position.EntryPrice;
var color = tradeType == TradeType.Buy ? Color.Green : Color.Red;
if (_chartObjects.ContainsKey(markerId))
{
Chart.RemoveObject(markerId);
_chartObjects.Remove(markerId);
}
var entryMarker = Chart.DrawText($"{markerId}_Entry", tradeType == TradeType.Buy ? "Buy" : "Sell", position.EntryTime, price, color);
_chartObjects[markerId] = entryMarker;
double exitPrice = tradeType == TradeType.Buy
? price + TakeProfitPips * Symbol.PipSize
: price - TakeProfitPips * Symbol.PipSize;
var exitMarker = Chart.DrawText($"{markerId}_Exit", "Exit", position.EntryTime.AddMinutes(10), exitPrice, color);
_chartObjects[$"{markerId}_Exit"] = exitMarker;
}
}
}
Replies
GauchoHood
23 Oct 2024, 16:52
( Updated at: 24 Oct 2024, 05:11 )
RE: MA TYPE PARAMETERS IN THE CLOUD
PanagiotisCharalampous said:
Hi there,
I cannot reproduce any problem. Can you share screenshots demonstrating this issue?
Best regards,
Panagiotis
As you can see. In the Cloud. The MA TYPES, Simple, triangular, hull, etc. Can not be selected.
What do you mean, when you said you found no error? Are the MA TYPE SHOWING in the cloud for you? Can you actually select them? Could you share a screen shot? Many thanks PANAGIOTIS!
@GauchoHood
PanagiotisCharalampous
24 Oct 2024, 05:48
RE: RE: MA TYPE PARAMETERS IN THE CLOUD
GauchoHood said:
PanagiotisCharalampous said:
Hi there,
I cannot reproduce any problem. Can you share screenshots demonstrating this issue?
Best regards,
Panagiotis
As you can see. In the Cloud. The MA TYPES, Simple, triangular, hull, etc. Can not be selected.
What do you mean, when you said you found no error? Are the MA TYPE SHOWING in the cloud for you? Can you actually select them? Could you share a screen shot? Many thanks PANAGIOTIS!
Hi there,
Here is a screenshot
Best regards,
Panagiotis
@PanagiotisCharalampous
GauchoHood
24 Oct 2024, 16:28
RE: RE: RE: MA TYPE PARAMETERS IN THE CLOUD
GauchoHood said:
PanagiotisCharalampous said:
Hi there,
I cannot reproduce any problem. Can you share screenshots demonstrating this issue?
Best regards,
Panagiotis
As you can see. In the Cloud. The MA TYPES, Simple, triangular, hull, etc. Can not be selected.
What do you mean, when you said you found no error? Are the MA TYPE SHOWING in the cloud for you? Can you actually select them? Could you share a screen shot? Many thanks PANAGIOTIS!
Hi there,
Here is a screenshot
Best regards,
Panagiotis
@GauchoHood
GauchoHood
24 Oct 2024, 16:30
RE: RE: RE: RE: MA TYPE PARAMETERS IN THE CLOUD
GauchoHood said: Wow, this is Crazy. Any Clues? I use different computers. A Mcbook at work and a PC at Home. And I cant see the option in either of them. Please help. My strategy really depends on it. Many thanks
PanagiotisCharalampous said:
GauchoHood said:
PanagiotisCharalampous said:
Hi there,
I cannot reproduce any problem. Can you share screenshots demonstrating this issue?
Best regards,
Panagiotis
As you can see. In the Cloud. The MA TYPES, Simple, triangular, hull, etc. Can not be selected.
What do you mean, when you said you found no error? Are the MA TYPE SHOWING in the cloud for you? Can you actually select them? Could you share a screen shot? Many thanks PANAGIOTIS!
Hi there,
Here is a screenshot
Best regards,
Panagiotis
@GauchoHood
PanagiotisCharalampous
25 Oct 2024, 05:21
No clues unfortunately. Can you record a video demonstrating the whole UI and the entire process of adding an instance and reproducing the issue? Maybe it can provide some information we are missing
@PanagiotisCharalampous
GauchoHood
15 Nov 2024, 07:42
RE: MA TYPE PARAMETERS IN THE CLOUD
PanagiotisCharalampous said:
No clues unfortunately. Can you record a video demonstrating the whole UI and the entire process of adding an instance and reproducing the issue? Maybe it can provide some information we are missing
Hi Panagiotis, hope you are well. Look. I need help to code an increase with the lotsize while my position progresses. For example, when 2 pips positive, double the lot. But the Chatgpt is saying it is not possible to increase Lotsize in Ctrader. Although, we have a button on Ctrader that do Just that, Double the.position size.
Can you help me please
@GauchoHood
PanagiotisCharalampous
15 Nov 2024, 10:45
RE: RE: MA TYPE PARAMETERS IN THE CLOUD
GauchoHood said:
PanagiotisCharalampous said:
No clues unfortunately. Can you record a video demonstrating the whole UI and the entire process of adding an instance and reproducing the issue? Maybe it can provide some information we are missing
Hi Panagiotis, hope you are well. Look. I need help to code an increase with the lotsize while my position progresses. For example, when 2 pips positive, double the lot. But the Chatgpt is saying it is not possible to increase Lotsize in Ctrader. Although, we have a button on Ctrader that do Just that, Double the.position size.
Can you help me please
Hi there,
Please create a separate thread with your question and make it more specific. Tell me what information is missing and what is stopping you from implementing this yourself so that I can help you.
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
22 Oct 2024, 08:34
Hi there,
I cannot reproduce any problem. Can you share screenshots demonstrating this issue?
Best regards,
Panagiotis
@PanagiotisCharalampous