Making a PIN BAR bot
Making a PIN BAR bot
21 Feb 2019, 15:59
Hello all,
Can someone help me code this?
- I need the bot to see the difference between a Bullish pin bar and a bearish pin bar.
- The bot needs to know that a pin bar is 100%.
- I need the possibility to set how much % wick i need in parameter.
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 Parameter { get; set; }
[Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("Stop Loss", DefaultValue = 200)]
public int SL { get; set; }
[Parameter("Takeprofit", DefaultValue = 0, MinValue = 0, Step = 1)]
public int Takeprofit { get; set; }
// Here the parameter for 'X'
private const string label = "PinBar";
protected override void OnStart()
{
}
protected override void OnBar()
{
if (Positions.Count == 0 && // Buy pin bar && Wick = > Parameter)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, SL, Takeprofit, null);
}
else if (Positions.Count == 0 && // Sell pin bar && Wick = > Parameter)
{
ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, SL, Takeprofit, null);
}
}
private long VolumeInUnits
{
get { return Symbol.QuantityToVolume(Quantity); }
}
}
}