SteveHopwood wrote: ↑Mon May 15, 2023 7:34 pm
Plus, anyone such as yourself, can read your post and make the changes themselves. Anyone who cannot, cannot use the shells.
Agree & thanks! Now for my next find, which dives a little bit deeper in the trading logic. See function LookForTradingOpportunities():
Code: Select all
if (BuySignal) {
SendLong = true;
}
if (SendLong) { // User choice of trade direction
if (!TradeLong) {
return;
}
This is how buy trades are started. For sell trades, it looks like this:
Code: Select all
if (!SendLong) {
if (SellSignal) {
SendShort = true;
}
if (SendShort) {
if (!TradeShort) { // User choice of trade direction
return;
}
So sell signals are only being processed if there's no buy signal present. In my opinion, long and short trades are generally equitable. By this logic, long trades are prioritized over short trades.
This may work in a perfect world. But let's assume we as coders implement some sort of faulty logic when it comes to analyse the market for entry opportunities. Allright: this is highly unlikely, but let's just assume the impossible is happening: our trading logic issues a buy and a sell signal at the same time for a given pair.
In above logic, the long trade will be placed, while the short trade is
silently ignored. Do I want that? Don't know about you, but I do not. What I find alarming most of all is the fact that ignoring the short trades obviously happens silently. Maybe there are security checks later on dealing with such a situation, which I possibly am not aware of yet. Anyway, I believe it's better to deal with this case before actually placing trades.
So this is my proposal to (hopefully) improve that bit of the shell code:
Code: Select all
// Security check: is our trading system going haywire? (simplex mod)
if (BuySignal && SellSignal) {
/*
do whatever seems appropriate to ring the alarm bells ...
... suspend trading?
... close / delete all trades?
... display visible and / or audible alarm?
... send an email to Steve for immediate help? ;-)
...
*/
return;
}
if (BuySignal) {
SendLong = true;
}
if (SendLong) {
...
if (SellSignal) {
SendShort = true;
}
if (SendShort) {
...
Now long and short trades are treated in the exact same manner, and on the same indentation level in our code. Furthermore we have the opportunity to implement some code to ring the alarm bells if the unthinkable is actually happening.
I'm just working on this mod, it's not yet ready, but I'd like to discuss my proposal here, before possibly running (coding) into a completely wrong direction. Maybe this idea is worth to find its way into the shell itself, not only in my upcoming EA's. In the end, it makes the shell a bit more foolproof (which suits me perfectly!), because it deals with a faulty signal logic in a more appropriate manner as compared to just ignoring it.
If you can't explain it simply, you don't understand it well enough. (Albert Einstein)
It appears that the Weighted Moving Average was invented by a trader who did not have a firm grasp of filter theory in hopes of reducing lag. (John F. Ehlers)