Can help me to code simple stuff ?
Can help me to code simple stuff ?
22 Mar 2017, 15:24
hellow :) i need some help from coders
i want to close position when the price now cross the Kijun Line. Thanks ^^
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class MidasIndex : Robot
{
[Parameter(DefaultValue = 9)]
public int periodFast { get; set; }
[Parameter(DefaultValue = 26)]
public int periodMedium { get; set; }
[Parameter(DefaultValue = 52)]
public int periodSlow { get; set; }
[Parameter(DefaultValue = 1000)]
public int Volume { get; set; }
[Parameter("Stop Loss", DefaultValue = 20)]
public int StopLossPips { get; set; }
[Parameter("Take Profit", DefaultValue = 25)]
public int TakeProfitPips { get; set; }
IchimokuKinkoHyo ichimoku;
protected override void OnStart()
{
ichimoku = Indicators.IchimokuKinkoHyo(periodFast, periodMedium, periodSlow);
}
protected override void OnBar()
{
var positionsBuy = Positions.FindAll("Buy");
var positionsSell = Positions.FindAll("Sell");
var distanceFromUpKumo = (Symbol.Bid - ichimoku.SenkouSpanA.Last(26)) / Symbol.PipSize;
var distanceFromDownKumo = (ichimoku.SenkouSpanA.Last(26) - Symbol.Ask) / Symbol.PipSize;
var distanceFromKijun = ichimoku.KijunSen;
if (positionsBuy.Length == 0 && positionsSell.Length == 0)
{
if (MarketSeries.Open.Last(1) <= ichimoku.SenkouSpanA.Last(27) && MarketSeries.Open.Last(1) > ichimoku.SenkouSpanB.Last(27))
{
if (MarketSeries.Close.Last(1) > ichimoku.SenkouSpanA.Last(27))
{
if (distanceFromUpKumo <= 30)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Buy", StopLossPips, TakeProfitPips);
}
}
}
if (MarketSeries.Open.Last(1) >= ichimoku.SenkouSpanA.Last(27) && MarketSeries.Open.Last(1) < ichimoku.SenkouSpanB.Last(27))
{
if (MarketSeries.Close.Last(1) < ichimoku.SenkouSpanA.Last(27))
{
if (distanceFromDownKumo <= 30)
{
ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "Sell", StopLossPips, TakeProfitPips);
}
}
}
}
}
}
}
Replies
brunoamancio.ti
13 Apr 2017, 21:20
You should practice more programming first. Try refactoring your code so that it is easier to read it and understand it. Nobody will help you with that spaghetti.
@brunoamancio.ti
handiphangceo@gmail.com
23 Mar 2017, 05:48
help pleaseee > . <
@handiphangceo@gmail.com