Topics
Replies
firemyst
22 Nov 2021, 09:22
RE:
amusleh said:
Hi,
If you know what time zone your indicator/cBot is running on and on which time the New York session ends then you can check if the OnBar/OnTick event is triggered during that time.
To change the time zone of DateTime you can use .NET TimeZoneInfo: Converting times between time zones | Microsoft Docs
Thank you for your reply.
Because after the New York session close, the next OnTick/OnBar events for each forex pair happens at different times. So I can't just say, "check at x o'clock.
For example, if I was in New York, in an OnBar event within a bot, I'd have to check if it is occurring between 5:00pm - 5:05pm. And if I'm on a time frame that's less than 5 minutes, I'd have to have a flag to indicate that I've already checked for the first bar after the close of the session.
Is that how you would do it? Or do you have any other ideas?
Thanks again.
@firemyst
firemyst
17 Nov 2021, 13:15
You have error in the bolded code:
if (Histogram boo 0 % prevHistogram < 0)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, TradeAmount, "MACD", 1.5 * PrevATR, PrevATR);
}
else if (Histogram < 0 % prevHistogram > 0)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, TradeAmount, "MACD", 1.5 * PrevATR, PrevATR);
}
I *think* you want the following:
if (Histogram > 0 && prevHistogram < 0)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, TradeAmount, "MACD", 1.5 * PrevATR, PrevATR);
}
else if (Histogram < 0 && prevHistogram > 0)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, TradeAmount, "MACD", 1.5 * PrevATR, PrevATR);
}
@firemyst
firemyst
28 Oct 2021, 10:21
RE: RE: RE: RE: RE: RE: RE: RE:
yuval.ein said:
My original single symbol cBot has dozens of private members (strings, integers, etc.). All those members were designed for a single symbol. Now that there are many symbols, each of them should have a different value per symbol. Is there an easy straight forward way to convert all the members from single to multi symbol?
Thanks
Yes.
Add [] onto the end of them to declare them as arrays.
int[]
double[]
etc etc
[0] is the first symbol's value, [1] is the second symbol's, so on and so forth. Hopefully after that, you won't have to make too many other changes to your code depending on how it's written.
@firemyst
firemyst
26 Oct 2021, 05:45
RE: RE: RE: RE: RE: RE:
yuval.ein said:
What if I want to use OnTick for more than one symbol?
Thanks
All you have to do is subscribe to the Tick event for each symbol you want.
This thread talks about it for indicators, but it's the same for cBots:
Example: Bars.Tick += YourOnTickEventMethod;
@firemyst
firemyst
25 Oct 2021, 15:55
RE: RE: RE: RE:
Hey
I got your email and tried to reply but my reply bounced.
Any other email address I can use to mail you?
Yes. If you look, that stupid email service provider puts in their own reply to email address. I'll send you another message with a different email in there.
@firemyst
firemyst
25 Oct 2021, 13:27
RE:
xabbu said:
thanl you very much, @firemyst, for your kind reply.
can you or the cTrader support team help me to understand, how I can implement this or a similar logic for m1 into a Renko cBot?
Kindest regards and a great and successful week,
I do not use Renko charts, so won't be able to help you there.
@firemyst
firemyst
23 Oct 2021, 18:06
RE:
pvu84pvu said:
Need to get indicator values for another symbol-timeframe. But not all indicators have DataSeries or Bars parameter in definition.
OK:
MovingAverage(DataSeries source, int periods, MovingAverageType maType)
BollingerBands(DataSeries source, int periods, double standardDeviations, MovingAverageType maType)
AcceleratorOscillator(Bars bars)
MISSING:
Alligator(int jawsPeriods, int jawsShift, int teethPeriods, int teethShift, int lipsPeriods, int lipsShift)
AverageDirectionalMovementIndexRating(int periods)
CenterOfGravity(int length)
Am I missing something?
How can I get Alligator values for another symbol-timeframe?
To answer your first question, probably inexperience and lack of forward planning in their leadership team that develops built in indicators.
For instance, the Alligator is essentially 3 moving averages, so it's no more difficult for their indicator-team to add in a data-source to the Alligator indicator than it apparently is for the same team to add the "shift" parameter to their MovingAverage indicator (notice you can add "shift" to the Alligator, but not the MA?? Like that makes any sense?) .
It's API inconsistency at its finest.
@firemyst
firemyst
23 Oct 2021, 17:59
The following business logic should help with finding it on say a M1 chart:
1) get the index of the open time of the bar when the position was opened. Ex: Bars.OpenTimes.GetIndexByTime(position open time);
2) get the index of the bar in which the position was closed. Ex: Bars.OpenTimes.GetIndexByTime(position close time);
3) loop from start to finish, checking the high and low of every bar in between the open and close time indexes you obtained in steps 1 and 2 above
@firemyst
firemyst
22 Oct 2021, 03:30
RE:
amusleh said:
Hi,
Most probably we will support officially Visual Studio 2022 after cTrader 4.2 release.
Are you able to provide an ETA or timeline on this? For all we know, cTrader 4.2 could be out next month, or 6 months, or even 12 months from now.
And then since you say we have to wait until after that release, we might have to wait yet another 12 months.
Thank you.
@firemyst
firemyst
24 Sep 2021, 03:41
( Updated at: 21 Dec 2023, 09:22 )
RE:
ome9emmy said:
Good day CTrader developers can we get a breakeven button while using the manual strategy backtesting. And also multi chart mode to switch between two different timeframe. ????❤️
THe latter you already have:
Just click the different time frame to change the chart.
The former -- you don't explain what you want. OKay. You want a button labelled "break even". So what do you expect it to do? What do you want it to do and when?
You're very vague, and need to be more specific when posting questions/requests.
@firemyst
firemyst
24 Sep 2021, 03:37
( Updated at: 21 Dec 2023, 09:22 )
RE:
vmtxd07 said:
Hi all.
I'm seeing the code in Automate of ctrader. I don't know how to get value of the Source after choose etc, Open or Close or High ...
I know DataSeries Source will return Source of bar will using as the data input.
Thanks !
[Parameter("Source")] public DataSeries Source { get; set; }
What "value" are you trying to get?
1) The actual decimal value of the SMA? If so, then create your indicator similar to as follows:
Indicators.MovingAverage(DataSource source, int periods, MovingAverageType maType)
and get its value every time you need it.
2) the value of the type of source selected? Then you can use @Panagiotis' suggestion by creating your own enum:
public enum MASource_Options
{
High,
Low,
Open,
Close
}
and using that as the parameter type:
[Parameter("Source", DefaultValue = MASource_Options.Close)]
public MASource_Options SMASource { get; set; }
@firemyst
firemyst
22 Sep 2021, 10:17
RE: RE: RE: RE: RE:
waym77 said:
firemyst said:
Have you tried passing in the MA objects in the "constructor" to your TradingPanel inner class?
You'll have to create the Constructor with the appropriate parameters.
Hi there, forgive me, I am not very familiar with constructor arguments.
Would it look something like below?
public TradingPanel(MovingAverage TrendMA, Robot robot, Symbol symbol, double defaultPrice, double defaultFrag, double defaultLots, double defaultRisk, double defaultStopLossPips, double defaultTakeProfitPips) { TrendMA = Indicators.MovingAverage(Bars.ClosePrices, TrendPeriods, MovingAverageType.Exponential); _robot = robot; _symbol = symbol; AddChild(CreateTradingPanel(defaultPrice, defaultFrag, defaultLots, defaultRisk, defaultStopLossPips, defaultTakeProfitPips)); }
I understand I'll also have to create new parameters for values like TrendPeriods in this class.
Thanks,
For your constructor, you would just have something similar to the following:
//In your other outer class, create the MA object as you normally would in the OnStart method;
//then after all the MA's are created, put in your
var tradingPanel = new TradingPanel(TrendMA, this, Symbol, ...);
//Now alter your TradingPanel class similar to the following.
public class TradingPanel : CustomControl
{
private MovingAverage _trendMA;
//All classes I believe have to have the default constructor
public TradingPanel() {}
public TrandingPanel(MovingAverage TrendMA, Robot r, Symbol s, ... )
{
_trendMA = TrendMA;
_robot = r;
_symbol = s;
// etc etc etc
}
}
If you can't get the above to work or it doesn't recognize the MovingAverage object declaration in the TradingPanel class, then that class probably can't reference the MovingAverage object, and you may have to ask @Panagiotis to lend his expert knowledge.
@firemyst
firemyst
22 Sep 2021, 04:41
RE:
riccardo.buttari said:
From my indicator, calling MarketData.GetSeries with a symbol other than the current one,
I get only the last 2000 most recent bars (even if I scroll the chart further back) and this does not allow me to perform backtests.
Is there a way to get more bars or set a start date?
Thanks
Try what's on this thread:
@firemyst
firemyst
22 Sep 2021, 04:39
RE:
hamsider said:
Hello, I try to to draw trend lines like from Day start to current index (0), Week start to current index (0) and Month start to current index (0). Any help how to get the index of Day start, Index of Week start and Index of Month Start.
Ref:Here the trend line is from session start to session end.
Thank you.
Look at this thread:
@firemyst
firemyst
22 Sep 2021, 04:38
RE:
PanagiotisCharalampous said:
Hi yaghouti,
At the moment commission information is not available in cTrader Automate API. Spread is not really relevant to this calculation since it is embedded in the actual price.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
What about this? Although you can only obtain it _after_ a position is opened:
@firemyst
firemyst
09 Dec 2021, 09:45
RE:
PanagiotisCharalampous said:
HI @Panagiotis:
I'm coding a day trading strategy that only opens positions or manages positions during the "OnBar". This means, after the NY session close. However, as you're aware, the pip spread during that time as the servers around the world reset for the next "trading day" can be HUGE. That is, what might normally be like a 3 pip spread can turn into a possible 17 pip spread temporarily.
So what I want to do is execute the logic when a new bar is formed, but if the spread is greater than say 3 pips (since most pairs are under 3 during normal hours), I want to wait until the spreads return back to some normality. Hence the "while loop" i have in my sample code above. I cannot check if the spread is > 3 and if so, skip until next bar, because it will happen again each day as each new "OnBar" event occurs and the spreads again become greater than normal.
Does that make sense?
Thank you.
@firemyst