Goldy

Post Reply
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.

Re: Goldy

Post by SteveHopwood »

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:
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.
trader689
Trader
Posts: 674
Joined: Thu Nov 17, 2011 12:53 am

Re: Goldy

Post by trader689 »

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:
AltosT
Trader
Posts: 85
Joined: Mon Nov 21, 2011 8:44 am
Location: Australia

Re: Goldy

Post by AltosT »

Hi trader, it will be :

Afterprime is the official SHF broker. Read about them at viewtopic.php?p=175790#p175790.
trader689
Trader
Posts: 674
Joined: Thu Nov 17, 2011 12:53 am

Re: Goldy

Post by trader689 »

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.
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.

Re: Goldy

Post by SteveHopwood »

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:
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.
jptwardy
Trader
Posts: 49
Joined: Thu Nov 12, 2020 2:16 pm

Re: Goldy

Post by jptwardy »

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
User avatar
ChartRunner
Posts: 7
Joined: Sat Feb 18, 2023 3:52 pm

Re: Goldy

Post by ChartRunner »

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.
I wish you a successful trading day, Chart :-BD
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.

Re: Goldy

Post by SteveHopwood »

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:
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.

Re: Goldy

Post by SteveHopwood »

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:
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.
jptwardy
Trader
Posts: 49
Joined: Thu Nov 12, 2020 2:16 pm

Re: Goldy

Post by jptwardy »

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
Post Reply

Return to “Automated trading systems”