| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Desky. TDesk's trading drone. https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5545 |
Page 46 of 50 |
| Author: | WorldsEnd [ Sun Jul 24, 2022 6:37 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Hey Steve, thanks a lot for putting your effort into this. A great idea to morph scalpy into a trade manager. I will start experimenting with it when London opens tomorrow |
|
| Author: | pree876 [ Thu Aug 18, 2022 5:07 am ] |
| Post subject: | Desky. TDesk's trading drone. |
sorry my bad |
|
| Author: | SteveHopwood [ Thu Aug 18, 2022 9:28 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Desky responds to TDesk signals. Only a moron fails to comprehend this. Sounds like you are a moron. I suggest you go and play in another sand pit. I can be blunter if you ned. Do say so. I will be starting with something along the lines of, "OK, you mindless dimwitted cretin................." I find them quite fun as do the older members of SHF |
|
| Author: | frog [ Fri Dec 30, 2022 6:26 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
I have a couple of requests that would be beneficial to most users of TDesk Trading Partner: 1: Include an option of "percent weekly increase" to stop trading for the week under the "Use trading done for the week" option. 2: Under the "basket Friday targets" include a "basket friday percent increase". These two options would be helpful to me and hopefully others also. Thanks!! |
|
| Author: | posido [ Sat Feb 04, 2023 10:35 am ] |
| Post subject: | Desky. TDesk's trading drone. |
Hello community, I have a question about the function "shutDownForTheWeekend" in TDesk Trading Partner EA.mq4. On Fridays after "FridayCloseAllHour" when "MaxAllowableCashLoss" is reached and exceeded, the function "closeAllTrades(allSymbols, allTrades);" is called. Code: Select all While elsewhere the function "shutDownForTheWeekend" (onTimer) is called when globalTradesTotal>0. So I wonder what it is about the check for "openTrades == 0" and the value is always 0. This resulted yesterday (Friday) that the trades were not closed. Code: Select all Code: Select all Code: Select all However, since "closeAllTrades" is called here anyway, the double call afterwards with "forceTradeClosure" makes no sense. Or am I missing something? Thank you! |
|
| Author: | SteveHopwood [ Sat Feb 04, 2023 9:15 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Great to see you trying to get under the hood of the code. I think you have misunderstood the MaxAllowableCashLoss input. Suppose you have your MaxAllowableCashLoss input set to -$100. Imagine it comes to Friday close hour and your DDis -$90: This is greater than -$100 so the trades will be closed. Now imagine the DD is at -$110; this is more than you are prepared to lose, so the trades will not be closed. forceTradeClosure is a program wide variable that tells succeeding code that an attempt to close all the trades on the platform for an individual pair failed and that it needs to try again. This way, I do not have to bother about why the attempt failed, just that it did and Desky needs to try again, and keep on trying until the orders finally are closed. It is applied to individual pairs as a basket. forceTradeClosure is set to 'false' at the top of closeAllTrades(etc) then set to 'true' if an order close fails. This tells the program that there are still orders to close and that it must try again. There are similar variables such as forceWholePositionClosure and marginLevelcloseFailed that force a retry at the top of OnTimer(). Do search for this comment: //In case an entire basket closure failure happened to see them in operation. Scrolling down you will see various calls to functions that examine, for example, if we have passed the shut down for the weekend. One failed attempt is followed by two more. I could have followed a third failure by a return; statement to force a retry at the next timer event - just didn't see it as necessary. I might add it. Then scroll down to: for (int pairIndex = 0; pairIndex < ArraySize(TDeskSymbols); pairIndex++) This opens the loop that iterates around all the symbols that TDesk is examining. Here is where forceTradeClosure comes into its own. Scroll down to this comment: //Deal with a closure failure to see what happens when a closure failure further down the line leads to a failure that jumps back one symbol in the loop. Then do a search down for forceTradeClosure and see how every time it is 'false' then the code retries. If the retry fails, the code decrements pairIndex by 1 and restarts the symbol loop so the code is looking at the same symbol at the next iteration that it was looking at before the restart. In trading terms, Desky was a doddle to code. All it has to do is react to TDesk signals. It is monumental in every other respect and the world is not full of people with the patience to code him in Empty4. Feel free to ask more questions. I am a teacher and love helping people to an understanding. --------------- The above was going to be my full explanation but then I thought to add to it. Much of the code on the OnTimer() event calls functions that do the actual heavy lifting. These called functions may in turn call other sub-functions that contain code to make the called functions look easier to follow. The idea is to be able to follow lines of code that are progressively simpler to follow. OnTimer() would be impossible to follow if all the code in the sub-functions was subsumed within it - thousands of lines of code. I am no Rene and so do the best I can as an amateur coder. As an example, do a search for: //Individual pair basket closure This will take you to the call in OnTimer and within the individual pairs' loop that looks for the opportunity to close an individual pair as a basket at a cash or pips TP. Then go to: bool canIndividualPairBasketBeclosed(string symbol) There you will see how the pips and cash targets are calculated and how closeAllTrades(symbol, allTrades) is called every time a TP is hit and how forceTradeClosure is used to call the function again. If failure contlines, then OnTimer() subtracts 1 from the loop around the symbols and starts again, knowing that the trades in that pair need closing. Strictly speaking and by my (limited) understanding of programming, the code in bool canIndividualPairBasketBeclosed(string symbol) should be divided into sub functions but there comes a point when I think two thingies: 1) Hell, I am a pianist not a programmer; 2) if it ain't bust, don't fix it. Have fun. I do. |
|
| Author: | SteveHopwood [ Sat Feb 04, 2023 9:15 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Great to see you trying to get under the hood of the code. I think you have misunderstood the MaxAllowableCashLoss input. Suppose you have your MaxAllowableCashLoss input set to -$100. Imagine it comes to Friday close hour and your DDis -$90: This is greater than -$100 so the trades will be closed. Now imagine the DD is at -$110; this is more than you are prepared to lose, so the trades will not be closed. forceTradeClosure is a program wide variable that tells succeeding code that an attempt to close all the trades on the platform for an individual pair failed and that it needs to try again. This way, I do not have to bother about why the attempt failed, just that it did and Desky needs to try again, and keep on trying until the orders finally are closed. It is applied to individual pairs as a basket. forceTradeClosure is set to 'false' at the top of closeAllTrades(etc) then set to 'true' if an order close fails. This tells the program that there are still orders to close and that it must try again. There are similar variables such as forceWholePositionClosure and marginLevelcloseFailed that force a retry at the top of OnTimer(). Do search for this comment: //In case an entire basket closure failure happened to see them in operation. Scrolling down you will see various calls to functions that examine, for example, if we have passed the shut down for the weekend. One failed attempt is followed by two more. I could have followed a third failure by a return; statement to force a retry at the next timer event - just didn't see it as necessary. I might add it. Then scroll down to: for (int pairIndex = 0; pairIndex < ArraySize(TDeskSymbols); pairIndex++) This opens the loop that iterates around all the symbols that TDesk is examining. Here is where forceTradeClosure comes into its own. Scroll down to this comment: //Deal with a closure failure to see what happens when a closure failure further down the line leads to a failure that jumps back one symbol in the loop. Then do a search down for forceTradeClosure and see how every time it is 'false' then the code retries. If the retry fails, the code decrements pairIndex by 1 and restarts the symbol loop so the code is looking at the same symbol at the next iteration that it was looking at before the restart. In trading terms, Desky was a doddle to code. All it has to do is react to TDesk signals. It is monumental in every other respect and the world is not full of people with the patience to code him in Empty4. Feel free to ask more questions. I am a teacher and love helping people to an understanding. --------------- The above was going to be my full explanation but then I thought to add to it. Much of the code on the OnTimer() event calls functions that do the actual heavy lifting. These called functions may in turn call other sub-functions that contain code to make the called functions look easier to follow. The idea is to be able to follow lines of code that are progressively simpler to follow. OnTimer() would be impossible to follow if all the code in the sub-functions was subsumed within it - thousands of lines of code. I am no Rene and so do the best I can as an amateur coder. As an example, do a search for: //Individual pair basket closure This will take you to the call in OnTimer and within the individual pairs' loop that looks for the opportunity to close an individual pair as a basket at a cash or pips TP. Then go to: bool canIndividualPairBasketBeclosed(string symbol) There you will see how the pips and cash targets are calculated and how closeAllTrades(symbol, allTrades) is called every time a TP is hit and how forceTradeClosure is used to call the function again. If failure contlines, then OnTimer() subtracts 1 from the loop around the symbols and starts again, knowing that the trades in that pair need closing. Strictly speaking and by my (limited) understanding of programming, the code in bool canIndividualPairBasketBeclosed(string symbol) should be divided into sub functions but there comes a point when I think two thingies: 1) Hell, I am a pianist not a programmer; 2) if it ain't bust, don't fix it. Have fun. I do. |
|
| Author: | posido [ Sun Feb 05, 2023 9:18 am ] |
| Post subject: | Desky. TDesk's trading drone. |
Hello Steve, First of all, thank you for your detailed answer! re "MaxAllowableCashLoss", I was on Friday in profit with about 130 EUR. As it is greater than -20 (default value) I had the assumption it would close all trades on Friday close hour. re "forceTradeClosure", I understand. But I think in following part for instance we can remove one of the duplicated calls of "closeAllTrades(symbol, OP_SELL);" in sellsInRecovery: Code: Select all Maybe dumb question, but what means "Empty4"? Thanks also for your added explanations. Btw, I am a coder as well since more than 20 years, actually nowadays a software and system architect for financial web applications. But I love trading and developing in MQL. Thanks again for your great answer! |
|
| Author: | SteveHopwood [ Tue Feb 07, 2023 12:11 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
I cannot see anything wrong with the code. I will check on Friday that there is nothing higher up in OnTimer() that prevents the call being reached. |
|
| Author: | posido [ Tue Feb 07, 2023 12:21 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Many thanks! |
|
| All times are UTC | Page 46 of 50 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|