Topics
Replies
firemyst
05 Sep 2020, 16:01
That's what cTrader does by default.
If it's not, then:
1) you might be running cTrader on multiple computers using the same workspace, and thus the "last one to save wins", meaning it could be overwriting your bot instances.
2) Try uninstalling and reinstalling cTrader.
3) Tag @Panagiotis as he can help you resolve the issue if the above two points don't.
@firemyst
firemyst
05 Sep 2020, 15:51
( Updated at: 23 Jan 2024, 13:16 )
RE: New creation, Prophetie for a +200% return over 2 years.
brasjulianescobar said:
Hey everyone, check out my new creation on [https://ctrader.com/algos/cbots/show/2316].
If you have any suggestion, please comment! :)
Thank you, happy trading!
How about posting a link that actually works? :-)
@firemyst
firemyst
04 Sep 2020, 09:48
( Updated at: 21 Dec 2023, 09:22 )
RE:
ghazisameer said:
Please explain how I can delete custom indicators from CTrader indicator list. My list of indicators in the Custom list is getting way too big.
In cTrader v 3.x: go into the automate tab on the left side, switch to "indicators" instead of "bots", find the indicator you want to delete, and then delete it.
@firemyst
firemyst
04 Sep 2020, 09:43
( Updated at: 21 Dec 2023, 09:22 )
RE:
DelTrader said:
Good night,
How can i mark the chart where breakeven is? (Imagining the price will continue goes up)
There is order of loss (Sell) and two of profit (Buy).
In the possibility of adding another order, the current breakeven update this Symbol, eg EURUSD.Im sorry for my English!
Thank you so much
When you calculate the break-even point, use Chart.DrawHorizontalLine to draw a line across the chart.
@firemyst
firemyst
04 Sep 2020, 09:39
RE:
myinvestmentsfx said:
Hi Guys,
I just want to establish whether or not its normal to wait 10 seconds+ to collect Mutli Symbol, Multi Timeframe information from the MarketData.GetSeries API.
See code below used as an example (Apologies code still a bit messy), once I enter the loop, to get past the first task in the loop can take up to 10 seconds.
I understand that latency, bandwidth and computing power all play a roll in the overall speed the code will execute. But from my testing it points to Multi Symbol, Multi Timeframe API's that's a little slow. If spotware can have a look it will be greatly appriciated.
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using System.Collections.Generic; namespace cAlgo { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewIndicator : Indicator { //////////////////////////////////////////////////////////////////////////////// /// USER PARAMETERS /// //////////////////////////////////////////////////////////////////////////////// protected override void Initialize() { PAIR_ANALYSIS(); } public override void Calculate(int index) { } private void PAIR_ANALYSIS() { //////////////////////////////////////////////////////////////////////////////// /// CHECK PAIR UP FOR TODAY & CHECK ATR REACHED /// //////////////////////////////////////////////////////////////////////////////// var start_time = Server.Time; double hposition = 1; List<Symbol> _all_symbol_codes = new List<Symbol>(); List<MarketSeries> _all_symbol_daily = new List<MarketSeries>(); List<MarketSeries> _all_symbol_5min = new List<MarketSeries>(); List<AverageTrueRange> _all_symbol_atr_daily_indicator = new List<AverageTrueRange>(); List<double> _all_atr_daily_results = new List<double>(); List<double> _all_daily_last_opens = new List<double>(); List<double> _all_5min_last_opens = new List<double>(); List<double> _all_daily_last_highs = new List<double>(); List<double> _all_daily_last_lows = new List<double>(); List<double> _all_daily_high_minus_daily_atr = new List<double>(); List<double> _all_daily_low_add_daily_atr = new List<double>(); List<string> _all_price_up_down = new List<string>(); List<string> _atr_reached_not_reached = new List<string>(); List<string> _all_symbol_names = new List<string>(); _all_symbol_codes.InsertRange(_all_symbol_codes.Count, new Symbol[] { MarketData.GetSymbol("EURUSD"), MarketData.GetSymbol("GBPUSD"), MarketData.GetSymbol("USDCHF"), MarketData.GetSymbol("USDJPY"), MarketData.GetSymbol("USDCAD"), MarketData.GetSymbol("AUDUSD"), MarketData.GetSymbol("GBPJPY"), MarketData.GetSymbol("EURJPY"), MarketData.GetSymbol("NZDUSD"), MarketData.GetSymbol("AUDJPY") }); for (int index = 0; index < _all_symbol_codes.Count; index++) { var Step_1 = Server.Time; Print("The Server Time Start Loop: {0}", Step_1 - start_time); _all_symbol_daily.Add(MarketData.GetSeries(_all_symbol_codes[index], TimeFrame.Daily)); var Step_2 = Server.Time; Print("The Server Get MarketData For Daily Timeframe Step 1: {0}", Step_2 - start_time); _all_symbol_5min.Add(MarketData.GetSeries(_all_symbol_codes[index], TimeFrame.Minute5)); _all_symbol_atr_daily_indicator.Add(Indicators.AverageTrueRange(_all_symbol_daily[index], 5, MovingAverageType.Exponential)); _all_atr_daily_results.Add(_all_symbol_atr_daily_indicator[index].Result.LastValue); _all_daily_last_opens.Add(_all_symbol_daily[index].Open.Last(0)); _all_daily_last_highs.Add(_all_symbol_daily[index].High.Last(0)); _all_daily_last_lows.Add(_all_symbol_daily[index].Low.Last(0)); _all_daily_high_minus_daily_atr.Add(_all_daily_last_highs[index] - _all_atr_daily_results[index]); _all_daily_low_add_daily_atr.Add(_all_daily_last_lows[index] + _all_atr_daily_results[index]); _all_5min_last_opens.Add(_all_symbol_5min[index].Open.Last(0)); hposition -= 0.1; if (_all_daily_last_opens[index] > _all_5min_last_opens[index]) { _all_price_up_down.Add(_all_symbol_codes[index] + " | " + "Down"); } else { _all_price_up_down.Add(_all_symbol_codes[index] + " | " + "Up"); } if ((_all_daily_last_highs[index] > _all_daily_low_add_daily_atr[index]) || (_all_daily_last_lows[index] < _all_daily_high_minus_daily_atr[index])) { _atr_reached_not_reached.Add("ATR Reached"); } else { _atr_reached_not_reached.Add("ATR --NOT-- Reached"); } } string _all_price_up_down_results = string.Join("\n", _all_price_up_down); string _all_atr_reached_not_reached = string.Join("\n", _atr_reached_not_reached); ChartObjects.DrawText("UP or Down", _all_price_up_down_results, StaticPosition.TopLeft, Colors.Blue); ChartObjects.DrawText("ATR", _all_atr_reached_not_reached, StaticPosition.TopCenter, Colors.Green); _all_symbol_daily.Clear(); _all_symbol_5min.Clear(); _all_symbol_atr_daily_indicator.Clear(); _all_atr_daily_results.Clear(); _all_daily_last_opens.Clear(); _all_daily_last_highs.Clear(); _all_daily_last_lows.Clear(); _all_daily_high_minus_daily_atr.Clear(); _all_daily_low_add_daily_atr.Clear(); _all_5min_last_opens.Clear(); _all_price_up_down.Clear(); _atr_reached_not_reached.Clear(); } } }Kind Regards,
It could depending on your connection and the response time of the cTrader servers.
What you might consider doing is using "MarketData.GetBarsAsync" instead. So then you can process each atr and show it as its data comes in. Otherwise, you have to wait until everything is received before data is shown.
@firemyst
firemyst
04 Sep 2020, 09:37
RE:
kdcp999 said:
I am trying ti figureout how to initialise multipl MACDCrossover Indicators for differen timeframes?
Because the MacdCrossover indicator takes a DataSeries which doesn't seem to be created based on any given time frame how do you acheive this?
DataSeries _data_series = Robot.CreateDataSeries(); MacdCrossOver_indicator = Robot.Indicators.MacdCrossOver( _data_series, LongCyclePeriod, ShortCyclePeriod, SignalPeriod ) //no time frame indication here.
How does the MACDCrossover know that you want a 4hour macdcrossover indictor as apoosed to a 2 hour MacdCrossover indicator?
Any help would be muchaprreciated.
David
It knows based on the data series you pass into it.
Instead of creating a data series, you need to pass it one.
Example:
MarketData.GetBars(Bars.TimeFrame, Symbol.Name).ClosePrices
@firemyst
firemyst
04 Sep 2020, 09:07
( Updated at: 21 Dec 2023, 09:22 )
RE:
WienAT said:
Dear all,
I am testing one bot and there is one thing that is not really clear to me:
I open position with following command:
ExecuteMarketOrder(TradeType.Buy, position.SymbolName, volume, "Buy");
Since there is no option that I execute trade with already setted SL price and TP price (i do not want to set number of pips for TP and SL) I am doing following:
Positions[Positions.Count - 1].ModifyStopLossPrice(entrypositionprice);
Positions[Positions.Count - 1].ModifyTakeProfitPrice(takeprofitprice);In this case both SL price and TP price are correctly moved. I see also in debugger Visual Studio:
But if I check my console in Ctrader i see following:
What could be wrong?
Regards
What could be wrong if you could have multiple positions open, which I can see from your bottom screen capture you do.
How do you know what position is in "Positions[Positions.Count - 1]"?
When you increase a position size, or open a new position, the position of your "Buy" position could change in the Positions object.
So you need to check the name of the position at "Positions[Positions.Count - 1]" or you need to search the Positions object for your specific label "Buy".
Example:
Position myPosition = Positions.Find("Buy", Symbol.Name);
@firemyst
firemyst
04 Sep 2020, 09:03
RE:
Mr4x said:
Hi,
I have what I think is a fairly simple request but cannot for the life of me figure it out.
I am basically looking to have an expression built in to my bot that allows me to execute only buy trades when market is above moving average, and only sell trades when market is below a defined moving average. There is no requirement to close any open trades when crossing the MA or anything like that.
I have tried building one using the code in the Sample Trend cBot included with cTrader but the problem is it will still only let me place one trade in either direction when moving average is crossed. It also uses a fast and slow moving average, which is irrelevant to me as I only need 1 moving average
So for example:
if CurrentMovingAverage <= DefinedMovingAverage
ProcessSell();
if CurrentMovingAverage >= DefinedMovingAverage
ProcessBuy();
I can provide more code if required for context / troubleshooting.
Many thanks,
Mr4x
You need to say:
//In your OnTick or OnBar event for bots depending on whether you want to check every tick or every bar
if (Bars.ClosePrices.Last(0) > MovingAverage.Result.Last(0))
{
//the code to execute when price is above the moving average
}
else if (Bars.ClosePrices.Last(0) < MovingAverage.Result.Last(0))
{
//the code to execute when price is below the moving average
}
else
{
//what you want to do, if anything, when the MA == the currency closing/tick price.
//rare event, but could happen so have to account for it!
}
@firemyst
firemyst
04 Sep 2020, 08:46
RE:
HumanArsenal said:
Hi There, Can You Guys Enable Us To Be Able To Edit The Fibonacci Retracement And Expansion And Be Able To Name Levels Ourselves, See How It Displays Price Right Next To The Levels? Can We Rather Have A Text Next To A Level Like That Instead Of Price.
Out of curiosity, what would you like there in terms of text?
Do you want to put your own text? Or some predefined text?
@firemyst
firemyst
04 Sep 2020, 02:52
RE:
fang0092 said:
Hi. I can't seem to print out elements inside the list.
var temp_list = new List<dynamic>(); temp_list.Add(new List<dynamic> { "abc", "def", "ghi", "jkl" }); string sentence = "this is a sentence"; temp_list.Add(sentence); temp_list.Add("isn't that a phrase?"); string type_templist = temp_list.GetType().ToString(); foreach (var higher_than_item in temp_list) { if (higher_than_item.GetType().ToString() == "System.Collections.Generic.List`1[System.Object]") { foreach (var item in higher_than_item) { // this print statement and the one below seems to be causing the error. temporarily made into a comment. help. -> Print(item); } } else { // one of the print statement to be causing the error. temporarily made into a comment. help. -> Print(higher_than_item); } }
If this is in an Indicator or Bot, you have to give it full security access to print the object and its underlying properties:
[Indicator(IsOverlay = false, AccessRights = AccessRights.FullAccess)]
If you're not using Visual Studio to debug, you should also try using exception handling to catch your errors and print out the exception which should hopefully help you in the future:
foreach (var item in higher_than_item)
{
// this print statement and the one below seems to be causing the error. temporarily made into a comment. help. ->
try {
Print(item);
}
catch (Exception e)
{
Print(e.ToString());
}
}
@firemyst
firemyst
03 Sep 2020, 04:59
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi firemyst,
But you just told me there's no way to accomplish the logic without having two dataseries objects to use interchangeably for the same trend:
Yes because you are using the wrong tool for the job. You are trying to display discontinuous lines with continuous data series. Why don't you use trendlines instead?
if (Result[index] > Result[index - 1]) { Chart.IndicatorAreas[0].DrawTrendLine(index.ToString(), Bars.OpenTimes[index - 1], Result[index - 1], Bars.OpenTimes[index], Result[index], Color.Green); } if (Result[index] < Result[index - 1]) { Chart.IndicatorAreas[0].DrawTrendLine(index.ToString(), Bars.OpenTimes[index - 1], Result[index - 1], Bars.OpenTimes[index], Result[index], Color.Red); }
Best Regards,
Panagiotis
Your right in that those would work. But that kind of defeats the purpose of having an indicatordataseries with "discontinuous lines" for plotting. So developers have to add in extra parameters for line style, plot type, color, thickness, etc to chart, since the API doesn't allow for us to obtain those properties from the IndicatorDataSeries objects.
In otherwords, It would be great to be able to avoid cluttering up the parameter interface with the associated parameters users can't even see the preview of:
Unless there's another way to do it or a way from the API to get the settings from the IndicatorDataSeries settings under "Lines"?
@firemyst
firemyst
02 Sep 2020, 16:17
RE:
PanagiotisCharalampous said:
Hi firemyst,
So essentially every developed cTrader indicator that uses different data series for up/down colors will have this issue?
No. This not a problem with cTrader but with your logic. So there is nothing to resolve here. cTrader leaves gaps when there are no values in the data series. But you leave no gaps, therefore there is no way cTrader to know that you do not want a line to be drawn. If your dataseries has values then cTrader will join the dots.
Best Regards,
Panagiotis
"No. This not a problem with cTrader but with your logic."
But you just told me there's no way to accomplish the logic without having two dataseries objects to use interchangeably for the same trend:
"The only way I can think of to get around this is to use two IndicatorDataSeries for each case and use them interchangeably"
That means I need two separate indicator dataseries for the uptrend and two separate indicator downseries for the downtrend:
If I understand correctly, that means at least 4 Indicatordataseries objects just to draw two lines correctly?
If there's an error with my logic, are you able to post or show me an example where it works with the alternating color lines properly drawn with the data I provided in the sample code?
Thank you,
@firemyst
firemyst
02 Sep 2020, 12:31
RE:
PanagiotisCharalampous said:
Hi firemyst,
The only way I can think of to get around this is to use two IndicatorDataSeries for each case and use them interchangeably so that gaps are maintained.
Best Regards,
Panagiotis
So essentially every developed cTrader indicator that uses different data series for up/down colors will have this issue?
Thanks for your suggestion @Panagiotis, but as I think you understand it isn't really practical to have two dataseries for "up" colors and two dataseries for "down" colors and having to interchange them..
Is this functionality something Spotware is working on to resolve?
I mean, every other platform out there allows for separate up/down colors in their indicators without this issue.
Why is it so hard to include it within cTrader?
Thank you.
@firemyst
firemyst
02 Sep 2020, 08:43
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi firemyst,
You are missing the case where the values are equal :)
Best Regards,
Panagiotis
HI @Panagiotis:
I don't think it's that simple because I had some code for the equal scenario.
Here's why. Look at the graphic below:
Point "A" is -2; "B" is 2; "C" is 0.
So at those points ResultsDownTrend[index] is -2, 2, and 0 respectively.
A has to be -2 because it's coming down from the previous point.
B has to be 2 because it's going down to point C.
cTrader is then automatically drawing the line between values A & B because both A & B have values for the preceeding/postceeding points even though I don't want the line drawn between those two points.
How do we get around this?
@firemyst
firemyst
02 Sep 2020, 08:24
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi firemyst,
Yes it is. I don't see anything wrong. Can you elaborate?
Best Regards,
Panagiotis
Hi @Panagiotis:
In the sample screen capture above, the expected output is that all lines going up should be green, all the lines going down should be red as shown below:
However, I'm unable to get the simple code above to do what I want.
What am I missing?
Thank you.
@firemyst
firemyst
01 Sep 2020, 17:55
RE:
luca.tocchi said:
how do i check the direction of the moving averages in real time and if they go high i go buy if they go low i sell?
Thanks a lot
You get the current value of the MA and can compare it to the previous value to see if it's increasing or decreasing.
//example pseudo-code
if (ma.Result.Last(0) > ma.Result.Last(1))
//open long position
else if (ma.Result.Last(0) < ma.Result.Last(1))
//open short position
else
//the ma values are equal. What do you want to do?
@firemyst
firemyst
07 Sep 2020, 05:41
RE:
ctid2033788 said:
1) It might not be updated for any number of reasons. For example, what if the SL is moved to be within the symbol's spread? What if you're trying to move the SL by a very small or invalid amount?
-2 vs 2 might seem backwards, but that's how it works.
2) Again, where are you placing your SL in relation to the current bid/ask price? Or from it's last location? Have you noted what the old value was, what the old value is you want to move it to, and looked at the charts to see if it is valid? If you're in a sell, are you trying to move the SL below the bid price? If you're in a buy, are you trying to move the SL above the ask price?
You need to post code if you still can't figure it out.
@firemyst