Getting the error bad volume.
Getting the error bad volume.
30 Mar 2021, 17:12
Hi ,
Trying to make a cBot to place a trade at a chosen price , with risk of 1 percent of my account.
I keep getting an error saying "BadVolume"
Here is the code i am using:-
Thank you.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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 NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double sellPrice { get; set; }
[Parameter(DefaultValue = 0.0)]
public double stopLevel { get; set; }
[Parameter(DefaultValue = 0.0)]
public double target { get; set; }
[Parameter("Account Risk", DefaultValue = 1.0)]
public double percentRisk { get; set; }
private double riskPerTrade;
private double sellLotSize;
private double distanceInpPipsToStoploss;
protected override void OnStart()
{
//----Calculate distance to stop loss in pips------//
distanceInpPipsToStoploss = stopLevel - sellPrice;
//----Calculate amount of money to risk on trade----//
riskPerTrade = Account.Balance * (percentRisk / 100);
//----Calculate risk about per pip move----//
sellLotSize = riskPerTrade / distanceInpPipsToStoploss;
}
protected override void OnTick()
{
PlaceLimitOrder(TradeType.Sell, Symbol, sellLotSize, target, "selltrade");
}
protected override void OnStop()
{
}
}
}
PanagiotisCharalampous
31 Mar 2021, 08:24
Hi Dom29600,
Try this instead
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous