gaheitman wrote:SteveHopwood wrote:Shelly, I cannot see any reason for those strange part-closures. The code that calls the part-closure function is enclosed within a conditional that demands that the trade be in profit before the part=closure function is called. My live account did not take these trades because I will not sell the high-swap pairs. My demo did and has not replicated the problem.
So, no idea what caused it. Maybe the other coders can see something wrong? All the management features are called from within CountOpenTrades().

Steve,
In CountOpenTrades(), the code:
Code: Select all
if (OrderType() == OP_SELL && OrderStopLoss() <= OrderOpenPrice() && OrderLots() == Lot)
{
PartCloseThisTrade();
}//if (OrderType() == OP_SELL)
would seem to be the culprit. The only test to get here is that OrderProfit() > 0. Since there is no StopLoss, OrderStopLoss() will be <= OrderOpenPrice(), giving us the impression that we have either hit BE or moved our SL down....
There also seems to be an issue a bit further down.
Code: Select all
if (OrderType() == OP_SELL && OrderStopLoss() >= OrderOpenPrice() - (BreakEvenProfit / factor) - JumpingStopPips && OrderLots() > PartLot)
{
PartCloseThisTrade();
}//if (OrderType() == OP_BUY && OrderStopLoss() >= OrderOpenPrice()
Don't you want it to be OrderStopLoss()
<= OrderOpenPrice()... ?
Also, I can't tell if jumping stop was set or not, but I believe if it is not then this code:
Code: Select all
if (pp >= (JumpingStopPips * 2) && OrderLots() > PartLot) PartCloseThisTrade();
will incorrectly call PartCloseThisTrade().
George
A couple of really helpful spots in their George. Thanks. I am always forgetting to check that sells actually
have a stop loss.
I still do not see how the code reached that point as the trade has to be in profit first and Shelley's were not. I noticed in Shelley's pic that Gday had made attempts to part-close and that this generated an invalid ticket error.
Just in case this is yet another example of Crapql4 not doing what it says in the documentation and was looking at a closed and profitable trade in the History list, I have added MODE_TRADES to the OrderSelect command.
Coders, you might want to add if (OrderCloseTime() > 0) continue; as well. I will do this in the next release.
Note to newbie coders: I am learning not to trust the Crapql4 documentation and to declare variables explicitly. Do not rely on the 'default' values described in the documentation. The proper coders here tell me this is just basic good practise anyhow.
Version 1e is in post 1, with the fixes for the bloops George picked up on. This is an essential download.
Also, George sent me a very neat chart history check that leaves us with the best of all possible worlds. The code is right at the top of start() and the two functions you need are immediately above start. You want to pinch and edit this and use it in your own shells. I am about to add it to mine.
Thanks again George. Invaluable help.

Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed
Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.