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

Scalping New York
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=6189
Page 7 of 31
Author:  sangratan [ Sun May 22, 2022 9:49 pm ]
Post subject:  Scalping New York

Thank you Steve for your work here.... :hi: :good: :)
Author:  wallywonka [ Mon May 23, 2022 5:37 am ]
Post subject:  Scalping New York

Nice work Steve! :clap: :clap: :clap: :clap:
Author:  SteveHopwood [ Mon May 23, 2022 8:45 am ]
Post subject:  Scalping New York

I am nearly there.

This one is for the coders. Imagine MS sent a basket at 1.05 and your AutomaticStartCloseHour input is 4. This means you want the closure of a failed basket to happen at 5.00.

This expression results in a closure time of 5.05:
datetime autoCloseStarts = OrderOpenTime() + (3600 * AutomaticStartCloseHour);

Any ideas for losing the 5 minutes?

:xm: :rocket:
Author:  lemur6666 [ Mon May 23, 2022 2:25 pm ]
Post subject:  Scalping New York

Steve,

I played with them TimeToStruct / StructToTime before. :uff:

But before I sit down to code it pls clarify : if you opened order at 1:55 and your AutomaticStartCloseHour input is 4 than you want to close it at 5:00 or 6:00 ? In other words you want to round minutes down to full hour, correct ? I can imagine rouding up passed xx:30 and rounding down below 00:29 ... :idea:
Author:  Maximilian [ Mon May 23, 2022 2:51 pm ]
Post subject:  Scalping New York

SteveHopwood » Mon May 23, 2022 8:45 am wrote:I am nearly there.

This one is for the coders. Imagine MS sent a basket at 1.05 and your AutomaticStartCloseHour input is 4. This means you want the closure of a failed basket to happen at 5.00.

This expression results in a closure time of 5.05:
datetime autoCloseStarts = OrderOpenTime() + (3600 * AutomaticStartCloseHour);

Any ideas for losing the 5 minutes?

:xm: :rocket:
Maybe too simple but couldn´t be a quick and dirty solution to reduce the 3600 seconds by the offset minutes in seconds eg.

datetime autoCloseStarts = OrderOpenTime() + (3600 * AutomaticStartCloseHour-(TradingMinutes*60));

?

Greetings Max
Author:  SteveHopwood [ Mon May 23, 2022 3:49 pm ]
Post subject:  Scalping New York

Maximilian » Mon May 23, 2022 2:51 pm wrote:
SteveHopwood » Mon May 23, 2022 8:45 am wrote:I am nearly there.

This one is for the coders. Imagine MS sent a basket at 1.05 and your AutomaticStartCloseHour input is 4. This means you want the closure of a failed basket to happen at 5.00.

This expression results in a closure time of 5.05:
datetime autoCloseStarts = OrderOpenTime() + (3600 * AutomaticStartCloseHour);

Any ideas for losing the 5 minutes?

:xm: :rocket:
Maybe too simple but couldn´t be a quick and dirty solution to reduce the 3600 seconds by the offset minutes in seconds eg.

datetime autoCloseStarts = OrderOpenTime() + (3600 * AutomaticStartCloseHour-(TradingMinutes*60));

?

Greetings Max
Thanks again Max. The same solution came to me in the car on the way home from school, so we are on the right track.

MS is not quite ready yet. I just saw him close a basket at TP, then immediately send a fresh one - something we do not want. There is a function to prevent this but it is not working yet.

:xm: :rocket:
Author:  SteveHopwood [ Mon May 23, 2022 7:59 pm ]
Post subject:  Scalping New York

Multiple Scalpy is in post 1. Scroll down to my usual sign off for details.

There may be bugs, so keep an eye out for inconsistencies.

:xm: :rocket:
Author:  SteveHopwood [ Tue May 24, 2022 9:38 am ]
Post subject:  Scalping New York

I left MS running from 1 AM to 5 PM, shooting for a TP of $30 (0.1 lots) to generate lots of closures. This has been ridiculously successful, generating a profit of $300.

The problem of MS sending a fresh basket as soon as closing at TP persists and it is driving me nuts.

The last code block before sending the orders is this:

Code: Select all

   //We are in a trading hour, so test for a basket having been sent
   //and hitting TP within the hour
   //The function returns 'true' if it finds an order that opened
   //or closed during the hour, else returns 'false'
   if (testForAlreadyTradedThisHour() )
   {
      displayUserFeedback();
      return;
   }//if (testForAlreadyTradedThisHour() )
The function it calls is this:

Code: Select all

bool testForAlreadyTradedThisHour()
{

   //The function returns 'true' if it finds an order that opened
   //or closed during the hour, else returns 'false'

   if (OrdersHistoryTotal() == 0)
      return(false);
      

      
   int hourBroker = TimeHour(TimeCurrent() );
   
   
      
   for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
   {
      if (!betterOrderSelect(SELECT_BY_POS, MODE_TRADES, MODE_HISTORY) )
         continue;//Shouldn't happen, but no harm in making sure
         
         
      //Did the order open during the current hour?
      int openHour = TimeHour(OrderOpenTime() );     
      if (openHour == hourBroker)
         return(true);//Yes, so already traded this hour
         
         
      //Did the order close during the current hour?
      int closeHour = TimeHour(OrderCloseTime() );
      if (closeHour == hourBroker)
         return(true);//Yes, so no more trading until a new H1 candle forms. 
      
   }//for (int cc = OrdersHistoryTotal() - 1; cc >= 0; cc--)
   

   //Reached here, so OK to trade
   return(false);

}//End bool testForAlreadyTradedThisHour()
Can any of you bloop spotters see why it does not work?

:xm: :rocket:
Author:  tomele [ Tue May 24, 2022 10:10 am ]
Post subject:  Scalping New York

Hi Steve.

Look at the arguments of betterOrderSelect.

Cheers
Author:  SteveHopwood [ Tue May 24, 2022 10:26 am ]
Post subject:  Scalping New York

tomele » Tue May 24, 2022 10:10 am wrote:Hi Steve.

Look at the arguments of betterOrderSelect.

Cheers
Oops. :oops: Thanks Thomas.

I will post the fix later. For DIYers, the code should be:
if (!betterOrderSelect(SELECT_BY_POS, MODE_HISTORY) )
All times are UTC Page 7 of 31