Description
FINALLY.!!!!!!! I have successfully been able to code this. It has no sell or buy algorithm or strategy. THIS IS A TEMPLATE YOU CAN PUT YOUR STRATEGY IN ONBAR, OR WHEREVER. LET IT DO ITS MAGIC. COMMENT PLEASE Its my first post On CBOTS. I give it for FREE FREE FREE
KINDLY Donate any amount my paypal - Davidmwabuka@gmail.com
If you have a strategy you want me to code it for you, EMAIL ME, check me on whatsapp, phone number is on top of this cbot section.
// copyright: Lawrence Mujari(David MWABUKA)
//
// Break even with trailling
///
// Donate any amount my paypal - Davidmwabuka@gmail.com
///
//// If you want me to code your strategy check me on whatsapp +255717441440 Very affordable price
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class BreakevenTrailingRobot : Robot
{
[Parameter("Breakeven Pips", DefaultValue = 10)]
public int BreakevenPips { get; set; }
[Parameter("Trailing Stop Pips", DefaultValue = 10)]
public int TrailingStopPips { get; set; }
private Position position;
protected override void OnStart()
{
position = null;
}
protected override void OnTick()
{
if (position == null)
{
// If we don't have a position, check if we should open one
if (IsBuySignal())
{
var volumeInUnits = Symbol.QuantityToVolume(1);
var result = ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, "Buy", null, null);
position = result.Position;
}
else if (IsSellSignal())
{
var volumeInUnits = Symbol.QuantityToVolume(1);
var result = ExecuteMarketOrder(TradeType.Sell, Symbol, volumeInUnits, "Sell", null, null);
position = result.Position;
}
}
else
{
// If we have a position, check if we need to adjust the stop loss
if (position.TradeType == TradeType.Buy)
{
var stopLossPrice = (byte)Math.Max(position.EntryPrice + Symbol.PipSize * BreakevenPips, position.StopLoss ?? 0);
var takeProfitPrice = position.EntryPrice + Symbol.PipSize * TrailingStopPips;
var result = ModifyPosition(position, stopLossPrice, takeProfitPrice, false);
if (result.IsSuccessful)
{
position = result.Position;
}
}
else if (position.TradeType == TradeType.Sell)
{
var stopLossPrice = (byte)Math.Min(position.EntryPrice - Symbol.PipSize * BreakevenPips, position.StopLoss ?? 0);
var takeProfitPrice = position.EntryPrice - Symbol.PipSize * TrailingStopPips;
var result = ModifyPosition(position, stopLossPrice, takeProfitPrice, false);
if (result.IsSuccessful)
{
position = result.Position;
}
}
}
}
private bool IsBuySignal()
{
// Check if the current bar is the first bar of the day
if (MarketSeries.OpenTime.Last(1).Day != MarketSeries.OpenTime.LastValue.Day)
{
return true;
}
return false;
}
private bool IsSellSignal()
{
// Insert your sell signal logic here
return false;
}
}
}
davidmwabuka
Joined on 07.03.2023
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: BREAKevernTRAIILLING WORKING (template).algo
- Rating: 0
- Installs: 834
- Modified: 21/04/2023 07:52
Comments
vI like the way you conduct your posts. Hmm… v starting a credit card processing company
glad to be one of the visitors on this amazing internet site : D.Packers and Movers Delhi
I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!.샌즈카지