Topics
Replies
firemyst
28 Mar 2023, 03:20
RE:
PanagiotisChar said:
Hi there,
At the moment there is no event raised at the moment a bar closes. A workaround would be to implement a Timer that is triggered on fixed intervals which coincide with a bar closing time.
Need help? Join us on Telegram
Need premium support? Trade with us
Or if you're using a chart that doesn't involve time like Renko and Range bars where a timer isn't practical, you can see how well the Bar Open event works for you because obviously when a new bar opens, the previous bar is closed.
@firemyst
firemyst
27 Mar 2023, 16:25
You can try doing:
//Pseudo code
//Get the start index you want to search from
int startIndex = Bars.OpenTimes.GetIndexByTime( <enter your start date/time value here> );
//get the end index corresponding to the ending date/time you want
int endIndex = Bars.OpenTimes.GetIndexByTime( <enter your end date/time value here> );
//Now go through every bar
for (int x=startIndex; x <= endIndex; x++)
{
// put your logic here that you want to do
}
@firemyst
firemyst
27 Mar 2023, 06:55
( Updated at: 27 Mar 2023, 15:40 )
RE: RE: RE: RE: RE: RE:Impulse MACD
jani said:
Anyone interested in cTrader version of Impuse MACD can contact me at Telegram: @Fibonacci2011
Or they can just search the archive of indicators others have developed and download for free at their convenience:
@firemyst
firemyst
15 Mar 2023, 04:26
RE: RE:
algo-trader said:
PanagiotisChar said:
Hi there,
Can you share the cBot code?
Need help? Join us on Telegram
Need premium support? Trade with us
Hi,
I've sorted the issue now but thank you for your response.
For future reference, are you able to post the solution on how you did it so if others have the same issue they know what to do?
@firemyst
firemyst
15 Mar 2023, 04:09
RE: RE:
notzen said:
I am also available for a webex or google meet or zoom session where you can expect the issue locally
Spotware said:
Hi notzen,
Can we have a complete cBot that will allow us to reproduce these exceptions?
Best regards,
cTrader Team
As a suggestion, any reason why you can't send @Spotware a slimmed down, minimal version of code that shows the issue?
@firemyst
firemyst
12 Mar 2023, 12:24
It's not very complex.
Doing a Google search, there's a similar one:
Perhaps you could contact that author to see if they'd be willing to do it for you.
If not, you should contact @PanagiotisChar
It would also help if you updated your post with the link to the original indicator on TradingView (assuming that's where you got it from since LazyBear is very active there)
@firemyst
firemyst
12 Mar 2023, 04:51
The first question is -- do you want to do this all under the same cBot? Or across different cBots? The answer to that question will affect the way you architecture things (and thus performance), because cBots cannot communicate directly with each other.
If it's the former, one thing you could try is setting a static variable that maintains the count. You'd have to make updating that variable thread-safe.
@firemyst
firemyst
12 Mar 2023, 04:47
RE:
j_matu said:
Hey there,
I am writing a cBot with two indicators (MACD and EMA)
I want them to run at separate time-frames, for example EMA crossover at H2 and MACD crossover at M5.
Am stuck trying to reference H2 and M5 time-frames.
Any help will be highly appreciated.
Thanks.
Have you looked at any of the code samples Spotware provided?
@firemyst
firemyst
12 Mar 2023, 04:41
RE:
Spotware said:
Dear traders,
Does anyone of you that experience the issue run cTrader on a virtual machine hosted on Linux or an ARM processor?
Best regards,
cTrader Team
@Spotware, see also this thread. Seems to still be happening to people as of March 10, 2023:
@firemyst
firemyst
09 Mar 2023, 08:09
RE:
ctid2434759 said:
Hi there,
This code is simplified for solving this specific problem.
I want to check if a position with the Label of "X" has closed.
If it has closed I want to add that into my if statement so that another one doesn't open again.Something like this?
if (CheckPositions < 2 && currentSymbolOrderLabel < 1 && PositionClosed.Label = "X" < 1 ) ??
So if there is less than 2 total open positions and less than one of the label "X" and the label "X" position has not already closed then ExecuteMarketRangeOrder.
Aka, if position Label "X" has closed do NOT ExecuteMarketRangeOrder for "X" again..Thanks
using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.SingaporeStandardTime, AccessRights = AccessRights.None)] public class ClosePositionOnTime : Robot { // Just the current simulator pairs global variables. private double _highPrice; private double _lmtPrice; protected override void OnStart() { Positions.Closed += PositionsOnClosed; // Get the high Price of the last candle for this pair _highPrice = Bars.HighPrices.Maximum(2); // Then set the price 1 pip bellow that (so i can allow it to act like a LMT order) _lmtPrice = _highPrice - 1 * Symbol.PipSize; // Draw this LMT order or price line on the chart so i can see the entry point. var highLine = Chart.DrawHorizontalLine("Low", _lmtPrice, Color.Blue); highLine.IsInteractive = true; } protected override void OnTick() { // Get the current Price, which is the symbols previous ASK price. // Then inside the onTick method this keeps checking every tick if the ask price is bellow the entry price. var _previousAsk = Symbol.Ask; // Check if the current price is higher than the previous ticks ASK price if (_lmtPrice != 0 && _previousAsk < _lmtPrice) { //See if there are any Open positions var CheckPositions = Positions.Count; var currentSymbolOrderLabel = Positions.FindAll("X").Length; //If "CheckPositions" Reports That less than 2 total positions are open and no existing current order with the label "Current Symbol Order" is open, Then ExecuteMarketOrder // HOW DO I ALSO CHECK IF THIS POSITION HAS CLOSED. // So if the order with Label "Current Symbol Order" has filled and closed do not fill it again // There will be multiple position Labels so it will need to check through the closed positions and find the matching Label if (CheckPositions < 2 && currentSymbolOrderLabel < 1 ) { // Place a buy order // At the current ask price because its bellow the trigger price with a range of 1 pip. ExecuteMarketRangeOrder(TradeType.Buy, SymbolName, 1000, 1, Symbol.Ask, "X", null, 25); } } } // Position Closed event that gets the label. private void PositionsOnClosed(PositionClosedEventArgs args) { var pos = args.Position; var label = pos.Label; Print("Closed Position: " + label); } protected override void OnStop() { // Handle cBot stop here } } }
You need to search the Historical Trade object it seems like.
HistoricalTrade ht = History.FindLast(the_label_to_look_for);
@firemyst
firemyst
09 Mar 2023, 08:06
( Updated at: 21 Dec 2023, 09:23 )
RE: RE: cTrader ClosePrices.last
deeganpope said:
I am using closeprices.last(0) and still have it trading 2 bars late. Did you ever figure this out?
ctid1820873 said:
Hi, I have searched all over and can´t find what I need.
If I use OnBar and Bars.ClosePrices.Last(1) or Bars.LastBar.Close it seems the execution is "On Bar Close" and not "On Bar Open" so as you see on my image the trigger here is the candle close under the line so next candle should execute but it is always the next after that which is too late.
If I use OnTick it triggers as soon as the low goes under the line but it might not close under anyway so that is too soon.
How would I go about triggering on the next open after closing under the line?
I
Thanks
Why not try posting some code so people can see what you're doing and why it's possibly not working?
@firemyst
firemyst
09 Mar 2023, 08:02
RE:
Serenityz0926 said:
Hello,
I'm looking for a way to change the height of indicator windows. I can change the height manually from the chart by dragging the top border but i want to do it with code.
I have gone through all the methods but can't seem to find anything.
Is it even possible to change the height of the indicator window?
I don't believe there is
@firemyst
firemyst
09 Mar 2023, 07:59
RE:
hansenlovefiona said:
I want Absolute ATR (ATR%) Indicator, where could i find it?
When it comes to recognizing long-term trends, it could be recommended using Absolute ATR (ATR%) as it will not depend on a price level of an analyzed stock or index. As an example, before 1973 crash the S&P 500 index was traded around $110 and before crash in 2008 the same S&P 500 index was traded around $1500. Such, in the first case the ATR was around 2.3 points and in the second case the ATR was around 30 points. However, in both cases, prior to the crash the Absolute ATR (ATR%) was below 2% and during the crash above 2%. As you may see, the Absolute Average True Range indicator allows comparing different securities and different periods in order to find patterns.
TRy looking here:
@firemyst
firemyst
28 Mar 2023, 03:27
It's amazing what happens when you try using Google :-)
https://www.google.com/search?q=calgo+connect+to+mysql+database&ei=7jMiZOf7GMPa4-EPnImBmAM&ved=0ahUKEwjnqqKnrv39AhVD7TgGHZxEADMQ4dUDCA8&uact=5&oq=calgo+connect+to+mysql+database&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIFCAAQogQyBQgAEKIEMgUIABCiBDoKCCEQoAEQwwQQCkoECEEYAVCwBVj1EGDpFmgBcAB4AIABogKIAZgKkgEFMC4yLjSYAQCgAQHAAQE&sclient=gws-wiz-serp
@firemyst