Scalping New York

Post Reply
User avatar
pivotter
Trader
Posts: 38
Joined: Sun May 01, 2016 12:02 am
Location: The Hague, The Netherlands

Scalping New York

Post by pivotter »

biobier » Fri Jun 03, 2022 11:56 am wrote:I have this issue only on my slow (busy) development system. I think that is the reason why only some ppl have that issue. The others run a proper sized system :P

However there still is something more than the previous error... Created a test script (attached).
See this part of the output especially the time for CADCHF:

Code: Select all

0	13:42:09.307	GetBarDetails AUDUSD,M5: Details last bar for AUDUSD 15: Time=2022.06.03 14:15:00, Open=0.7243000000000001, High=0.72514, Low=0.7242499999999999, Close=0.72484, Volume=1047
0	13:42:09.320	GetBarDetails AUDUSD,M5: Details last bar for CADCHF 15: Time=2022.04.28 12:45:00, Open=0.75662, High=0.7571099999999999, Low=0.75621, Close=0.7569900000000001, Volume=1800
0	13:42:09.336	GetBarDetails AUDUSD,M5: CADCHF Got error (4066): requested history data is in update state Will etry
0	13:42:09.336	GetBarDetails AUDUSD,M5: Details last bar for CADCHF 15: Time=2022.04.28 12:45:00, Open=0.75662, High=0.7571099999999999, Low=0.75621, Close=0.7569900000000001, Volume=1800
0	13:42:09.336	GetBarDetails AUDUSD,M5: Details last bar for CADJPY 15: Time=2022.06.03 14:15:00, Open=103.481, High=103.534, Low=103.466, Close=103.514, Volume=1720
Time=2022.04.28 12:45:00 WTF? 14:15 is the right one. Running the script again that symbol get the right time. Feel free to play around with the script. But I think we are getting closer....

Thanks Biobier

I adapted the code to prevent the loading of open and close data from the wrong candle by checking for the timestamp:(on the assumption that if the right candle time is retrieved the data for iopen and iclose will be there as well)


double copen = 0;
double cclose = 0;
int k = 0;
GetLastError();//reset possible uncatched error
int err=GetLastError();
while ((closeEnough(copen, 0) ) && (k < 200) && (!IsStopped())){
if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
copen = iOpen(symbol, tf, 1);
err=GetLastError();
if(err>0) Sleep(10);
}
if (k==100) {RefreshRates();}
k++; }

//-----------
k = 0;
GetLastError();//reset possible uncatched error
err=GetLastError();
while ((closeEnough(cclose, 0) ) && (k < 200) && (!IsStopped())){
if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
cclose = iClose(symbol, tf, 1);
err=GetLastError();
if(err>0) Sleep(10);}
if (k==100) {RefreshRates();}
k++; }

direction = noney;//Default, and unlikely to happen but does sometimes

if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
if (cclose >= copen)
{
direction = longy;
return;
}//if (cclose > copen)

if (cclose <= copen)
{
direction = shorty;
return;
}//if (cclose > copen)
}//if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
You think the rumbling comes from our "magic" black-box ?
biobier
Trader
Posts: 72
Joined: Mon Mar 18, 2019 7:24 am

Scalping New York

Post by biobier »

SteveHopwood » Fri Jun 03, 2022 7:58 pm wrote:
biobier » Fri Jun 03, 2022 8:02 am wrote:Spotted that in function testForAlreadyTradedThisHour it is checked for all orders (not for our magicnumber only)

Code: Select all

      if (OrderMagicNumber() != MagicNumber) continue;
Need to be added.
The reason I did not bother with this in the first place is that Scalpy is a whole position basket trader. Only an idiot then tries other strategies at the same time.

Leaving out the magic number check is a protection measure for the dimwits - and a deliberate one.

