volume information retrieval
Created at 07 Dec 2022, 10:59
GR
volume information retrieval
07 Dec 2022, 10:59
Hello, I'm new here and I'm starting to create my own trading bot, it's the first time I'm getting into C#, I more or less understand how it works but I'm facing a small problem.
On the bot that I try to create, I would like to make it enter in position when the volume indicator is higher than 215 but I can't understand how to get the information of this one, in the indicators I see all the volume indicators but not the simple one, the one that has automatically on the charts, if someone could give me a hand thanks.
PS : sorry the comments are in french in the code lol
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class RobotVolumeDow : Robot
{
[Parameter("Initialisation", DefaultValue = "salut beau gosse")]
public string Message { get; set; }
[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; }
[Parameter("Add Pips", Group = "Break Even", DefaultValue = 0.0, MinValue = 0.0)]
public double AddPips { get; set; }
[Parameter("Trigger Pips", Group = "Break Even", DefaultValue = 10, MinValue = 1)]
public double TriggerPips { get; set; }
[Parameter("MA Type", Group = "Moyenne Mobile")]
public MovingAverageType MAType { get; set; }
[Parameter("Source", Group = "Moyenne Mobile")]
public DataSeries SourceSeries { get; set; }
[Parameter("Slow Periods", Group = "Moyenne Mobile", DefaultValue = 70)]
public int SlowPeriods { get; set; }
private MovingAverage slowMa;
[Parameter("Fast Periods", Group = "Moyenne Mobile", DefaultValue = 30)]
public int FastPeriods { get; set; }
private MovingAverage fastMa;
[Parameter("source", Group = "Niveau de Volume")]
public DataSeries SourceVolume {get; set; }
[Parameter("Niveau de Volume", Group = "Niveau de Volume", DefaultValue = 215)]
public int NiveauVolume { get; set; }
[Parameter("Heure de Début", Group = "Horaire", DefaultValue = 15, MinValue = 00, MaxValue = 24, Step = 1)]
public int HeureDeDebut { get; set; }
[Parameter("Minute de Début", Group = "Horaire", DefaultValue = 30, MinValue = 00, MaxValue = 60, Step = 1)]
public int MinuteDeDebut { get; set; }
[Parameter("Heure de Fin", Group = "Horaire", DefaultValue = 21, MinValue = 00, MaxValue = 24, Step = 1)]
public int HeureDeFin { get; set; }
[Parameter("Minute de Fin", Group = "Horaire", DefaultValue = 30, MinValue = 00, MaxValue = 60, Step = 1)]
public int MinuteDeFin { get; set; }
protected override void OnStart()
{
fastMa = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
slowMa = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
}
protected override void OnTick()
{
}
protected override void OnBar()
{
if (SlowPeriods > FastPeriods && Server.Time.Hour > HeureDeDebut && Server.Time.Minute > MinuteDeDebut
&& Server.Time.Hour < HeureDeFin && Server.Time.Minute < MinuteDeFin)
ExecuteMarketOrder(TradeType.Buy, SymbolName, InitialQuantity, "RobotVolumeDow", StopLoss, TakeProfit);
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}