Topics
Replies

firemyst
20 Aug 2023, 13:06 ( Updated at: 21 Dec 2023, 09:23 )

Report the issue to Spotware through cTrader:

 

You should also provide more information than you have here if you can. For instance, go into your Windows Event Logs, find the errors, and copy/paste that information and post it as well.

 


@firemyst

firemyst
18 Aug 2023, 15:14

RE: RE: RE: RE: cBots don't working - Help!!!

rafaelfonts.silveira said: 

firemyst said: 

What symbol are you trying to place an order on?

For these attempts I am using EURUSD and XAUUSD

And how do you know your broker allows you to buy .01 lots of EURUSD and XAUUSD?

Some brokers don't allow micro lots.


@firemyst

firemyst
18 Aug 2023, 14:48 ( Updated at: 21 Dec 2023, 09:23 )

RE: RE: cBots don't working - Help!!!

rafaelfonts.silveira said: 

firemyst said: 

Any suggestion?

Yes. Read the actual parameters to the API call and what you're passing.

For instance, your third parameter, you have “”. That's the VOLUME parameter. How can you have “” for volume?

 

Hello firemyst. Thanks a lot for your answer, I changed the code to the version below:

ExecuteMarketOrder(TradeType.Buy, SymbolName, 0.01, "", 10, 10, "", false);

The volume parameter is second, right after SymbolName, still no order placed when running the cBot.

This code is just an example so that I can discover the real problem, because none of the platform's native cBots are working, I tested several and none of them placed orders when executed.

What symbol are you trying to place an order on?


@firemyst

firemyst
18 Aug 2023, 14:47

And what symbol are you trying to place an order against?


@firemyst

firemyst
18 Aug 2023, 13:10 ( Updated at: 18 Aug 2023, 13:13 )

Any suggestion?

Yes. Read the actual parameters to the API call and what you're passing.

For instance, your third parameter, you have “”. That's the VOLUME parameter. How can you have “” for volume?

 


@firemyst

firemyst
17 Aug 2023, 13:05

Assuming you're not backtesting through cTrader Automate, but rather visually?

If so, see this thread on what would help you:

https://ctrader.com/forum/ctrader-support/41513

 


@firemyst

firemyst
17 Aug 2023, 13:02

Also, in addition to printing to the log, if you want a text file, you can use C#'s ability to write to text files, csv files (so you can later import into Excel if you want), or even json or xml formatted files.

 

 

 


@firemyst

firemyst
17 Aug 2023, 12:57 ( Updated at: 21 Dec 2023, 09:23 )

  1. Turn off the tick volume display by right-clicking on teh chart → viewing options → tick volume
  2. use the “Chart.DrawText” API method to draw the text where you want it on the chart.

@firemyst

firemyst
17 Aug 2023, 06:43

RE: Account.Margin not correct : Unacceptable

ncel01 said: 

Hi to both,

Does that mean you were not able to reproduce the problem or, you didn't even try to?

You can always compare Account.Margin with its calculated value (by applying its formula), through prints, whenever a position is opened/closed.

I guess there's no big science behind it.

Why would anyone have tried when you didn't show what was wrong (through screen captures) or explain how such values were wrong?

Basically, if you can't take the time to explain/show the details, nobody is going to waste their time trying to find an alleged needle-in-a-haystack that nobody else seems to have reported.


@firemyst

firemyst
17 Aug 2023, 01:01

Evidence?

Screen captures showing the issue?

 


@firemyst

firemyst
17 Aug 2023, 00:59

This is an easy enough bot to write.

Just have your bot check all your positions 1 per hour, every 4 hours, every 15 minutes, or however often you want for any positions open more than 5 days.

//pseudo code
DateTime currentTime = DateTime.Now;
foreach (Position p in Positions)
{
    if (p.EntryTime < (currentTime - (5 days)) )
         p.Close();  
}

@firemyst

firemyst
17 Aug 2023, 00:50

Yes, there is a reason; you obviously don't understand some aspects on how the markets work.

Here's two links to help you better understand:

https://quant.stackexchange.com/questions/38527/forex-why-does-spread-peak-at-2200-gmt#:~:text=22%20GMT%20is%205pm%20nyc,can%20close%20the%20day%20flat.

 

https://www.forex.academy/why-does-the-forex-get-weird-at-5pm-usd/

 

If you get huge spreads outside of 5-6pm New York time, it could be because there's a major news release that's affecting the pair you're trading.

 

To avoid being taken out by the sudden huge spreads, some traders may do the following:

  1. change the type of stop-loss they have (for example, “opposite side”, “double trade side”, etc)
  2. remove their stop loss for the short period the market reset happens
  3. not trade during these periods (market reset, new release, etc)

