Topics
Replies
ctid3179522
21 Nov 2021, 10:12
RE:
PanagiotisCharalampous said:
Hi there,
That's normal. Read here. You need to apply rounding.
Best Regards,
Panagiotis
ok thank you
@ctid3179522
ctid3179522
18 Nov 2021, 21:14
RE:
PanagiotisCharalampous said:
Hi there,
Please explain what do you thing s wrong here. The results seem correct to me.
Best Regards,
Panagiotis
The result of 1.15922 - 1.15949 is - 0,00027 not - 0.000269999999999992
@ctid3179522
ctid3179522
18 Nov 2021, 11:34
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi there,
Can you please provide us with examples of these "wrong weird math calculation results"?
Best Regards,
Panagiotis
I took 2 screenshots to show them :
@ctid3179522
ctid3179522
02 Jun 2021, 08:59
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi ctid3179522,
You need to be a bit more specific. What is the exact functionality you are trying to code? Where would you expect trades to open and they don't?
Looking at the following conditions
Symbol.Bid == Bars.HighPrices.Last(2)
Symbol.Bid == Bars.LowPrices.Last(2)
These will rarely be true.
Best Regards,
Panagiotis
The 1st candle must contain the 2nd candle(1st high-low range contains de 2nd) , opens trade in current candle if price hits 1st candle high/low. If 1st candle is bullish than its buy order if its bearish than its sell order. I checked in backtesting and it doesnt open trades when these conditions are met like this year GBP/JPY 4 hour it opens no trades
@ctid3179522
ctid3179522
25 Feb 2021, 12:40
RE: RE:
ctid3179522 said:
PanagiotisCharalampous said:
Hi ctid3179522,
Can you share the cBot code?
Best Regards,
Panagiotis
It is the Sample Martingale bot that comes with Ctrader installation. nothing changed but if you think i mistakenly changed something here it is:
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample Martingale cBot" creates a random Sell or Buy order. If the Stop loss is hit, a new
// order of the same type (Buy / Sell) is created with double the Initial Volume amount. The cBot will
// continue to double the volume amount for all orders created until one of them hits the take Profit.
// After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.
//
// -------------------------------------------------------------------------------------------------
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 SampleMartingalecBot : Robot
{
[Parameter("Initial Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double InitialQuantity { get; set; }
[Parameter("Stop Loss", Group = "Protection", DefaultValue = 40)]
public int StopLoss { get; set; }
[Parameter("Take Profit", Group = "Protection", DefaultValue = 40)]
public int TakeProfit { get; set; }
private Random random = new Random();
protected override void OnStart()
{
Positions.Closed += OnPositionsClosed;
ExecuteOrder(InitialQuantity, GetRandomTradeType());
}
private void ExecuteOrder(double quantity, TradeType tradeType)
{
var volumeInUnits = Symbol.QuantityToVolumeInUnits(quantity);
var result = ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "Martingale", StopLoss, TakeProfit);
if (result.Error == ErrorCode.NoMoney)
Stop();
}
private void OnPositionsClosed(PositionClosedEventArgs args)
{
Print("Closed");
var position = args.Position;
if (position.Label != "Martingale" || position.SymbolName != SymbolName)
return;
if (position.GrossProfit > 0)
{
ExecuteOrder(InitialQuantity, GetRandomTradeType());
}
else
{
ExecuteOrder(position.Quantity * 2, position.TradeType);
}
}
private TradeType GetRandomTradeType()
{
return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
}
}
}
@ctid3179522
ctid3179522
25 Feb 2021, 12:37
RE:
PanagiotisCharalampous said:
Hi ctid3179522,
Can you share the cBot code?
Best Regards,
Panagiotis
It is the Sample Martingale bot that comes with Ctrader installation. nothing changed
@ctid3179522
ctid3179522
14 Dec 2021, 14:26
ok thank you
@ctid3179522