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

Goldy
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=6421
Page 5 of 14
Author:  SteveHopwood [ Sat Apr 26, 2025 4:26 pm ]
Post subject:  Re: Goldy

I have started an experiment with not sending take profits with individual trades. Details in "Edit 26th April 2025" in post 1. There are login details that will allow you to monitor the progress, or otherwise, of this experiment.

--------------------------------------------

This has nothing to do with Goldy trading.

For those of us who have difficulty reading the print on our demo platforms, Windows 10 and 11 has provided a neat helping hand, called "Magnifier".

Chromes Copilot AI app provided this to access Magnifier:
"You can open Magnifier in Windows 10 quickly with these methods:
- Shortcut Key: Press Windows + Plus (+) to turn it on instantly.
- Start Menu: Click the Start menu, type Magnifier, and hit Enter.
- Settings: Go to Settings > Ease of Access > Magnifier, then toggle it on.

To turn it off, press Windows + Escape (Esc). "

Hover the mouse cursor over the text you need magnifying then hold the Windows key and tap the + (plus) key to make the text larger. Hold the Windows key and tap the - (minus) key to return to normal size.

This has saved me from a lot of squinting. :good:

:xm: :rocket:
Author:  trader689 [ Sat Apr 26, 2025 9:28 pm ]
Post subject:  Re: Goldy

thanks Steve, could you point to which broker those demo login details are for. I tried the global prime web trader and on an Empty4 terminal but couldn't make get it to connect

trader
SteveHopwood wrote: Sat Apr 26, 2025 4:26 pm I have started an experiment with not sending take profits with individual trades. Details in "Edit 26th April 2025" in post 1. There are login details that will allow you to monitor the progress, or otherwise, of this experiment.

--------------------------------------------

This has nothing to do with Goldy trading.

For those of us who have difficulty reading the print on our demo platforms, Windows 10 and 11 has provided a neat helping hand, called "Magnifier".

Chromes Copilot AI app provided this to access Magnifier:
"You can open Magnifier in Windows 10 quickly with these methods:
- Shortcut Key: Press Windows + Plus (+) to turn it on instantly.
- Start Menu: Click the Start menu, type Magnifier, and hit Enter.
- Settings: Go to Settings > Ease of Access > Magnifier, then toggle it on.

To turn it off, press Windows + Escape (Esc). "

Hover the mouse cursor over the text you need magnifying then hold the Windows key and tap the + (plus) key to make the text larger. Hold the Windows key and tap the - (minus) key to return to normal size.

This has saved me from a lot of squinting. :good:

:xm: :rocket:
Author:  AltosT [ Sat Apr 26, 2025 9:38 pm ]
Post subject:  Re: Goldy

Hi trader, it will be :

Afterprime is the official SHF broker. Read about them at viewtopic.php?p=175790#p175790.
Author:  trader689 [ Sat Apr 26, 2025 9:45 pm ]
Post subject:  Re: Goldy

thanks Altos, I had tried the afterprime webtrader before I posted but that only offers a live server so that's why it probably did not work - have now tried in an Empty4 terminal and it's working

trader
AltosT wrote: Sat Apr 26, 2025 9:38 pm Hi trader, it will be :

Afterprime is the official SHF broker. Read about them at viewtopic.php?p=175790#p175790.
Author:  SteveHopwood [ Sun Apr 27, 2025 4:02 pm ]
Post subject:  Re: Goldy

I received this as part of a pm from ChartRunner:
ChartRunner wrote: Thu Apr 24, 2025 6:57 pm
By the way, just wanted to share a quick observation: because the equity on my AP demo account was dropping, I added a deposit to help avoid a margin call. But after that, Goldy closed all the orders, since it treated the deposit as if the equity profit target had been reached. 😅

