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

Scalping New York
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=6189
Page 17 of 31
Author:  Umberleigh [ Wed Jun 01, 2022 4:37 pm ]
Post subject:  Scalping New York

Scalpy is doing a great job
Author:  SteveHopwood [ Wed Jun 01, 2022 4:49 pm ]
Post subject:  Scalping New York

pivotter » Wed Jun 01, 2022 3:35 pm wrote:we always assume that per request all data is correctly retrieved, but if from iClose or iOpen the retrieved value is a zero instead of the correct value you would also get a wrong candle direction.

We can test it with print the retrieved values.
Another great idea Ben. :clap: :clap: :clap: :clap: :clap: I can code this into Scalpy to force him tokeep on trying until a non-zero value is returned.

:xm: :rocket:
Author:  SteveHopwood [ Wed Jun 01, 2022 4:56 pm ]
Post subject:  Scalping New York

So far as I know, this only works for the chart hosting the EA/script. I tried this in my Experiments script to see if the function could be called with a parameter:

Code: Select all

void OnStart()
{

   string symbol = "EURUSD";
   RefreshRates(symbol); 
}
It threw up an error.

:xm: :rocket:
Author:  pivotter [ Wed Jun 01, 2022 4:58 pm ]
Post subject:  Scalping New York

SteveHopwood » Wed Jun 01, 2022 4:49 pm wrote:
pivotter » Wed Jun 01, 2022 3:35 pm wrote:we always assume that per request all data is correctly retrieved, but if from iClose or iOpen the retrieved value is a zero instead of the correct value you would also get a wrong candle direction.

We can test it with print the retrieved values.
Another great idea Ben. :clap: :clap: :clap: :clap: :clap: I can code this into Scalpy to force him tokeep on trying until a non-zero value is returned.

:xm: :rocket:

i would also change:
line 390 (cclose > copen) to (cclose >= copen)
line 396 (cclose < copen) to (cclose <= copen)
typical Empty4 , sometimes it starts working after adding the equal sign,

Also on line 1466 and 1467
type = OP_SELL;
price = bid;

