firemyst's avatar


Member since: 26 Mar 2019





Last Algorithm Comments

@Renko on Time/Tick/Range Chart:  11 Aug 2022, 16:30

@fernando.f.oficial, you're not seeing anything because when this indicator calls the "DrawRenkoBrick" Method, the LowPrice and HighPrice parameters are coming in as NaN's. The Chart.DrawRectangle method can't draw coordinates that are NaN's.  The author @jumpycalm needs to fix this bug.  

@RealPivot:  24 Jun 2022, 05:21

This is a great indicator. However, it would be a lot more efficient and less resource intensive if the code was updated to only calculate the pivot points when the "index" for the pivot time frame that's selected changes. For example, if I'm on the 4-hour time frame, and have the daily pivot point selected, why does it have to be calculated on every tick? It's not going to change until the next day. I would suggest implementing logic where you have a global class variable called something like "int previousIndex", and when the current pivot timeframe index is > previousIndex in the Calculate method: 1) run the calculations 2) set previousIndex to the current pivot time frame index. 3) until current pivot time frame index is > previousIndex, you can skip all the logic in Calculate. Boom! You just saved all the CPU calculations having to be done every tick and your indicator just became that much faster. :-)

@Currency Strength Meter (Pro) Ver1.11:  07 May 2022, 13:57

should have been "stackoverflow41" and not "stackover41"

@Currency Strength Meter (Pro) Ver1.11:  07 May 2022, 13:56

Still doesn't work. I can't post a screen capture or video here. It might be working for you, but it's definitely not on Pepperstone cTrader here. My email: "stackover41" @ "". Send me a message please (hopefully with a screen capture of your suggested configs) and I can respond back with a video and screen captures showing you the issues.

@Currency Strength Meter (Pro) Ver1.11:  07 May 2022, 13:37

THis indicator doesn't seem to work. I've had to comment out this line:   private void Chart_ScrollChanged(ChartScrollEventArgs obj)         {             //Chart.SetYRange(MVRange, PVRange);         } Because cTrader keeps flashing lines up and down -- the ScrollChanged event is constantly called even though I don't touch it. Labels are never shown as a result.

@Super Profit:  24 Jan 2020, 21:22

Can you describe in plain English please what you're doing with the MA's in your code? I don't understand the reasoning, or what you're doing with these:   var period1 = (int)Math.Floor(DllPeriod / Period);             var period2 = (int)Math.Floor(Math.Sqrt(DllPeriod));             _movingAverage1 = Indicators.MovingAverage(Price, period1, MaType);             _movingAverage2 = Indicators.MovingAverage(Price, DllPeriod, MaType);             _movingAverage3 = Indicators.MovingAverage(_dataSeries, period2, MaType);   What the Sqrt function? And the DLLPeriod/Period. I don't understand what they're doing or purpose is? Thank you.

@Trend Angle:  11 Aug 2019, 10:38

Why does this indicator require "full access rights" to the computer when being installed?

@Memory Manager Bot:  29 Jul 2019, 09:08

Thank you for this. I find that even with forcing GC.Collect() or GC.GetTotalMemory(true) in bot code still doesn't seem to reclaim everything, and was wondering what else could be done short of having to constantly stop/restart bots as @Paul Hayes alluded to above.

@Bollinger Bands Width:  27 May 2019, 03:36

Why do you divide by Main[index]? Subtracting the bottom from the top alone will provide you with the width. Or subtracting the bottom from the top and dividing by 2.  Thank you.

@Bandwidth:  27 May 2019, 03:35

Why do you divide by bb.Main[index]? Subtracting the bottom from the top alone will provide you with the width. Or subtracting the bottom from the top and dividing by 2.  Thank you.

Last Forum Posts

@Close position after 5 bar passes:  04 Oct 2022, 03:18

r.stipriaan said:

Hi hamirady60, 

I think its not posible to close positon on bars, i use this method, it works with time. 

            var SellPosition = Positions.Find("Short", SymbolName, TradeType.Sell);

            if (SellPosition != null &&  SellPosition.EntryTime.AddHours(5) < TimeInUtc)
                ClosePosition(Positions.Find("Short", SymbolName, TradeType.Sell));

Positions can be closed on bars.

Here's one way to do it:

1) set a global variable for keeping track:

int _indexOrderPlaced = 0;

int _currentIndex = 0;

2) in OnStart, reset the value to zero:

_indexOrderPlaced = 0;

_currentIndex = Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue);

3) When an order is placed, get the bar's current index similar to:

_indexOrderPlaced = Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue);

Every time OnBar is called:

//Get the current index

_currentIndex = Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue);

//Check if it's within 5 of the order being placed

if (_currentIndex - _indexOrderPlaced > 5)


//close the position here

//reset this

_indexOrderPlaced = 0;


Just a schematic, but should help to get you started.

@Debugging and Breakpoints:  01 Oct 2022, 16:47

