Adding DMI + SuperTrend
Adding DMI + SuperTrend
23 Nov 2015, 21:32
Hello,
I am new in programmation and i just would like to know how is it possible to add the two indicators SuperTrend and the ADX DMI+ and DMI-. This i the code from cAlgo, i juste want to add the two indicators as conditions :
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 = 1, MinValue = 0.01, Step = 0.01)]
public double InitialQuantity { get; set; }
[Parameter("Stop Loss", DefaultValue = 40)]
public int StopLoss { get; set; }
[Parameter("Take Profit", 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.QuantityToVolume(quantity);
var result = ExecuteMarketOrder(tradeType, Symbol, 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.SymbolCode != Symbol.Code)
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;
}
}
}
Thanks a lot
Spotware
23 Nov 2015, 23:14
Dear Trader,
Please have a look at the Referencing Custom Indicators section of our API Programmers Guides.
Please note that we don't provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You can contact one of our Partners or post a job in Development Jobs section for any coding assistance.
@Spotware