pls move them 3 lines up before the MA240 check to give them time to switch before the value is send in sendSingleTrade(
Author:  SteveHopwood [ Wed Jun 01, 2022 5:10 pm ]
Post subject:  Scalping New York

pivotter » Wed Jun 01, 2022 4:58 pm wrote:
SteveHopwood » Wed Jun 01, 2022 4:49 pm wrote:
pivotter » Wed Jun 01, 2022 3:35 pm wrote:we always assume that per request all data is correctly retrieved, but if from iClose or iOpen the retrieved value is a zero instead of the correct value you would also get a wrong candle direction.

We can test it with print the retrieved values.
Another great idea Ben. :clap: :clap: :clap: :clap: :clap: I can code this into Scalpy to force him tokeep on trying until a non-zero value is returned.

:xm: :rocket:

i would also change:
line 390 (cclose > copen) to (cclose >= copen)
line 396 (cclose < copen) to (cclose <= copen)
typical Empty4 , sometimes it starts working after adding the equal sign,

Also on line 1466 and 1467
type = OP_SELL;
price = bid;

pls move them 3 lines up before the MA240 check to give them time to switch before the value is send in sendSingleTrade(
Thanks again. I do not see how this would help.
Also on line 1466 and 1467
type = OP_SELL;
price = bid;

pls move them 3 lines up before the MA240 check to give them time to switch before the value is send in sendSingleTrade
Doesn't mean it will not help - just that I do not see how.

Re this:
i would also change:
line 390 (cclose > copen) to (cclose >= copen)
line 396 (cclose < copen) to (cclose <= copen)
typical Empty4 , sometimes it starts working after adding the equal sign,
Definitely and already made the change. It made me think that I have declared cclose ets as a double - legacy code from years ago. Do you think this should be a 'datetime' instead? Or merely an integer?

:xm: :rocket:
Author:  SteveHopwood [ Wed Jun 01, 2022 5:17 pm ]
Post subject:  Scalping New York

I just answered my own question about the cclose etc declaration by putting this into my Experiments script:

Code: Select all

void OnStart()
{

   datetime x =TimeLocal();
   Alert(x);
 
}
Worked perfectly, so I will make that change.

:xm: :rocket:
Author:  pivotter [ Wed Jun 01, 2022 5:19 pm ]
Post subject:  Scalping New York

SteveHopwood » Wed Jun 01, 2022 5:10 pm wrote:
pivotter » Wed Jun 01, 2022 4:58 pm wrote:
SteveHopwood » Wed Jun 01, 2022 4:49 pm wrote:
pivotter » Wed Jun 01, 2022 3:35 pm wrote:we always assume that per request all data is correctly retrieved, but if from iClose or iOpen the retrieved value is a zero instead of the correct value you would also get a wrong candle direction.

We can test it with print the retrieved values.
Another great idea Ben. :clap: :clap: :clap: :clap: :clap: I can code this into Scalpy to force him tokeep on trying until a non-zero value is returned.

:xm: :rocket:

i would also change:
line 390 (cclose > copen) to (cclose >= copen)
line 396 (cclose < copen) to (cclose <= copen)
typical Empty4 , sometimes it starts working after adding the equal sign,

Also on line 1466 and 1467
type = OP_SELL;
price = bid;

pls move them 3 lines up before the MA240 check to give them time to switch before the value is send in sendSingleTrade(
Thanks again. I do not see how this would help.
Also on line 1466 and 1467
type = OP_SELL;
price = bid;

pls move them 3 lines up before the MA240 check to give them time to switch before the value is send in sendSingleTrade
Doesn't mean it will not help - just that I do not see how.

Re this:
i would also change:
line 390 (cclose > copen) to (cclose >= copen)
line 396 (cclose < copen) to (cclose <= copen)
typical Empty4 , sometimes it starts working after adding the equal sign,
Definitely and already made the change. It made me think that I have declared cclose ets as a double - legacy code from years ago. Do you think this should be a 'datetime' instead? Or merely an integer?

:xm: :rocket:
iClose is a double see https://docs.mql4.com/series/iclose
Author:  SteveHopwood [ Wed Jun 01, 2022 6:04 pm ]
Post subject:  Scalping New York

Thanks. Yet again pointing the way forward. :clap: :clap: :clap: :clap: :clap:

:xm: :rocket:
Author:  SteveHopwood [ Wed Jun 01, 2022 6:24 pm ]
Post subject:  Scalping New York

Thanks to Ben, the latest version attempting to Battle Empty4 Anomalies is in post 1.

Code checkers and DIYers, copy these over the top of the existing functions. You can see how I have used our closeEnough() function to ensure that we are not comparing bid/ask values with zero.

Newcomers to all this, remember to right click Scalpy in your Navigator window and delete him, close down your platform and then download the update from post 1. Empty4 will only recompile .mq4 source code on restarting if the .ex4 file is missing.

Code: Select all

void getDirection(string symbol, int tf, int pairIndex)
{

   //Ascertain the direction of movement of the previous candle
   
   double copen = 0;
   double cclose = 0;
   
   while (closeEnough(copen, 0) )
      copen = iOpen(symbol, tf, 1);
   
   while (closeEnough(cclose, 0) )
      cclose = iClose(symbol, tf, 1);
   
   direction = noney;//Default, and unlikely to happen but does sometimes
   if (cclose > copen)
   {
      direction = longy;
      return;
   }//if (cclose > copen)
   
   if (cclose < copen)
   {
      direction = shorty;
      return;
   }//if (cclose > copen)
   

}//End void getDirection(string symbol, int tf, int pairIndex)

bool confirmLongSignal(string symbol, int pairIndes)
{

   //Bob's moving average filter
   getBasics(symbol);//Probably notnecessary, but this is Empty4 we are battling with
   MaVal = 0;
   while (closeEnough(MaVal, 0) )
      MaVal = GetMa(symbol, MaTF, MaPeriod, MaShift, MaMethod, MaAppliedPrice, 0);
         
   //MaVal is no longer == 0, so we can continue
   if (ask < MaVal) 
      return(false);   

   //Got here, so ok to send the order
   return(true);

}//End bool confirmLongSignal(string symbol, int pairIndes)


bool confirmShortSignal(string symbol, int pairIndes)
{

   //Bob's moving average filter
   getBasics(symbol);
   MaVal = 0;
   while (closeEnough(MaVal, 0) )
      MaVal = GetMa(symbol, MaTF, MaPeriod, MaShift, MaMethod, MaAppliedPrice, 0);
      
   //MaVal is no longer == 0, so we can continue   
   if (bid > MaVal) 
      return(false);   


   
   //Got here, so ok to send the order
   return(true);

}//End bool confirmShortSignal(string symbol, int pairIndes)

:xm: :rocket:
Author:  SteveHopwood [ Wed Jun 01, 2022 6:31 pm ]
Post subject:  Scalping New York

Now is as good a time as any to remind/tell people how SHF is a hugely cooperative forum.

Yes, it is my name at the top but we are only so successful because of the contributions of countless others. Read my code and you will see my written appreciation of the contributions of so many coders over the years - some of whom have forgotten more about coding than I will ever learn.

I am not going to name names here because I forget names and will inevitably leave people out. You know who you are - you are members of my Elite group here.

Not everyone who makes/made fantastic contributions are members of the Elite. This does not make you any the less invaluable.

Onwards and upwards.

:xm: :rocket:
All times are UTC Page 17 of 31