:xm: :rocket:
Agree from that point BUT it is good to have for testing ;-) With that I could change the magic number and wait minutes to trigger scalpy to send trades again.
Must-reads for FOREX NOOBS as me:
Help for Newbies.
Information For Beginners
biobier
Trader
Posts: 72
Joined: Mon Mar 18, 2019 7:24 am

Scalping New York

Post by biobier »

pivotter » Fri Jun 03, 2022 9:19 pm wrote:[

Thanks Biobier

I adapted the code to prevent the loading of open and close data from the wrong candle by checking for the timestamp:(on the assumption that if the right candle time is retrieved the data for iopen and iclose will be there as well)

Code: Select all

 double copen = 0;
   double cclose = 0;
   int k = 0;
   GetLastError();//reset possible uncatched error
   int err=GetLastError();
   while ((closeEnough(copen, 0) ) && (k < 200) && (!IsStopped())){
   if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
      copen = iOpen(symbol, tf, 1);
      err=GetLastError();
      if(err>0) Sleep(10);
      }
      if (k==100)  {RefreshRates();} 
      k++;   }

    //-----------
    k = 0;
   GetLastError();//reset possible uncatched error
   err=GetLastError(); 
   while ((closeEnough(cclose, 0) ) && (k < 200) && (!IsStopped())){
   if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
      cclose = iClose(symbol, tf, 1); 
      err=GetLastError();
      if(err>0) Sleep(10);}
      if (k==100)  {RefreshRates();}
      k++;  }

   direction = noney;//Default, and unlikely to happen but does sometimes
   
   if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
   if (cclose >= copen)
   {
      direction = longy;
      return;
   }//if (cclose > copen)
   
   if (cclose <= copen)
   {
      direction = shorty;
      return;
   }//if (cclose > copen)
   }//if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
With that only the hour is compared so it would not work if any other TF is set.
As I understand the documentation of RefreshRates(), it only refreshes the predefined arrays and variables like Ask, Bid, Time[] etc. So that will not help in this case. I also thought about to compare iTime with iTime for the symbol the EA is loaded on but that did not work for some reason (I assume the milliseconds or so differ always).
Must-reads for FOREX NOOBS as me:
Help for Newbies.
Information For Beginners
User avatar
pivotter
Trader
Posts: 38
Joined: Sun May 01, 2016 12:02 am
Location: The Hague, The Netherlands

Scalping New York

Post by pivotter »

yes, we can replace 60 with TradingTimeFrame, np, as for the Empty4 documentation it is from time to time not up to date and it only refreshes once after 100 attempts.
I tested one run and had no H1 wrong direction trades, but i also cheated as i added ForceLoadHistoricalData() to the top of sendBasket() to make sure all H! and H4 candles are updated before all symbols are scanned,

Next week i'll run a version without loadhistory to see if it works as well
Last edited by pivotter on Fri Jun 03, 2022 9:15 pm, edited 1 time in total.
You think the rumbling comes from our "magic" black-box ?
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Scalping New York

Post by SteveHopwood »

biobier » Fri Jun 03, 2022 8:39 pm wrote:
pivotter » Fri Jun 03, 2022 9:19 pm wrote:[

Thanks Biobier

I adapted the code to prevent the loading of open and close data from the wrong candle by checking for the timestamp:(on the assumption that if the right candle time is retrieved the data for iopen and iclose will be there as well)

Code: Select all

 double copen = 0;
   double cclose = 0;
   int k = 0;
   GetLastError();//reset possible uncatched error
   int err=GetLastError();
   while ((closeEnough(copen, 0) ) && (k < 200) && (!IsStopped())){
   if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
      copen = iOpen(symbol, tf, 1);
      err=GetLastError();
      if(err>0) Sleep(10);
      }
      if (k==100)  {RefreshRates();} 
      k++;   }

    //-----------
    k = 0;
   GetLastError();//reset possible uncatched error
   err=GetLastError(); 
   while ((closeEnough(cclose, 0) ) && (k < 200) && (!IsStopped())){
   if (TimeHour(iTime(symbol, 60, 1)) == (TimeHour(TimeCurrent())-1)){
      cclose = iClose(symbol, tf, 1); 
      err=GetLastError();
      if(err>0) Sleep(10);}
      if (k==100)  {RefreshRates();}
      k++;  }

   direction = noney;//Default, and unlikely to happen but does sometimes
   
   if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
   if (cclose >= copen)
   {
      direction = longy;
      return;
   }//if (cclose > copen)
   
   if (cclose <= copen)
   {
      direction = shorty;
      return;
   }//if (cclose > copen)
   }//if ((!closeEnough(copen, 0) ) && (!closeEnough(cclose, 0) )){
