stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Pivoty Slope
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=723
Page 5 of 7
Author:  Jimdandy [ Mon Aug 06, 2012 6:56 pm ]
Post subject:  Re: Pivoty Slope

I'm trying to figure out what i'm missing here...

if (EnforcePivotCross && (iOpen(NULL, PivotCrossTimeFrame, 1) <= DailyPivot || iClose(NULL, PivotCrossTimeFrame, 2) >= DailyPivot) ) SendLong = false;

We've got the current candle in progress.. 0
The last candle completed.. 1
and Candle before that 2

.....So I would think that if the last candle (1) opened below pivot and (1) closed above pivot that would be a cross for a long...

.....But if I understand this line.. (and apparently i don't) it says
If the last candle (1) opened below the pivot... OR if the candle before last (2) closed above the pivot... kill the long signal.

.....So if crossing candle is the last candle (1) it opens below the pivot before it crossed.... it would kill the long.

.....If one candle later when the crossing candle is now candle 2.... since it closed above the pivot it still would still kill the long.

.....Yet another candle passes, now the crossing candle is candle 3 .. out of the picture.. candle 1 opens above the pivot so it passes the test... however candle 2 closes above the pivot so again the long is killed......... there is something simple that I am missing here. How does it ever take a trade with this enabled?

It just seems to me that this says... you can take a long if candle 1 opened above the pivot and candle 2 closed below it. Which is kind of hard to do since candle 1 opens at the SAME PRICE that candle 2 closes. unless........ there is a gap over the weekend from the close of candle 2 to the open of candle 1
... or.... candle 2 is at the end of OLD day and candle 1 is above a NEW daily pivot.

Someone enlighten me please...... PipPip....Jimdandy
Author:  SteveHopwood [ Mon Aug 06, 2012 10:14 pm ]
Post subject:  Re: Pivoty Slope

Jimdandy wrote:I'm trying to figure out what i'm missing here...

if (EnforcePivotCross && (iOpen(NULL, PivotCrossTimeFrame, 1) <= DailyPivot || iClose(NULL, PivotCrossTimeFrame, 2) >= DailyPivot) ) SendLong = false;

We've got the current candle in progress.. 0
The last candle completed.. 1
and Candle before that 2

.....So I would think that if the last candle (1) opened below pivot and (1) closed above pivot that would be a cross for a long...

.....But if I understand this line.. (and apparently i don't) it says
If the last candle (1) opened below the pivot... OR if the candle before last (2) closed above the pivot... kill the long signal.

.....So if crossing candle is the last candle (1) it opens below the pivot before it crossed.... it would kill the long.

.....If one candle later when the crossing candle is now candle 2.... since it closed above the pivot it still would still kill the long.

.....Yet another candle passes, now the crossing candle is candle 3 .. out of the picture.. candle 1 opens above the pivot so it passes the test... however candle 2 closes above the pivot so again the long is killed......... there is something simple that I am missing here. How does it ever take a trade with this enabled?

It just seems to me that this says... you can take a long if candle 1 opened above the pivot and candle 2 closed below it. Which is kind of hard to do since candle 1 opens at the SAME PRICE that candle 2 closes. unless........ there is a gap over the weekend from the close of candle 2 to the open of candle 1
... or.... candle 2 is at the end of OLD day and candle 1 is above a NEW daily pivot.

Someone enlighten me please...... PipPip....Jimdandy
Nice one Jim. Thanks.

I glowered at the offending code for quite some time, demanding that it tell me why I had coded it thus. It refused to reply and continued watching the telly. Not a hint of guilt in sight. The code iself is clearly innocent, unless it is a supreme actor.

So, I guess I just plain got it wrong. No doubt the iClose(NULL, PivotCrossTimeFrame, 2) >= DailyPivot) made sense at the time, but it sure makes none right now, so V 1a is in post 1.

V 1a comes with a Steve Health Warning. I have a piano recital tomorrow and have been doing a lot of practise in prep for it. The sort of intensity I have brought to this is exhausting, both physically and emotionally.

On top of this, came a couple of glasses of dinner wine and I am half-way through a large tumbler of Scotch.

Then I coded the fix that I have added to post 1.

'nough said?

:D
Author:  Jimdandy [ Tue Aug 07, 2012 3:26 am ]
Post subject:  Re: Pivoty Slope

I can see why when you set it to true it greatly reduced the number of trades it took..... now can you explain that circle of fifths thingy to me? PipPip.. Jimdandy....

p.s. I have another ea that is doing the same thing with the stoploss error.. it's when it's moved to breakeven and is still trying to do it again even though the code plainly says RETURN if its already been done.... got to figure that one out next...
Author:  SteveHopwood [ Tue Aug 07, 2012 7:39 am ]
Post subject:  Re: Pivoty Slope

Jimdandy wrote:I can see why when you set it to true it greatly reduced the number of trades it took..... now can you explain that circle of fifths thingy to me? PipPip.. Jimdandy....

p.s. I have another ea that is doing the same thing with the stoploss error.. it's when it's moved to breakeven and is still trying to do it again even though the code plainly says RETURN if its already been done.... got to figure that one out next...
That is because Crapq4 does strange things to doubles sometimes, but does not handle the result properly. If A = 100 and B = 100, then they are equal, but Empty4 might turn B into 100.0000001, making them unequal.

This is where Gary's CloseEnough() comes in:

Code: Select all

bool CloseEnough(double num1, double num2)
{
   /*
   This function addresses the problem of the way in which mql4 compares doubles. It often messes up the 8th
   decimal point.
   For example, if A = 1.5 and B = 1.5, then these numbers are clearly equal. Unseen by the coder, mql4 may
   actually be giving B the value of 1.50000001, and so the variable are not equal, even though they are.
   This nice little quirk explains some of the problems I have endured in the past when comparing doubles. This
   is common to a lot of program languages, so watch out for it if you program elsewhere.
   Gary (garyfritz) offered this solution, so our thanks to him.
   */
   
   if (num1 == 0 && num2 == 0) return(true); //0==0
   if (MathAbs(num1 - num2) / (num1 + num2) < 0.00000001) return(true);
   
   //Doubles are unequal
   return(false);

}//End bool CloseEnough(double num1, double num2)
Then the call is, for example:
if (CloseEnough(NewStop, OrderStopLoss()) ) return;

:D
Author:  Jimdandy [ Tue Aug 07, 2012 11:09 am ]
Post subject:  Re: Pivoty Slope

........Yea I had an Aha moment when I read Gary's explanation of this problem and thanked him for it on down the thread.... but uh..... well..... I almost hate to bring it up.. but I think ........

.....if (EnforcePivotCross && iClose(NULL, PivotCrossTimeFrame, 1) >= DailyPivot) SendLong = false;

.....should be :

.....if (EnforcePivotCross && iClose(NULL, PivotCrossTimeFrame, 1) <= DailyPivot) SendLong = false;

.....if the last candle closed BELOW the pivot we should cancel the long should we not?

..... or have I just not had enough scotch yet to make this work? I mean if I have to drink scotch I'll do it... i'm willing to make that sacrifice..... the liquor store is only a half mile away and I have running shoes. :-D

Here I go....PipPip.....JimDandy.
Author:  SteveHopwood [ Tue Aug 07, 2012 10:32 pm ]
Post subject:  Re: Pivoty Slope

Jimdandy wrote:........Yea I had an Aha moment when I read Gary's explanation of this problem and thanked him for it on down the thread.... but uh..... well..... I almost hate to bring it up.. but I think ........

.....if (EnforcePivotCross && iClose(NULL, PivotCrossTimeFrame, 1) >= DailyPivot) SendLong = false;

.....should be :

.....if (EnforcePivotCross && iClose(NULL, PivotCrossTimeFrame, 1) <= DailyPivot) SendLong = false;

.....if the last candle closed BELOW the pivot we should cancel the long should we not?

..... or have I just not had enough scotch yet to make this work? I mean if I have to drink scotch I'll do it... i'm willing to make that sacrifice..... the liquor store is only a half mile away and I have running shoes. :-D

Here I go....PipPip.....JimDandy.
Nope. The market has to have crossed the pivot, so the previous candle has to have closed below the pivot. If it closed above, then the market cannot have crossed it as it was already above.

Welcome to my world, Jim. Imbibe the scotch and it becomes less painful.

:D
Author:  Jimdandy [ Wed Aug 08, 2012 2:34 am ]
Post subject:  Re: Pivoty Slope

Ummm I'm not drinking enough apparently... I was thinking that for a long you want the market to cross from below to above the pivot...... when it finally does get above the pivot then the long was triggered... Let me get to imbibing.... Hope the recital went well.... PipPip.....JimDandy
Author:  cuzgeorge [ Mon Sep 10, 2012 4:09 pm ]
Post subject:  Re: Pivoty Slope

Hi all, :D
set this up for the week,
no SL/TP, BE at 20/10 and NO JStop.
link and pic attached.
regards
cuzgeorge

Image
Author:  cuzgeorge [ Wed Sep 12, 2012 5:15 pm ]
Post subject:  Re: Pivoty Slope

Lowered the JS to 20 + BE.
Left BE at 20/10.
results are very promising.
Great work Steve.
Author:  thelearner [ Tue Sep 18, 2012 9:06 am ]
Post subject:  Re: Pivoty Slope

what TF is this EA originally made for? I believe NB10.2 runs on H4, CMIIW.
Can I bother someone to just send alert ONLY (I want to enter the position manually if I could so I can monitor). Thanks a lot... I like pivots because it doesn;t change with TF. So all traders watch the same line and avoid misinterpretation :)
All times are UTC Page 5 of 7