| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Desky. TDesk's trading drone. https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5545 |
Page 24 of 50 |
| Author: | SteveHopwood [ Tue Mar 05, 2019 11:03 am ] |
| Post subject: | Desky. TDesk's trading drone. |
This shows the value of including error reporting alerts in the code. The Bid price is a variable of the double type, so it has 8 decimal points. Crapql4 sometimes replaces the final 0 with a 1. See the value of the order price being sent - 0.6795600000000001. That has happened here and so the order generates the invalid stop error. Desky needs to know the bid, ask and no of decimal points (known as "Digits) for each individual pair so there is a function that reads these at the start of many functions by calling void GetBasics(string symbol). Here it is as it now is in V3 in post 1: Code: Select all bid = NormalizeDouble(MarketInfo(symbol, MODE_BID), digits); NormalizeDouble forces the variable to hold only the value of the digits after the decimal point, so removing the chance of the eighth having the erroneous 1 added. If you go to the function in your current version, you will see that this is missing. I also had to slightly rearrange the order so that 'digits' is correctly populated. Copy the code here over the top of the code in 2z. Look a few lines down to the top of bool LookForTradingOpportunities(string symbol, int pairIndex, int type). You will see this code: GetBasics(symbol); This ensures that Desky is working with up to date values. The void OnTimer() event holds the iteration through our list of trading pairs. Find it with a search for: for (int pairIndex = 0; pairIndex < ArraySize(TDeskSymbols); pairIndex++) Three lines above this you will see: string symbol = ""; pairIndex is assigned the place in our trade pair list. 'symbol' is assigned the pair symbol such as GBPUSD. These are then passed to every subsequent called function e.g. DoHedging(symbol, pairIndex); So, if you want to add your own functions define them like this: void MyFunction((string symbol, int pairIndex) { GetBasics(symbol); Rest of function; } Then call it from where ever is appropriate: MyFunction(symbol, pairIndex); You pass symbol and pairIndex around whenever you call a new function. pairIndex is not always needed but I have taken lately to passing it around anyhow, so it can be passed from function to function. Suppose you have defined two functions and the second is called from within the first: void MyFunction((string symbol, int pairIndex) { GetBasics(symbol); double priceToSend = MySecondFunction(symbol, pairIndex); } double MySecondFunction((string symbol, int pairIndex) { GetBasics(symbol); double price = bid; return (price); } The void DoHedging(string symbol, int pairIndex) function calls two sub-functions, so have a look to see a real example. |
|
| Author: | c1borg [ Tue Mar 05, 2019 12:52 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Using the new version ATR set to true and we still get an error. This feature is working on other demos could it be the ATR is too low on NZDUSD? Day's Range: 0.6790 - 0.6828
|
|
| Author: | SteveHopwood [ Tue Mar 05, 2019 5:02 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Check you are using the latest version. Or have recompiled if you DIY'd. |
|
| Author: | c1borg [ Tue Mar 05, 2019 7:16 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Ok checked and everything looks right |
|
| Author: | SteveHopwood [ Tue Mar 05, 2019 8:04 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Then I have no idea what the problem is. You around, tutank? |
|
| Author: | c1borg [ Tue Mar 05, 2019 8:56 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
I don't think it's a major issue and only seems to arise if the ATR is small |
|
| Author: | tutank [ Wed Mar 06, 2019 3:12 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
Have you modified the code, there's something wrong because SELLSTOP price 0.6802 is higher than current BID 0.67956... |
|
| Author: | SteveHopwood [ Wed Mar 06, 2019 4:11 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
No, but I had a look at DoesTradeExist() and found bloops that are not helping matters. There are places in the code where I had not replaced Symbol() with the passed parameter "symbol". This could also explain the total failure of counter-trend trading. DIYers, go to: bool DoesTradeExist(int type, double price) Add string symbol to the list of parameters: bool DoesTradeExist(int type, double price, string symbol) Scroll down to: if (OrderSymbol() != Symbol() ) continue; Replace it with: if (OrderSymbol() != symbol) continue; Re-compiling wii throw up two errors. Double click them to go to them. They will both be: if (DoesTradeExist(type, price)) They both need "symbol" adding: if (DoesTradeExist(type, price, symbol)) Then go to bool HaveEnoughCandlesReversed(string direction) and repeat the process so that the function has the added parameter: bool HaveEnoughCandlesReversed(string direction, string symbol) Scroll down to: double copen = iOpen(Symbol(), CtsTimeFrame, cc); Change it to: double copen = iOpen(symbol, CtsTimeFrame, cc); Do the same on the next line. Re-compile and follow the serious error messages to the offending lines and add, ", symbol)" as in this line: if (HaveEnoughCandlesReversed(down, symbol) ) Don't be tempted to do a global search and replace - there are places in the code where Symbol() is needed. |
|
| Author: | kwchau [ Fri Mar 08, 2019 2:17 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
I'm testing Desky 2z with swap filter all set to true, but notice that trades with negative swap are still being taken. I have turned off most setting like recovery, hedging etc except rolling grid and offsetting. Not sure how this happens. I have not test this swap functions in previous version, so I am not sure this is carried forward problem. Anyone observes the same thing ? Any help will be highly appreciated. Cheers, kwchau |
|
| Author: | SteveHopwood [ Fri Mar 08, 2019 3:30 pm ] |
| Post subject: | Desky. TDesk's trading drone. |
This is nothing that you are doing wrong. The code is legacy code that does not work here. I will fix it. |
|
| All times are UTC | Page 24 of 50 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|