indicator MarketData GetSymbol
indicator MarketData GetSymbol
03 May 2017, 19:39
Hello
I have almost finished my cbot with several symbols ..
I have coded a small indicator bar with instant opening which must function independently for each pair, indices ...
The problem .... when I start the robot all the pairs are in the same direction Buy or Sell.
The indicator is set to the open instance.
For example if the instance is open USD / JPY (chart 15 min) and the trend is Buy (several candles) all the pairs will follow the table and do not work independently even if the tandance is Sell on currency pairs.
The coding of my indicator (which works very well normally) poses problems with Market Data.
An expert has a solution ...
cordially
Piece of code
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Reflection; using System.Threading; using System.Diagnostics; using Microsoft.Win32; using cAlgo.API.Requests; using System.Text; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class SamplecBot : Robot { [Parameter("Volume", DefaultValue = 1000, MinValue = 1000, Step = 1000)] public int Volume { get; set; } private Symbol _symbol1; private void InitializeSeries(string symbolCode) { _symbol1 = MarketData.GetSymbol("GBPUSD"); } protected override void OnStart() { InitializeSeries("GBPUSD"); } protected override void OnTick() { var cBotPositions = Positions.FindAll("777"); if (cBotPositions.Length >= 1) return; ExecuteOrder(Volume, GetTradeCommand()); } private TradeType GetTradeCommand() { var lastIndex = MarketSeries.Close.Count - 1; double close = MarketSeries.Close[lastIndex - 1]; double lastClose = MarketSeries.Close[lastIndex - 2]; return close > lastClose ? TradeType.Buy : TradeType.Sell; } private void ExecuteOrder(double quantity, TradeType tradeType) { var cBotPositions = Positions.FindAll("777"); if (cBotPositions.Length >= 1) return; var result = ExecuteMarketOrder(tradeType, _symbol1, Volume, "777", 240, 60); if (result.Error == ErrorCode.NoMoney) Stop(); } } }