With that only the hour is compared so it would not work if any other TF is set.
As I understand the documentation of RefreshRates(), it only refreshes the predefined arrays and variables like Ask, Bid, Time[] etc. So that will not help in this case. I also thought about to compare iTime with iTime for the symbol the EA is loaded on but that did not work for some reason (I assume the milliseconds or so differ always).
I believe I mentioned this earlier.

Can we put RefreshRates() to bed please, folks. I know you are trying to help and we are all deeply grateful. Just forget RefreshRates() here. It does not help. Truly. Honestly. Cross my heart and hope my pupils have done some practise over the break. Forlorn hope, I know, but you never know.

:xm: :rocket:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Scalping New York

Post by SteveHopwood »

Consider this folks:

Scalpy is doing rather well.

How about letting him do his thingy for a while instead of endlessly angsting about the stuff that is not quite right.

Spend your life trying to hunt down and correct empty4 insanities and you will go bonkers. Guess how I know. ;)

:xm: :rocket:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
pivotter
Trader
Posts: 38
Joined: Sun May 01, 2016 12:02 am
Location: The Hague, The Netherlands

Scalping New York

Post by pivotter »

REfreshrates() is in de bin and looking forward to a new week with Scalpy!
You think the rumbling comes from our "magic" black-box ?
User avatar
tomele
Administrator
Posts: 1208
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

Scalping New York

Post by tomele »

If I may kindly join your conversation.
To get symbol data using functions for accessing timeseries and indicators, make sure that the symbol exists in the MarketWatch window. If the symbols is not available in Market watch, enable it using the SymbolSelect(symbol_name, true) function before you request the data.

The symbol can be hidden from MarketWatch after 10 minutes since the last access to the symbol history, i.e. since the call of functions like iOpen(), iHigh(), CopyTime() etc. This is due to the fact that the terminal stores symbol data for 10 minutes since the last access to them; after that unused data are automatically deleted from the terminal memory.
This is why some users have the problem while others don't - different Market watch lists. Thus multisymbol EAs should always have a SymbolSelect() loop over all needed symbols (at least) in OnInit().

Cheers
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Scalping New York

Post by SteveHopwood »

pivotter » Fri Jun 03, 2022 8:46 pm wrote:but i also cheated as i added ForceLoadHistoricalData() to the top of sendBasket() to make sure all H! and H4 candles are updated before all symbols are scanned,
That is a great idea. Can you post the code please, so I can add it?

:xm: :rocket:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Scalping New York

Post by SteveHopwood »

tomele » Sat Jun 04, 2022 10:28 am wrote:If I may kindly join your conversation.

This is why some users have the problem while others don't - different Market watch lists. Thus multisymbol EAs should always have a SymbolSelect() loop over all needed symbols (at least) in OnInit().

Cheers
Thanks Thomas

mql4 documentation mostly confuses me. My limited understanding is that SymbolSelect() returns 'false' if the symbol is not offered by the broker and so cannot be placed in the Watch window.

I have added this to void sendBasket(), just above the getDirection() command:

Code: Select all

      //Ensure the symbol is in the market watch window
      bool symbolExists = SymbolSelect(symbol, true);
      if (!symbolExists)
         continue;
Correct?

:xm: :rocket:
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Automated trading systems”