Maybe it would make sense to exclude deposits from the equity profit logic, so it doesn’t trigger premature closures? Just a thought—but overall, loving the progress and excited to keep testing!
I am not sure that it is possible to deal with this in the code. I will think about it but for now, here is what to do:
  • Remove Goldy from the chart.
  • Press the F3 key to open a window that shows the Global Variables that hold the values Goldy needs when she restarts.
  • Assuming the pair is XAUUSD, then delete the GV's named, "XAUUSD cash to add" and, "XAUUSD hedged profit target".
  • Wait for the additional funds to show in the trading window, then restart Goldy. She will recalculate the equity profit target.
:xm: :rocket:
Author:  jptwardy [ Sun Apr 27, 2025 11:32 pm ]
Post subject:  Re: Goldy

I see that the default tradesundaycandle is false. How does that work with the open/pending positions? The ea currently indicates that it is outside trading hours. Thanks
Author:  ChartRunner [ Mon Apr 28, 2025 10:24 am ]
Post subject:  Re: Goldy

SteveHopwood wrote: Sun Apr 27, 2025 4:02 pm I received this as part of a pm from ChartRunner:
ChartRunner wrote: Thu Apr 24, 2025 6:57 pm
By the way, just wanted to share a quick observation: because the equity on my AP demo account was dropping, I added a deposit to help avoid a margin call. But after that, Goldy closed all the orders, since it treated the deposit as if the equity profit target had been reached. 😅

Maybe it would make sense to exclude deposits from the equity profit logic, so it doesn’t trigger premature closures? Just a thought—but overall, loving the progress and excited to keep testing!
I am not sure that it is possible to deal with this in the code. I will think about it but for now, here is what to do:
  • Remove Goldy from the chart.
  • Press the F3 key to open a window that shows the Global Variables that hold the values Goldy needs when she restarts.
  • Assuming the pair is XAUUSD, then delete the GV's named, "XAUUSD cash to add" and, "XAUUSD hedged profit target".
  • Wait for the additional funds to show in the trading window, then restart Goldy. She will recalculate the equity profit target.
:xm: :rocket:
Steve,
I think to prevent EA from treating manual deposits as “profit,” we need to track how much we’ve deposited since the strategy started (or since you last reset) and subtract that from the equity when you compute “equity‐profit”.
Something like this:

Code: Select all

 //––– Global variables –––
double g_initialBalance;    // Balance at EA start (or last reset)
double g_totalDeposits;     // Cumulative manual deposits
double g_lastBalance;       // Balance in the previous tick

int OnInit()
{
   // Capture starting balance
   g_initialBalance = AccountBalance();
   g_lastBalance      = g_initialBalance;
   g_totalDeposits    = 0.0;
   
   // … your existing init code …
   return(INIT_SUCCEEDED);
}

void OnTick()
{
   // 1) Detect any manual deposit (positive jump in AccountBalance
   //    that isn’t due to closed trades—in demo it’s just a deposit)
   double currentBalance = AccountBalance();
   double deltaBalance   = currentBalance - g_lastBalance;
   if(deltaBalance > 0)
   {
      // Assume it’s a deposit; accumulate
      g_totalDeposits += deltaBalance;
   }
   g_lastBalance = currentBalance;

   // 2) Compute “true” profit based on equity minus deposits
   double currentEquity     = AccountEquity();
   double equityNetOfDeposits = currentEquity - g_totalDeposits;
   double profitSoFar       = equityNetOfDeposits - g_initialBalance;

   // 3) Your original equity‐target check
   //    (replace YOUR_PROFIT_TARGET with your number or input variable)
   if(profitSoFar >= YOUR_PROFIT_TARGET)
   {
      // close all trades — your existing close logic
      CloseAllTrades();
   }

   // … rest of your OnTick logic …
}

...

The idea :idea: is:

OnInit

Store the starting balance (g_initialBalance) and initialize g_totalDeposits to zero.

OnTick

Compute deltaBalance = AccountBalance() – g_lastBalance.
If deltaBalance > 0, assume it’s a deposit and add it to g_totalDeposits.
Update g_lastBalance for the next tick.

Profit calculation


