PR
Topics
24 Aug 2022, 05:01
1
711
1
Replies
profitstreet.trade
05 Aug 2022, 06:37
Hello
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(AccessRights = AccessRights.None)]
public class TwoSides : Robot
{
[Parameter(DefaultValue = "TwoSides")]
public string BotName { get; set; }
[Parameter("StopLoss in pips", DefaultValue = 0.00)]
public int StopLoss { get; set; }
[Parameter("TakeProfit in pips", DefaultValue = 50)]
public int TakeProfit { get; set; }
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1000, MinValue = 1000, Step = 1000)]
public double Quantity { get; set; }
protected override void OnStart()
{
Print("CBot Started ");
}
protected override void OnBar()
{
ExecuteMarketOrder(TradeType.Buy,SymbolName,Quantity,BotName,StopLoss,TakeProfit,"MyBot");
ExecuteMarketOrder(TradeType.Sell,SymbolName,Quantity,BotName,StopLoss,TakeProfit,"MyBot");
}
protected override void OnStop()
{
Print("Bot Stopped ");
}
}
}
@profitstreet.trade
profitstreet.trade
14 Aug 2022, 18:31
Just Like this
using System;
using System.Collections.Generic;
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 NewcBot2 : Robot
{
private TradeType Direction = TradeType.Buy;
[Parameter("SMA1 Period")]
public int PeriodsSma1 { get; set; }
[Parameter("SMA2 Period")]
public int PeriodsSma2 { get; set; }
[Parameter("SMA Source")]
public DataSeries Source { get; set; }
private SimpleMovingAverage _sma1 { get; set; }
private SimpleMovingAverage _sma2 { get; set; }
protected override void OnTick()
{
_sma1 = Indicators.SimpleMovingAverage(Source, PeriodsSma1);
_sma2 = Indicators.SimpleMovingAverage(Source, PeriodsSma2);
Print("Decimal ", Symbol.Digits);
if (_sma1.Result.LastValue < _sma2.Result.LastValue)
{
Direction = TradeType.Buy;
}
else
{
Direction = TradeType.Sell;
}
if(Positions.FindAll("CesareLive", SymbolName,Direction).Length == 0)
{
ExecuteMarketOrder(Direction, SymbolName, Symbol.QuantityToVolumeInUnits(0.03), "CesareLive", 4, 4);
}
}
}
}
@profitstreet.trade