Martingale strategy plz~~
Martingale strategy plz~~
04 Apr 2015, 09:27
CALGO the Martingale strategy regardless of winning or losing, I hope are random orders, which is suppose to lose, he is still under the hand of doubling the number of orders, but the BUY / SELL random can anybody do this for me?? plz
In other words, I want it to follow the Martingale strategy, once lost to redouble their value, but always random, assuming that buy order lost, than random, sell order lost is random too.
The following is Martin Heidegger policy C # program, in which part do I modify it?
I am Taiwanese, my English is not very good if the expression is unclear interesting again I wish to express
// -------------------------------------------------------------------------------------------------
//
// This code is a cAlgo API sample.
//
// This robot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk
//
// All changes to this file will be lost on next application start.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample Martingale Robot" creates a random Sell or Buy order. If the Stop loss is hit, a new
// order of the same type (Buy / Sell) is created with double the Initial Volume amount. The robot will
// continue to double the volume amount for all orders created until one of them hits the take Profit.
// After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.
//
// -------------------------------------------------------------------------------------------------
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 MartingaleRobot : Robot
{
[Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)]
public int InitialVolume { 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(InitialVolume, GetRandomTradeType());
}
private void ExecuteOrder(long volume, TradeType tradeType)
{
var result = ExecuteMarketOrder(tradeType, Symbol, volume, "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(InitialVolume, GetRandomTradeType());
}
else
{
ExecuteOrder((int)position.Volume * 2, position.TradeType);
}
}
private TradeType GetRandomTradeType()
{
return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
}
}
}
Spotware
06 Apr 2015, 12:52
We can recommend you to contact one of our Partners or post a job in Development Jobs section.
@Spotware