Topics
Forum Topics not found
Replies
pedroesplago
22 Aug 2022, 16:01
RE:
PanagiotisCharalampous said:
Sir Thank you soo much this will help to analyzed which cbot is more profitable.
@pedroesplago
pedroesplago
21 Aug 2022, 05:46
RE: Martingale that always Buy
CAN SOMEONE HELP EDIT THE CODE OF MARTINGALE INSTEAD OF RANDOM I WANT IT BUY ONLY CONTINUOSLY, PLEASEEEE
@pedroesplago
pedroesplago
21 Aug 2022, 05:32
RE:
Can you solved that code instead of random trade can you make it buy only simulteneously
@pedroesplago
pedroesplago
20 Aug 2022, 16:38
RE: Martingale that execute Buys only
PanagiotisCharalampous said:
Hi thamimsibi3,
Try NormalizeVolume function. It will return you a valid volume for trading.
Best Regards,
Panagiotis
Hi Sir a pleasant day to you! would you mind if you can make a code that execute from the start of the trade is buy on not random and what ever the outcomes tp/sl must execute buy only. Thank you so much!
@pedroesplago
pedroesplago
20 Aug 2022, 16:04
RE: Martingale that always Buy/Sell
PanagiotisCharalampous said:
Hi thamimsibi3,
Try NormalizeVolume function. It will return you a valid volume for trading.
Best Regards,
Panagiotis
Hi Sir a pleasant day to you! would you mind if you can make a code that always buys only no matter what is the outcome
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)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
public double InitialQuantity { get; set; }
[Parameter("Stop Loss", DefaultValue = 3)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 3)]
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 != Symbol.Name)
return;
if (position.GrossProfit > 0)
{
ExecuteOrder(InitialQuantity, position.TradeType);
}
else
{
if (position.TradeType == TradeType.Sell)
ExecuteOrder(position.Quantity * 2, TradeType.Buy);
else
ExecuteOrder(position.Quantity * 2, TradeType.Sell);
}
}
private TradeType GetRandomTradeType()
{
return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
}
}
}
@pedroesplago
pedroesplago
22 Aug 2022, 16:09
RE:
Sir I just want also to share to you about your code from you previous conversation with someone else here in this forum. It works perfectly when you backtest it from Aug 2021 upto today for EUR/USD
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)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
public double InitialQuantity { get; set; }
[Parameter("Stop Loss", DefaultValue = 3)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 3)]
public int TakeProfit { get; set; }
private Random random = new Random();
protected override void OnStart()
{
Positions.Closed += OnPositionsClosed;
ExecuteOrder(InitialQuantity, TradeType.Buy);
}
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 != Symbol.Name)
return;
if (position.GrossProfit > 0)
{
ExecuteOrder(InitialQuantity, TradeType.Buy);
}
else
{
ExecuteOrder(position.Quantity * 2, TradeType.Buy);
}
}
private TradeType GetRandomTradeType()
{
return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
}
}
}
@pedroesplago