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

10.7 trading helpers by Steve and others
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3561
Page 8 of 9
Author:  SteveHopwood [ Wed Jul 16, 2014 1:20 pm ]
Post subject:  10.7 trading helpers by Steve and others

kwchau » Tue Jul 15, 2014 4:31 pm wrote:Based on Steve's Sell Twice into Trend EA, I have made some changes to the codes such that I can trigger trade based on W1 Stoch 7 and take profit when the D1 Stoch 7 reaches my threshold. There is no other exit strategies. I put the attached amended EA on a D1 chart. It runs ok all along but suddenly today, it keeped opening and closing trades until I removed it manually. :arrrg:

My coding skill is nearly zero so I could not figure out what has gone wrong.

I hope I've made myself clear enough so that Steve or some coding gurus in this forum could help me to find out where are the problems and how I could overcome this opening and closing issue. Thanks guys in advance ! :roll:
This will happen if the conditions are correct for opening on one TF, and correct for closing on another. First tick: ea yells, "Yippee. Something to do. I can send a trade" and does so. Next tick: ea yells, "Yippee. Something to do. I can close a trade" and does so. Next tick, ea yells..............................

Try this. Go to line 909, insert a blank line and add this code:

Code: Select all

if (DailyStochMainClose > Stoch7ForExitLevel)
so the whole snippet reads:

Code: Select all

if (!SendLong)
   {
      //Short trade
      //Specific system filters
      if ((StoCrossStatus == crossshort70 && !Trade2Open) || (StoCrossStatus == crossshort90 && !Trade1Open)) 
         if (DailyStochMainClose > Stoch7ForExitLevel)
     // if (CloseEnough(DailyStochMain, 0))
        // if(CloseEnough(WeeklyStochMain, 0)) //remove yellow and red line condition
            SendShort = true;
      
   }//if (!SendLong)
    
You might need a buffer, as in if (DailyStochMainClose > Stoch7ForExitLevel + buffer). Try it and see.

:xm:
Author:  kwchau [ Wed Jul 16, 2014 2:31 pm ]
Post subject:  10.7 trading helpers by Steve and others

SteveHopwood » Wed Jul 16, 2014 9:20 pm wrote: This will happen if the conditions are correct for opening on one TF, and correct for closing on another. First tick: ea yells, "Yippee. Something to do. I can send a trade" and does so. Next tick: ea yells, "Yippee. Something to do. I can close a trade" and does so. Next tick, ea yells..............................

Try this. Go to line 909, insert a blank line and add this code:

Code: Select all

if (DailyStochMainClose > Stoch7ForExitLevel)
so the whole snippet reads:

Code: Select all

if (!SendLong)
   {
      //Short trade
      //Specific system filters
      if ((StoCrossStatus == crossshort70 && !Trade2Open) || (StoCrossStatus == crossshort90 && !Trade1Open)) 
         if (DailyStochMainClose > Stoch7ForExitLevel)
     // if (CloseEnough(DailyStochMain, 0))
        // if(CloseEnough(WeeklyStochMain, 0)) //remove yellow and red line condition
            SendShort = true;
      
   }//if (!SendLong)
    
You might need a buffer, as in if (DailyStochMainClose > Stoch7ForExitLevel + buffer). Try it and see.

:xm:
Steve, thank you very much for your help. :clap:

I believe this may not be the root cause of the problem. When this occurred, I have consciously checked the indicators to verify this was not the case. However it is a very good idea to build this check into the codes to ensure it will not happen again in future.

It also just comes to my mind that your EA is designed in such a way that it normally will remove itself from the chart once an open trade/ trades are closed. I wonder why this time it did not remove itself after closing the open position/positions and continue to open and close positions.

cheers
Author:  SteveHopwood [ Wed Jul 16, 2014 6:53 pm ]
Post subject:  10.7 trading helpers by Steve and others

kwchau » Wed Jul 16, 2014 2:31 pm wrote:

It also just comes to my mind that your EA is designed in such a way that it normally will remove itself from the chart once an open trade/ trades are closed. I wonder why this time it did not remove itself after closing the open position/positions and continue to open and close positions.

cheers
It could be that the removal code does not work with the latest platforms. For sure it is redundant as there is now an ExpertRemove() command. Try replacing line 2475 with ExpertRemove()

:xm:
Author:  kwchau [ Thu Jul 17, 2014 1:42 am ]
Post subject:  10.7 trading helpers by Steve and others

SteveHopwood » Thu Jul 17, 2014 2:53 am wrote: It could be that the removal code does not work with the latest platforms. For sure it is redundant as there is now an ExpertRemove() command. Try replacing line 2475 with ExpertRemove()

:xm:
The current removal code is still working in most cases. It works well in the last 2 months and is still working now except the instance two days ago in which It did not remove the EA but keep on opening and closing trades until I remove it manually.

Have replaced the code as suggested, thank you for your help ! :good:
Author:  kwchau [ Sun Aug 10, 2014 3:05 pm ]
Post subject:  10.7 trading helpers by Steve and others

Hi Steve,

I have been thinking adding codes to your helper EA to close open positions when Stoch 7 reverses direction at bar close on a H4 chart as part of the closing strategy. I am sure this is very easy for you to do but to me it is an impossible job. :?

Could you show me the way how to do this ? I hope you could help me out !

cheers !
Author:  SteveHopwood [ Sun Aug 10, 2014 9:58 pm ]
Post subject:  10.7 trading helpers by Steve and others

kwchau » Sun Aug 10, 2014 3:05 pm wrote:Hi Steve,

I have been thinking adding codes to your helper EA to close open positions when Stoch 7 reverses direction at bar close on a H4 chart as part of the closing strategy. I am sure this is very easy for you to do but to me it is an impossible job. :?

Could you show me the way how to do this ? I hope you could help me out !

cheers !
There is no way in the world that I am going to remember reading this in the morning. Send me a pm my friend, to remind me to look at this.

:xm:
Author:  kwchau [ Tue Aug 12, 2014 10:32 am ]
Post subject:  10.7 trading helpers by Steve and others

Hi coding gurus,

I'm seeking help to fix an indicator P4 Clock. It is working fine in the past but today when I re-compiled it, I got the following error :

'TimeToString' - override system function P4 Clock.mq4 499 8

The error is probably caused by new version of Empty4. :arrrg: Appreciate all the help to fix the code.

Thanks in advance ! :hi:
Author:  milanese [ Tue Aug 12, 2014 10:45 am ]
Post subject:  10.7 trading helpers by Steve and others

kwchau » Tue Aug 12, 2014 10:32 am wrote:Hi coding gurus,

I'm seeking help to fix an indicator P4 Clock. It is working fine in the past but today when I re-compiled it, I got the following error :

'TimeToString' - override system function P4 Clock.mq4 499 8

The error is probably caused by new version of Empty4. :arrrg: Appreciate all the help to fix the code.

Thanks in advance ! :hi:
here you go, the warnings can be ignored..
p4Clock_6xx.mq4
Cheers :)

Tommaso
Author:  kwchau [ Tue Aug 12, 2014 10:55 am ]
Post subject:  10.7 trading helpers by Steve and others

milanese » Tue Aug 12, 2014 6:45 pm wrote: here you go, the warnings can be ignored..

Cheers :)

Tommaso
Thank you, Tommaso :hi:
Author:  Over60 [ Tue Aug 12, 2014 12:55 pm ]
Post subject:  10.7 trading helpers by Steve and others

@ Milanese

A great help.
Thanks Tommaso!

Over60
All times are UTC Page 8 of 9