equityNetOfDeposits = AccountEquity() – g_totalDeposits
profitSoFar = equityNetOfDeposits – g_initialBalance
Only when profitSoFar meets or exceeds your target do you invoke CloseAllTrades().

This way, any manual top-ups don’t count as “strategy profit” and won’t prematurely trip your equity-target close logic.
Author:  SteveHopwood [ Mon Apr 28, 2025 3:58 pm ]
Post subject:  Re: Goldy

jptwardy wrote: Sun Apr 27, 2025 11:32 pm I see that the default tradesundaycandle is false. How does that work with the open/pending positions? The ea currently indicates that it is outside trading hours. Thanks
I forgot about this. Good spot. It should be 'true'.

I am going to add code that will work with Friday closing hour. It will tell Goldy to keep trading normally even if the Friday stop trading hour is reached, if there are market orders still open. She will stop further trading once/if the equity TP is hit. This will allow us to go 'flat' for the weekend and either restart on Sunday night or wait until Monday morning.

:xm: :rocket:
Author:  SteveHopwood [ Mon Apr 28, 2025 4:06 pm ]
Post subject:  Re: Goldy

ChartRunner wrote: Mon Apr 28, 2025 10:24 am
Steve,
I think to prevent EA from treating manual deposits as “profit,” we need to track how much we’ve deposited since the strategy started (or since you last reset) and subtract that from the equity when you compute “equity‐profit”.
Something like this:

Code: Select all

 //––– Global variables –––
double g_initialBalance;    // Balance at EA start (or last reset)
double g_totalDeposits;     // Cumulative manual deposits
double g_lastBalance;       // Balance in the previous tick

int OnInit()
{
   // Capture starting balance
   g_initialBalance = AccountBalance();
   g_lastBalance      = g_initialBalance;
   g_totalDeposits    = 0.0;
   
   // … your existing init code …
   return(INIT_SUCCEEDED);
}

void OnTick()
{
   // 1) Detect any manual deposit (positive jump in AccountBalance
   //    that isn’t due to closed trades—in demo it’s just a deposit)
   double currentBalance = AccountBalance();
   double deltaBalance   = currentBalance - g_lastBalance;
   if(deltaBalance > 0)
   {
      // Assume it’s a deposit; accumulate
      g_totalDeposits += deltaBalance;
   }
   g_lastBalance = currentBalance;

   // 2) Compute “true” profit based on equity minus deposits
   double currentEquity     = AccountEquity();
   double equityNetOfDeposits = currentEquity - g_totalDeposits;
   double profitSoFar       = equityNetOfDeposits - g_initialBalance;

   // 3) Your original equity‐target check
   //    (replace YOUR_PROFIT_TARGET with your number or input variable)
   if(profitSoFar >= YOUR_PROFIT_TARGET)
   {
      // close all trades — your existing close logic
      CloseAllTrades();
   }

   // … rest of your OnTick logic …
}

...

The idea :idea: is:

OnInit

Store the starting balance (g_initialBalance) and initialize g_totalDeposits to zero.

OnTick

Compute deltaBalance = AccountBalance() – g_lastBalance.
If deltaBalance > 0, assume it’s a deposit and add it to g_totalDeposits.
Update g_lastBalance for the next tick.

Profit calculation


equityNetOfDeposits = AccountEquity() – g_totalDeposits
profitSoFar = equityNetOfDeposits – g_initialBalance
Only when profitSoFar meets or exceeds your target do you invoke CloseAllTrades().

This way, any manual top-ups don’t count as “strategy profit” and won’t prematurely trip your equity-target close logic.
Fantastic. Thanks. :clap: :clap: :clap: :clap: :clap:

:xm: :rocket:
Author:  jptwardy [ Wed Apr 30, 2025 4:42 pm ]
Post subject:  Re: Goldy

Steve - in using this for a while I'd also like to see something similar to the deposit code - when you remove profits from the account. It would be nice to have a setting to be able to stop live trading when the next equity target is met, allowing you to remove profits and then either run the script manually or automatically to reset the EA. Thanks
All times are UTC Page 5 of 14