Topics
Replies

firemyst
27 Aug 2023, 15:22 ( Updated at: 27 Aug 2023, 15:23 )

I think your logic in both loops is wrong because you're changing the average price every time you do the loop.

That is, look at #1. When you have 10 positions open and the averagePrice (in pips) is < -10, you modify one position.

Then you do another loop and calculate the average again. The average will change because you've already modified one position. 

Same with #2. The average will change each time when you close a position.

What you should do is calculate the average once with all the current positions, and then do you loop. This way, the average won't change on each loop iteration.

For example:

double averagePrice = Positions.Average(x => x.Pips);
if (averagePrice > 11){    
    foreach (var position in Positions)    
    {            
        ClosePositionAsync(position);     
    }
}

@firemyst

firemyst
26 Aug 2023, 19:37 ( Updated at: 27 Aug 2023, 05:33 )

You've posted this in the wrong forum.

You need to post suggestions in the “Suggestions” forum:

https://ctrader.com/forum/suggestions

 


@firemyst

firemyst
23 Aug 2023, 02:06 ( Updated at: 24 Aug 2023, 05:01 )

You need to post this in the correct forum:

https://ctrader.com/forum/suggestions

 


@firemyst

firemyst
22 Aug 2023, 11:27 ( Updated at: 21 Dec 2023, 09:23 )

@Spotware, any ideas or updates? Able to reproduce?

I tried again today on the Ger40 Renko 5 chart.

I changed the above code from:

double ma1LastResult = Math.Round(ma1.Result.Last(1), Symbol.Digits);
            double ma2LastResult = Math.Round(ma2.Result.Last(1), Symbol.Digits);

to:

double ma1LastResult = Math.Round(ma1.Result.Last(1), 2);
            double ma2LastResult = Math.Round(ma2.Result.Last(1), 2);

and still get values that differ between the .Last(1) outputs and the Market Snapshot tool today as shown below:

Times are UTC + 8

 

I would expect the output from ma1.Result.Last(1) to be the same, or at least within mathematical rounding distance of the displayed value on the chart. 

In the case of the 4 EMA, calgo returns a value that differs by 20% of a pip. This difference certainly shouldn't be acceptable.

Thank you.


@firemyst

firemyst
21 Aug 2023, 23:22

Do the following that's posted in this thread:

https://ctrader.com/forum/calgo-support/41644

 


@firemyst

firemyst
21 Aug 2023, 01:41

Everything you've done seems legit to me. The OnException probably isn't being called because it might not be anything to do with your code, but rather a bug in cTrader itself.

There are two more things you can try:

  1. put individual try/catch blocks around each assignment statement in your OnStart method to see if that does anything in terms of catching something. I doubt it, but you never know. 

Example:

protected override void OnStart()
{
    try {
        emaBars = MarketData.GetBars(EmaTimeFrame);
    }
    catch (Exception e) {
        print ("EXCEPTION 1! {0}", e.ToString());
    }
    try {
        ema = Indicators.HullMovingAverage(emaBars.OpenPrices, EmaPeriods);
    }
    catch (Exception e) {
        print ("EXCEPTION 2! {0}", e.ToString());
    }
    
    //etc etc
}

 

2. look in your Windows Event view logs for the big red ERROR indication. There might be a clue in there on what's happened. Either way, it would be great to post that information too because that will also help @Spotware @cTraderTeam in investigating/fixing the issue if it is indeed a bug with cTrader itself.

 

 


@firemyst

firemyst
20 Aug 2023, 13:18

This is another good indicator:

https://ctrader.com/algos/indicators/show/2021

 


@firemyst

firemyst
20 Aug 2023, 13:17

Why would they do it? You've posted in the “suggestions” forum - this isn't the place to report technical issues.

You need to post in one of the other forums.


@firemyst

firemyst
20 Aug 2023, 13:08

You need to post this in the “Suggestions” forum.


@firemyst

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