You have to decide what's best for you and your trading.


@firemyst

firemyst
16 Aug 2023, 02:07

I have been using NYC Servers for a long time and have never had any issues with them.

My VPS has always been up (they have a 100% uptime guarantee) except when I reboot my server to install the latest Windows updates.

It handles MT4/5 and cTrader perfectly and has all SSD storage.

They are co-located next to either NY or London, where the major Forex markets are so there's minimal latency.

 


@firemyst

firemyst
13 Aug 2023, 11:32

RE: RE: Close onBar order execution too late

michaelgriffiths00 said: 

Many thanks for the reply firemyst. I have tried the following 

protected override void OnTick()
        {
            // Handle price updates here
            // Put your core logic here
            if (IncludeTrailingStop)
                {
                    SetTrailingStop();
            } 
            
            
            
            DateTime currentTickTime = Server.Time;
            DateTime lastCandleCloseTime = Bars.OpenTimes.Last(1).AddMinutes(5);

            TimeSpan timeDifference = currentTickTime - lastCandleCloseTime;
            double millisecondsDifference = timeDifference.TotalMilliseconds;
            
            double tolerance = 50; // Define a tolerance in milliseconds

            if (Math.Abs(millisecondsDifference - 300000) <= tolerance)
            {
                // This tick is likely the first tick after the close of the previous candle
                // You can use this information for your logic
                ManagePositions();
            }
            Print("The number of ms's is {0}", millisecondsDifference);
            
        }

However, as the number of milliseconds for each candle is not always exactly 300,000, it's very difficult to gauge what the close price of the candle will be

 

 

Not what I meant. :-)

The way I'm suggesting, you don't use your onTick or OnBar methods.

You create your own SEPARATE event handler method that's called every 5 minutes once you start the timer ticking.

It's in that new event method you will perform your logic, as you know it will reliably happen close to every 5 minutes.

Example:

using System;
using System.Timers;

//First, set up your timer
Timer t = new Timer(TimeSpan.FromMinutes(5).TotalMilliseconds); // Set the time (5 mins in this case)
    t.AutoReset = true;
    t.Elapsed += new System.Timers.ElapsedEventHandler(your_method);
    //You'll have to figure out the logic to start it exactly when you want
    t.Start();
// This method is called every 5 mins
private static void your_method(object sender, ElapsedEventArgs e)
{
    ManagePositions(); 
}

That's using the native C# timers, but hopefully you get my point.

cAlgo has it's own timer example, but make sure to read the notes they put in at the top of the code :

https://help.ctrader.com/ctrader-automate/references/Timer/Timer/#namespace

 

 


@firemyst

firemyst
13 Aug 2023, 05:21

Don't see a screen capture attached?

Also, what are the colors of your candles? Hopefully not the same color as your background?

Lastly, in the past there have been issues with charts not updating when there's a bug in the Intel Graphics display driver. You may have to update to teh latest, or roll back depending where you're at.


@firemyst

firemyst
13 Aug 2023, 05:18

THis is probably dependent on your broker as they control sizes you're allowed to trade with.


@firemyst

firemyst
13 Aug 2023, 05:17

Have you looked at any error messages of the logging tab?

I'll give you a hint as to why you're probably having issues – change the volume to “1” and run again on NAS, then change back to 10,000. 

You should be able to figure it out from there. :-)


@firemyst

firemyst
13 Aug 2023, 05:13

RE: How to add TimeFrame parameter to SMA?

Dagfx said: 

Also how I can show 1h-4h  level on a lower timeframe like 5m. 

Why don't you look at the examples Spotware provided?

https://help.ctrader.com/ctrader-automate/indicator-code-samples/#multiple-timeframes

 


@firemyst

firemyst
13 Aug 2023, 05:10

Your requirements are tricky because unless you're keeping track of time yourself and have a timer-method to check the time when a bar should be closing, there's no way to tell if a bar has closed or not until the next tick comes in.

For instance, a tick could come in on the current M1 candle at 12:59:55pm; the next tick might not come in until 1:00:05pm - difference of ten seconds. And regardless of time, that next tick could jump up down by several pips from the last value depending on what's happening in the market.

If you had a separate event method being called on say, every second, then your bot should execute the method at 1:00:00pm, in which can you can make the judgment call in your code to open a position.

Another alternative is once your threshold is crossed, you can wait to open a position once price is a pip, 2 pips, or x-pips above the threshold before waiting for the candle to close and next candle to open.

 


@firemyst

firemyst
12 Aug 2023, 11:20

 

Why have you not posted a screen capture of the error message you get when it crashes?

 


@firemyst