Topics
Replies
firemyst
05 Jul 2023, 03:23
One way to do it is you need to keep track of your engulfing candles. You might want to use something like two Dictionary<int,double>() objects (one for bull candles and one for bear candles) where the key is the "bar's index" and the value is the high/low of the price.
On every new bar:
1) check every value in the bullish dictionary
2) if current price > the price of an entry in the dictionary (each value), a) delete the indicator icon at the specified bar (the key value) and b) delete the key/value pair from the dictionary as you know you don't have to check it ever again.
3) repeat steps 1-2 above for the bearish dictionary
4) if the previous bar is a bullish engulfing candle add the bar's index as the "key" to the bullish dictionary with the high price as the "value"
5) if the previous bar is a bearish engulfing candle add the bar's index as the "key" to the bearish dictionary with the low price as the "value"
@firemyst
firemyst
04 Jul 2023, 11:00
Hypothetically what you could do is:
//To find a bearish fractal in a range:
int startIndex = 4;
int endIndex = 7;
array.Skip(startIndex).Take(endIndex - startIndex).Max();
And see if the middle value of the array is equal the max value returned. If so, it's a bearish fractal.
note that according to the definition of a bearish fractal is as follows from Investopedia:
- A bearish turning point occurs when there is a pattern with the highest high in the middle and two lower highs on each side.
It doesn't say each high has to be lower/higher than the previous/next. Only that the one in the middle has to be the highest/lowest. So given that interepretation, you could use the sample code I put in at the top here.
If you do want it with each candle getting consecutively higher/lower from the middle one, I don't know how you do that without looping over each value.
@firemyst
firemyst
04 Jul 2023, 02:17
Your list is great and you've given thought to these.
However, what I would do (and I know this is tedious) is break them up and post the suggestions one by one. This way, users can vote on individual suggestions for Spotware to implement instead of one big list that probably won't garner nearly as many votes or people reading.
For instance, if someone votes on this list, what item in particular are they voting for? Nobody knows.
@firemyst
firemyst
03 Jul 2023, 03:44
RE:
sadiqbashir14 said:
We need more customized indicators, especially useful indicators like fluidetrades in the tradingview and many others.
Then
1) look for them in the repository:
2) write them yourself
3) ask in the indicator forum if there's someone willing to do it for you
4) or contact someone like @PanagiotisChar or @ClickAlgo who will have them developed for you for a cost.
@firemyst
firemyst
30 Jun 2023, 17:24
//Try this
if (Account.MarginLevel.HasValue && Account.MarginLevel >= MarginRequirement)
//execute your order
}
else
{
if (!Account.MarginLevel.HasValue)
Print("Margin Level has no value.");
else
//print out your margin levels so you can actually see what it is
Print("Margin Level is {0}", Account.MarginLevel);
}
@firemyst
firemyst
30 Jun 2023, 03:33
You can do it in a position closing event method. Rough example below:
//In the OnStart method:
Positions.Closed += Positions_Closed;
//In the method itself once the event is defined:
private void Positions_Closed(PositionClosedEventArgs args)
{
Position p1 = args.Position;
//do whatever you have to do
//Now get the historical trade stuff.
HistoricalTrade ht = History.FindLast(p1.Label, p1.SymbolName, p1.TradeType);
Print("Position \"{0} {1}\" closed for reason \"{2}\" with {3} profit. Entry Price {4}, Closing Price {5}, StopLoss {6}, ClosingTime {7}", p1.Id, p1.Label, args.Reason, String.Format("{0:$#,###.00}", p1.GrossProfit), p1.EntryPrice, p1.ClosingPrice, p1.StopLoss, ht.ClosingTime);
//finish off whatever you have to do
}
@firemyst
firemyst
28 Jun 2023, 06:54
In regards to your second point, why aren't you testing margin levels in your code _before_ sending the execute order? Your margin levels change dynamically, and the order execution isn't always instantaneous.
For instance, you could have margin level of 50% when you submit the order, but then price in another open position of yours drops, lowering your margin level below 50%, which means your order can no longer execute even though it had enough margin when you submitted the order.
//You should check your account's margin levels before sending the order
//just to be a bit safer
if (Account.MarginLevel.HasValue && Account.MarginLevel >= xxx)
//execute your order
}
@firemyst
firemyst
26 Jun 2023, 05:58
( Updated at: 21 Dec 2023, 09:23 )
RE: RE:
Quant_Vs_Market said:
firemyst said:
JSON works perfectly with cAlgo. I use it in all my bots for saving states.
I'm using the NewtonSoft json package in Visual Studio.
You haven't stated anything on how you have your VS configured (if you're using it), nor any sample code reproducing your issue.
It simply says package "netwonsoft.json" is not supported, same thing with entityframework. so i reckon its blocked due to some reason. i am running .Net6.0, but i already removed these packages, i resorted to saving notepad files separated by random characters ;(
I suspect it may have something to do with the way it's been imported?
See with mine:
and it's a .Net 6.0 bot too:
and it's local to my machine when I add a reference in cTrader itself (make sure to do that instead of trying to add a reference in Visual Studio itself)
@firemyst
firemyst
07 Jul 2023, 03:12
You're using the .Last incorrectly.
.Last should have an index indicator how many bars back you want.
If you want the last (most recent) value, then you need to use either:
.Last(0)
.LastValue
@firemyst