Description
yutttttttttttttiy
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 CCIReversal : Robot
{
[Parameter(DefaultValue = 26)]
public int cciPeriod { get; set; }
[Parameter(DefaultValue = 9)]
public int maPeriod { get; set; }
[Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("Trading Side", DefaultValue = 2, MinValue = 0, MaxValue = 2, Step = 1)]
public int tradeSize { get; set; }
private CommodityChannelIndex cci;
//private Position _position;
private const string robotname = "CCIReversal";
private int side;
//private int magic;
protected override void OnStart()
{
cci = Indicators.CommodityChannelIndex(cciPeriod);
side = tradeSize;
}
protected override void OnBar()
{
var longPos = Positions.Find(robotname, Symbol, TradeType.Buy);
var shortPos = Positions.Find(robotname, Symbol, TradeType.Sell);
var pre_cci = cci.Result.Last(2);
var cur_cci = cci.Result.Last(0);
Print("CCI = " + cur_cci + " Pre CCI" + pre_cci);
if ((cci.Result.HasCrossedAbove(-100.0, 1) && cur_cci > pre_cci) || (cci.Result.HasCrossedAbove(100.0, 1) && cur_cci > pre_cci))
{
if (shortPos != null)
{
ClosePosition(shortPos);
if (side == 1 || side == 2)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, robotname);
}
}
else if (longPos == null)
{
if (side == 1 || side == 2)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, robotname);
}
}
else if (longPos != null)
{
/*if (side == 1 || side == 2)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, robotname);
}*/
}
Print("con1");
}
else if ((cci.Result.HasCrossedBelow(-100.0, 1) && cur_cci < pre_cci) || (cci.Result.HasCrossedBelow(100, 1) && cur_cci < pre_cci))
{
if (longPos != null)
{
ClosePosition(longPos);
if (side == 0 || side == 2)
{
ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, robotname);
}
}
else if (shortPos == null)
{
if (side == 0 || side == 2)
{
ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, robotname);
}
}
else if (shortPos != null)
{
/*if (side == 0 || side == 2)
{
ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, robotname);
}*/
}
Print("con2");
}
Print("Long" + (longPos != null));
Print("Short" + (shortPos != null));
}
private long VolumeInUnits
{
get { return Symbol.QuantityToVolume(Quantity); }
}
private void cci_reversal()
{
}
}
}
YU
yuriykirienko10
Joined on 06.12.2016
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: CCI Reversal.algo
- Rating: 0
- Installs: 2112
- Modified: 13/10/2021 09:54
Warning! Running cBots downloaded from this section may lead to financial losses. Use them at your own risk.
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
JS
[url=https://www.googl.com/]Google[/url]
[abc]
https://www.google.com
Google
[Google](https://www.google.com)
ZU
of fighters to grace the Manny Pacquiao vs Shane Mosley Pay Per View event scheduled todaytours in Riga
HA
I have to say this post was certainly informationrmative and contains useful content for enthusiastic visitors. I will definitely bookmark this site for future reference and further viewing. cheers a bunch for sharing this with us! 비아마켓
GI
Professional Best House cleaning Sydney We provide trusted and professional House cleaner near me services across Sydney at Affordable Prices.
I’m a blog crazed person and i love to read cool blog like yours.*:,::egr and dpf delete kits