| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Holy Graily Bob's Candle Power https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5272 |
Page 16 of 36 |
| Author: | dreambig2 [ Fri Sep 29, 2017 3:44 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
Decided to try some Neg Correlated pairs next week see if helps overall DD. UC/AU....EC/CJ....XA/AC...GJ/EG Cheers |
|
| Author: | TraderJoeForex [ Fri Sep 29, 2017 6:47 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
No trades closed on H4 yet and adding GTWV to CP didn't do much although GJ has been in such a tight range it will be interesting to see if next week makes any difference. Great results again from M5 CP though |
|
| Author: | c1borg [ Sat Sep 30, 2017 10:33 am ] |
| Post subject: | Holy Graily Bob's Candle Power |
Ok here are some initial results only traded over 2 days and always on v1e. Definately consistent profit but small loss on EURUSD. First 10hrs seems to be significant, after that less trades and higher losses, too early to say yet though, will continue next week. 0.22% gain |
|
| Author: | c1borg [ Sat Sep 30, 2017 11:04 am ] |
| Post subject: | Holy Graily Bob's Candle Power |
All the big losses appear to be 11hrs + not sure if rebooting every 10hrs or so will reduce these but will try again next week. |
|
| Author: | SteveHopwood [ Sat Sep 30, 2017 4:13 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
V 1f is in post 1. Make sure you save a set file from your current version before loading it onto a chart so you can resume with your own settings. ------------ I had no more invalid stop errors after removing the NormalizeDouble() command from the code. I know some of you are at an early stage in looking under the bonnet at the code, so here are some explanations. Here is an input that you will see throughout my bots: extern int StopLossPips=200;
double StopLoss;
Code: Select all Add the code to a script, compile and run it. The Alert will show you "0.0". The StopLossPips variable is an integer shown to the user to make it clear that it is a pips input and to avoid confusion caused by a decimal point. It cannot be used to calculate a stop loss, which is why I have the double StopLoss as a converter. You will see this line of code in OnInit(): StopLoss=StopLossPips; This stores the user input in a double that can be interrogated throughout the code. This solves one problem and introduces another that is a features of doubles variables and it is this: the value of the variable that we can see may not be quite the same as the value the code is working with. I was reaching the wrist-slashing stage very early on in the life of SHF when the program was steadfastly refusing to recognise that two doubles that had to be the same but were not being recognised as equal. Take this very simplified example of what was happening: Code: Select all Hard to get x any more equal to y, but the damn code was refusing to recognise this. garyfritz explained. A variable of the 'double' type has 8 decimal places and that a rogue digit can appear in the 8th decimal place. So the code might be comparing x with a value of 1.00000000, to y with a value of 1.00000001. They are not equal. This is why we have this function, supplied at the time by Gary and used ever since: Code: Select all if (StopLoss != 0) DoSomething; because this will fail if the code thinks the value of StopLoss is 0.00000001 Instead: if (!CloseEnough(StopLoss, 0) ) DoSomething; because here the code will recognise that StopLoss is in fact zero and so will not do the 'something' in the following code. Here is where NormalizeDouble() comes in. Imagine this calculation with a buy order stop loss of 1.53245 and a jumping stop of 20 pips: double NewStop = OrderStopLoss() + (JumpingStopPips / factor); 'factor' is the pip factor that transforms the value of a doubles variable into Points. The code was originally supplied by lifesys. Tommaso has since supplied even better code that I see has not made its way here or into my shells - another little thingy for my todo list tomorrow. The above calculation should result in NewStop having the falue of 1.53445 i.e. 20 pips above the current stop loss. Trouble is, being a double, the value recognised in code might be 1.53445001; this will throw up an invalid stop error because the broker will not accept a price of 1.53445001. NormalizeDouble() removes any excess digits after the number of decimal places in the quote. We normally combine this all on one line as in: double NewStop = NormalizeDouble(OrderStopLoss() + (JumpingStopPips / factor), Digits); Breaking down the equation, the (JumpingStopPips / factor) is evaluated first. Imagine it is GU so the equation without normalising after the first bracket evaluation is: double NewStop = OrderStopLoss() + 0.002; Using our buy stop loss example, NewStop should be 1.53445 but we check for the extra rogue digit by 'normalising' it: NewStop - NormalizeDouble(NewStop, Digits); Incidentally, don't be afraid to bread equations down into simpler steps, especially when you are starting out. This is the complicated-looking version: double NewStop = NormalizeDouble(OrderStopLoss() + (JumpingStopPips / factor), Digits); You might find it easier to have the two step separated out instead:
To return to Candle Power and the invalid stop quotes, the command intended to prevent them appears to have been creating them. Removing said command appears to have stopped them. Welcome to my world. There should be a sign at the opening saying, "Abandon hope all ye who enter here." |
|
| Author: | RisklessPips [ Sat Sep 30, 2017 4:57 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
Many thanks for shortening the learning curve Steve. Is the doubles thing described anywhere in the literature or do Empty4 expect coders to find this type of thing out by trial and error in a situation where money or the loss of it is a consequence? Charles |
|
| Author: | SteveHopwood [ Sat Sep 30, 2017 5:16 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
In my case, mostly when people have told me in the past. You will see lots of appreciations of other coders' work as you read through my code; these people have taught me a lot. Hehe. Not much of the code is actually mine. |
|
| Author: | tomele [ Sat Sep 30, 2017 7:49 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
Ok. Giving the wisenheimer here. You are not alone. Mql4 is a subset of the C language. And there, as in many other languages, the result of an int divided by an int is not a float, but the floor of the division. You can avoid this by implicit or explicit typecasting. Implicit typecasting in this case can be done by introducing a double (here a simple "1.0") somewhere in the early part of the equation: Code: Select all Explicit typecasting means making one part of the equation explicitely a double: Code: Select all Dont rely on automatic type conversion and cast your data as early as you can. Cheers, Thomas |
|
| Author: | SteveHopwood [ Sat Sep 30, 2017 8:10 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
This is ridiculous. From the point of view of a normal human being: something * 1 = something; 1 * something = something; something * 1.0 = something etc because 1.0 = 1. Yet when I try this: Code: Select all Yet when I try this: the return is 0.5 Why? And what does this have to do with problems with NormalizeDouble() that have sprung from nowhere after over a decade of seamless use? |
|
| Author: | tomele [ Sat Sep 30, 2017 8:35 pm ] |
| Post subject: | Holy Graily Bob's Candle Power |
The compiler thinks: All integers here. Lets be lazy and treat them as integers. Result of divided integers is the floor of the result. Why should I care for decimal places? Steve wants integer from me. And the I translate it into a double. Now you have introduced a float into the equation. That forces the compiler into float computing mode and maybe to think: WTF? You want me to work? Ok. You will get a trizillion of decimal places from me. Hope you sleep bad. I dont know. Yet. Cheers |
|
| All times are UTC | Page 16 of 36 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|