Topics
Replies
firemyst
06 Feb 2021, 16:02
I think you might be over-engineering things.
All cTrader bots are installed and run from:
C:\Users\<user name>\Documents\cAlgo\Sources\Robots
just as all indicators are installed and run from:
C:\Users\<user name>\Documents\cAlgo\Sources\Indicators
So why not just prepend that path in the bot code?
Or within each folder make one called "sounds", stick the sounds in there, and prepend the path
C:\Users\<user name>\Documents\cAlgo\Sources\Robots\sounds
??
If the users writing the code don't know the path, then provide them with a dll that has a static constant string variable with the path? They'll have to include that dll in their projects, but so what?
@firemyst
firemyst
06 Feb 2021, 13:09
You have a few possible options:
1) Use the built in system sounds, and then configure what the sounds will be in the Windows Control panel:
System.Media.SystemSounds.Exclamation.Play();
System.Media.SystemSounds.Asterisk.Play();
System.Media.SystemSounds.Beep.Play();
System.Media.SystemSounds.Hand.Play();
System.Media.SystemSounds.Question.Play();
System.Media.SystemSounds.Exclamation.Play();
2) Get the current executing directory and use that as appropriate:
3) If you did a simple Google search, you would have found that the sound files for Windows are kept in C:\Windows\Media folder. Put all sound files in there, and prepend the path to whatever file name the user selects.
Hope that helps!
@firemyst
firemyst
01 Feb 2021, 16:08
RE:
PanagiotisCharalampous said:
Hi firemyst,
Just set the IsInteractive property of the object to true.
Best Regards,
Panagiotis
Thank you @Panagiotis!
And how do I capture the events when dragging and dropping the line? I didn't see any examples in the API Guides nor the API documentation itself:
or here:
Thank you.
@firemyst
firemyst
23 Jan 2021, 08:31
As the error message says, why do you think there's a property called "Result"?
There clearly isn't one, so you'll have to figure out what property you need to reference to get the latest value. Not every indicator has a "Result" field nor is it required to.
So the best way to tackle this problem is change the line from "Ema.Result.LastValue" to just "Ema". Once you have that, type the period "." to see if any properties show up. Then you'll have to pick from the list if they do.
If they don't, you need to either be able to see the source code to see what the property is, read the documentation, or get in contact with the indicator's author.
@firemyst
firemyst
21 Jan 2021, 05:14
( Updated at: 21 Jan 2021, 05:15 )
From the code you provided above, you need to do two things:
1) remove #endregion as there's no corresponding #region tag
2) Change the line
private PRC newprc;
to
private PolynomialRegressionChannels newprc;
because there is no "PRC" object type defined in your code.
@firemyst
firemyst
20 Jan 2021, 08:07
It's a nullable type.
Anytype in C# that ends in a "?" is a nullable type.
This basically only applies to primitive types though, because objects (such as strings) are inherently nullable.
So a type of int? means it's nullable whereas a type of just plain int is not.
int x = 16 is fine.
int? x = 16 is fine.
int? x = null is fine.
int x = null is not fine.
@firemyst
firemyst
18 Jan 2021, 14:36
RE:
PanagiotisCharalampous said:
Hi firemyst,
The cloud is not assossiated with anything, it is a separate entity which is drawn between two lines. We have no plans for an on/off feature at the moment, but you can suggest it.
Best Regards,
Panagiotis
Hi @Panagiotis:
So Spotware includes a charting feature in cTrader that provides traders with zero control over the colors, zero control over any of its display features, and zero ability to even turn it on or off?
With all due respect and with that lack of basic functionality, such features shouldn't have to be "suggested".
Thank you :-)
@firemyst
firemyst
10 Jan 2021, 11:44
RE:
PanagiotisCharalampous said:
Hi EagleMoxy,
No it doesn't. You obfuscate dll files that can can be decompiled, just to make the life of the perpetrator a bit harder. There is no point to obfuscate encrypted files.
Best Regards,
Panagiotis
Two points for clarification/confirmation @Panagiotis:
1) Spotware hypothetically (more than likely) has the ability to decrypt files as most other brokers that have custom software that encrypts code also has the ability to decrypt it. So any calgo files can be decrypted by Spotware, correct?
2) Are the files also encrypted when compiled from within Visual Studio?
Thank you.
@firemyst
firemyst
08 Jan 2021, 02:46
RE:
PanagiotisCharalampous said:
Hi apon.ru.bd,
Unfortunately this information is not available in the HistoricalTrade class.
Best Regards,
Panagiotis
Just to clarify, the "reason" is available, but the actual stoploss/take-profit value isn't, correct @Panagiotis?
@apon.ru.bd, you said, "I need to check closing reason in tick method, not from positionClosing method."... so put the code in the OnTick method rather than the closing one.
That's a lot of extra CPU time wasted though checking the Historical Trade information on every tick.
Also, there is a way to get the stoploss value when a position is closed. Every time OnTick is called, save the current stoploss value in a global class variable; then in the PositionsClosed method check the value of it (as it should have the latest)
Rough code sample:
private double _lastSLValue = -1;
OnTickMethod( ... )
{
//whatever
//check to make sure you have a position
//you may also need to check if you have an SL if you don't always assign one
if (p != null)
_lastSLValue = p.StopLoss.GetValueOrDefault();
//whatever
}
PositionsClosedMethod ( ... )
{
//do whatever you need to with _lastSLValue
// more stuff
//reset the value if you need to
_lastSLValue = -1;
}
@firemyst
firemyst
07 Jan 2021, 15:14
RE: RE:
EagleMoxy said:
*( is there a way to get email notifications when a question is answered in the forum?)
Yes, there is.
You have to click the "Subscribe" button at the top of the page after you submit your response.
This forum doesn't automatically subscribe you to replies.
@firemyst
firemyst
07 Jan 2021, 15:13
private void OnPositionsClosed(PositionClosedEventArgs args)
{
Print("Closed");
var position = args.Position;
if (position.Label != "Martingale22" || position.SymbolName != SymbolName)
return;
//What kind of "delay" do you want?
//To wait x-milliseconds
Thread.Sleep(1000); //waits 1 second. You may have to import system.threading
if (position.GrossProfit > 0)
{
ExecuteOrder(InitialQuantity, TradeType.Buy);
}
}
@firemyst
firemyst
07 Jan 2021, 08:50
I suspect your error is on this line:
BB = Indicators.BollingerBands(wvf, bbl, mult, MovingAverageType.Simple);
wvf is not a "DataSeries" object; it's a "double".
That's the first parameter required when using that BollingerBands constructor is a DataSeries. For example, the close prices, high prices, low prices, open prices, etc.
@firemyst
firemyst
07 Jan 2021, 08:40
( Updated at: 07 Jan 2021, 08:42 )
Sample code to get such information:
Position p1 = args.Position;
//Now get the historical trade stuff.
HistoricalTrade ht = History.FindLast(p1.Label, p1.SymbolName, p1.TradeType);
if (ht != null)
{
double cp = ht.ClosingPrice;
Print("Position \"{0} {1}\" closed for reason {2} with {3} profit. Entry Price {4}, Closing Price {5}, StopLoss {6}", p1.Id, p1.Label, args.Reason, String.Format("{0:$#,###.00}", p1.GrossProfit), p1.EntryPrice, cp, p1.StopLoss);
}
The only other thing you'll have to do is narrow down the position(s) returned if you have multiple.
For example:
if (p1.SymbolName == Symbol.Name && p1.Label == thePositionLabel)
{ ... }
@firemyst
firemyst
07 Feb 2021, 04:27
RE: RE:
JerryTrader said:
It can look into other folders. For instance, through bots I create subfolders within the c:\windows\temp folder (which we know is always there because it's part of Windows) to store data, sounds, logs, and other information.
However, depending on the security permissions, you may have to grant your bots/indicators "full permissions" (or something else) other than the default of "none".
If you do go that route, make sure you have some sort of "clean up" happening too. Otherwise your files/folder will accumulate and slowly suck up your drive's free space.
@firemyst