Description
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SimpleMovingAverageRobot : Robot
{
[Parameter("Periods", DefaultValue = 20)]
public int Periods { get; set; }
private MovingAverage _sma;
protected override void OnStart()
{
_sma = Indicators.SimpleMovingAverage(MarketSeries.Close, Periods);
}
protected override void OnBar()
{
if (Positions.Count == 0)
{
if (_sma.Result.Last(1) < _sma.Result.Last(2))
{
ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, "SMA Sell");
}
else if (_sma.Result.Last(1) > _sma.Result.Last(2))
{
ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "SMA Buy");
}
}
else
{
foreach (var position in Positions)
{
if (position.TradeType == TradeType.Sell && _sma.Result.Last(1) > _sma.Result.Last(2))
{
ClosePosition(position);
}
else if (position.TradeType == TradeType.Buy && _sma.Result.Last(1) < _sma.Result.Last(2))
{
ClosePosition(position);
}
}
}
}
}
u
negrium
Joined 30.01.2020
- Type: paid
- Language: C#
- Trading Platform: cTrader Automate
- Filename: Robot_Forex.algo
- Rating: 0
- Downloads: 178
Comments
Hello – Nice site, just looking around some pages, it seems to be a very nice looking theme you are using here. I am presently using WordPress to run a few of my web sites but looking to change one of these over to a theme the same as yours just for a test run. Anything in particular you would suggest about it?how to be a credit card processor
It’s hard to find knowledgeable men and women for this topic, however, you seem like do you know what you’re preaching about! Thankssell credit card machines
Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a bit, but instead of that, this is excellent blog. A fantastic read. I will definitely be back.Packers and Movers Pune to Bhopal
Thank you for sharing my problem has been solved 8 ball pool
I just could not depart your site prior to suggesting that I really enjoyed the usual info an individual provide to your visitors? Is gonna be back incessantly in order to investigate cross-check new posts.Slot Gacor