Yes, you are missing something... seems like a quick VS tutorial is in order:

F5 - run until the next break point is hit

F10 - go line by line (as you're doing)

F11 - step into a method call

You might also want to have a read:

@Price Action opening and closing above a MA:  23 Sep 2022, 06:50

jeremy.ayres said:

When comparing moving average values on open and close how can I compare this against Price Action values? E,g,. if one is greater than the other, surely I would need to compare similar values, or there a built-in way to call this is in the code?

What price action values do you want to compare against? Open prices? Close prices?

You would just need to do something similar to:

MovingAverage1.Result.LastValue >= Bars.ClosePrices.LastValue

Not that in the current bar, the current price is always the "close price" even if the bar hasn't closed yet.

@Indicator Calculation on closed bars only / ignore current bar:  23 Sep 2022, 06:48

I think you can do what you want in the Calculate method:

1) create a class variable that's an int that keeps track of previous indexes:

private int _previousIndex;

2) in the initialize method, set _previousIndex = 0

3) In Calculate:

if (index > _previousIndex)


//do all your logic

_previousIndex = index;


The above code will only run then when it moves to the next bar, thereby not calculating it on the current bar.

@Matching Fractal Arrows up with Bars:  18 Sep 2022, 09:58

jaydcrowe1989 said:


I am not sure if this is possible but is there a way to get the last drawn fractal arrow or is there a way to match the arrows up with the correct bar they were drawn at?



Yes. I wrote my own fractal indicator that does just that.

If you need help, please post your code.

@debugging with the new version:  18 Sep 2022, 09:57

Google and searching the website is your friend:

@Hard to debug new dynamic multiprocess backtesting:  03 Sep 2022, 18:37

douglascvas said:

Could cTrader go back to 1 single process, please? It is so hard to debug algos when the process keeps changing on each run.

Yes, it is a little bit more of a hassle.

Perhaps this will help:

@How to stop an Algo after profit reached!:  01 Sep 2022, 04:38

Omega said:

firemyst said:

Omega said:

Hi fellas'

I have two algo's I use to trade...

First is an algo that trades a basket of currencies the second will close all positions when the account reaches it's profit target.

The issue I have is that the first algo that trades doesn't stop once the positions have been closed by the second algo if I'm not there to manually stop ctrader.

Is there a way to stop the trading algo after it has reached my profit target without my being there to do it manually?

Look forward to your ideas...


ALl you have to do is put this line of code in your cBot when you want it to stop:


So when the position is closed, in the running bot instance check to make sure the current bot instance is the one that had its position closed. If it was, tell it to "Stop()".

Thanks for that...

I get the 'Stop(); line but I have an algo on each chart, it's the collective or basket of currencies that provide the profit overall so I'm thinking that it will need a separate algo for this?

Since you can't control one bot from another bot, there are at least 2 options I can think of off the top of my head that you can try:

1) (the easiest one) - create a public static variable in your bot code. That'll be visible across all bots. Call it something like:

public static bool StopAllBotInstances = false;

Make it a boolean. Have each bot check it during the onTick method. If it's ever set to true by one bot, call Stop(); Every bot should then stop with the next tick.

2) (not as easy) Create your own event handler called something like "OnProfitTargetReached" that does the same thing -- Stop() when the event is fired by any bot instance.

@Add a numeric UI control:  01 Sep 2022, 04:31

BigManDave said:

firemyst said:

They are already there.

Just declare the parameter to be a type of "int" or "double".

Then you can apply the min/max settings, "step" setting, etc.

As far as I am aware, they are not already there, because I asked Panagiotis and he said this functionality doesn't exist in the cAlgo API.

TextBlock and TextBox do not have any parameters as far as I know. Please can you give a code example of what you are talking about?

Just because it's not in the cAlgoAPI doesn't mean it doesn't exist in the .net framework. You can build controls using Windows Forms.

In your case, you probably want a NumericUpDown control. You can also use a TextBox control, and on the KeyPress event, check to make sure it's numeric only.

Here's the details from Microsoft on the NumericUpDown control:

and here's a blog with examples of that AND how to code a textbox so it accepts numbers only:

Here's an example from the cTrader repository that adds controls into cTrader:

You can always check StackOverflow as well:

Simple code I use to add a checkbox to a chart to allow me to toggle things:

private CheckBox _checkBox;
        private Canvas _checkboxCanvas;

//... and here's how to implement
 _checkBox = new CheckBox 
                        Text = "This is an example",
                        Margin = 5,
                        IsChecked = true,
                        Left = 10,
                        Top = 20

                    _checkBox.Checked += CheckBox_Checked;
                    _checkBox.Unchecked += CheckBox_Unchecked;

                    _checkboxCanvas = new Canvas();

//Add to the cTrader chart so I can check/uncheck it and have it do what I want

Hope that helps?

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.