HGB's Candle Power multi-pair combined trader and dashboard

EA's inspired by nanningbob's work here, especially those based on his 240 Moving Average trend detection filter.
Post Reply
User avatar
dreambig2
Trader
Posts: 46
Joined: Sat Nov 19, 2016 12:54 am
Location: US

HGB's Candle Power multi-pair combined trader and dashboard

Post by dreambig2 »

pandaboy » Fri Nov 17, 2017 1:08 pm wrote:I am testing H4 with Leon's settings.. SL 25.. TP is open.. BE at 50.. JS 10.. looks promising. made 820 pips and closed everything manually.. just 2 days though.. will run it for few weeks and see the results.
Thank You Leon and Steve.. :hi:
Hi Pandaboy,

Are you closing at the end of each 4 hour cycle or are you closing at the end of the trading day?
I have started a set and have several trades already well into profit into my first 4 hours.

I also loaded Leons Strict daily before London open last night and see no pending or trades but I think trades and pendings come at end of day/beginning of new day if I understand correctly.

thx
db
eRIKb81
Trader
Posts: 22
Joined: Wed Jul 05, 2017 6:03 am

HGB's Candle Power multi-pair combined trader and dashboard

Post by eRIKb81 »

The whole-basket-close still is not working. It closed only the last ticket with the right magic number, in this case 1 out of 4 orders.

Tried it again when the basket was in profit, this time no orders got closed. This makes me think something goes wrong in CountOpenTrades(string symbol, int PairIndex).

Perhaps the block at line 1728 "//Whole position monitor if TradeWholePositionAsBasket is enabled" should be moved the the position after the "//Ensure the EA 'owns' this trade" block?

I haven't done any programming in ages, but I hope I narrowed it down.

The good news is that there was profit today!
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.

HGB's Candle Power multi-pair combined trader and dashboard

Post by SteveHopwood »

eRIKb81 » Tue Dec 05, 2017 7:03 pm wrote: I haven't done any programming in ages, but I hope I narrowed it down.
You have indeed. Thanks for sticking with this. Your solution of mucking around with CountOpenTrades() was so clearly wrong that it sent me looking elsewhere. The culprit was within void CloseAllTradesBelongingToEA(), which was closing only those trades held within the FifoTicket array. Only those trades belonging to the currently selected symbol would be held in this array.

Peasants, my latest attempted fix is in post 1 - V 1k.

Classy people, compare the new function with the existing one:

Code: Select all

void CloseAllTradesBelongingToEA()
{

   WholePositionForceTradeClosure = false;
   
   if (OrdersTotal() == 0) return;
   
   bool result = false;
   for (int pass = 0; pass <= 1; pass++)
   {
      if (OrdersTotal() == 0 || OpenTrades == 0)
         break;
      for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
      {
         if (!BetterOrderSelect(cc, SELECT_BY_POS, MODE_TRADES) ) continue;
         if (OrderMagicNumber() != MagicNumber) continue;
         
         while(IsTradeContextBusy()) Sleep(100);
         if (OrderType() < 2)
         {
            result = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, CLR_NONE);
            if (result) 
            {
               cc++;
               OpenTrades--;
            }//(result) 
            
            if (!result) ForceTradeClosure= true;
         }//if (OrderType() < 2)
         
         if (pass == 1)
            if (OrderType() > 1) 
            {
               result = OrderDelete(OrderTicket(), clrNONE);
               if (result) 
               {
                  cc++;
                  OpenTrades--;
               }//(result) 
               if (!result) WholePositionForceTradeClosure = true;
            }//if (OrderType() > 1) 
            
      }//for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
   }//for (int pass = 0; pass <= 1; pass++)
   
   //If full closure succeeded, then allow new trading
   if (!WholePositionForceTradeClosure) 
   {
      OpenTrades = 0;
      BuyOpen = false;
      SellOpen = false;
   }//if (!ForceTradeClosure) 


}//End void CloseAllTradesBelongingToEA()
This code examines every open trade and only rejects those that have the wrong magic number.

Poor Relations in the US: this basket closure is still available to you, I think, despite your government's ludicrous FIFO rules. Every time a trade closure fails, it will set the WholePositionForceTradeClosure flag which in turn tells the bot to keep on trying to close trades. They will all close eventually. This might take a while. I suggest revolution and an overthrow of your government.

:xm:
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
dreambig2
Trader
Posts: 46
Joined: Sat Nov 19, 2016 12:54 am
Location: US

HGB's Candle Power multi-pair combined trader and dashboard

Post by dreambig2 »

:smile: The H4 set I'm using got up to +$200 so I closed when down to +$100. Glad I did the second 4 hour cycle went south.
I did notice that old pendings were not being closed thus price was triggering these trades which appears contributing to the negative trades. Pretty sure these should have closed. Resetting platform and reloading set will see how goes next 4 hours.

db
eRIKb81
Trader
Posts: 22
Joined: Wed Jul 05, 2017 6:03 am

HGB's Candle Power multi-pair combined trader and dashboard

Post by eRIKb81 »

Minibloop: you forgot to replace 'ForceTradeClosure' with 'WholePositionForceTradeClosure' in pass 0.

Waiting for a profitable basket to test again :).
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.

HGB's Candle Power multi-pair combined trader and dashboard

Post by SteveHopwood »

eRIKb81 » Tue Dec 05, 2017 8:55 pm wrote:Minibloop: you forgot to replace 'ForceTradeClosure' with 'WholePositionForceTradeClosure' in pass 0.

Waiting for a profitable basket to test again :).
Nice spot. Thanks. :clap: :clap: :clap: :clap: Fix in post 1.

Classy people, go to void CloseAllTradesBelongingToEA() and find ForceTradeClosure; replace it with WholePositionForceTradeClosure. It will be around about line 3823 depending on how many of the updates you have been superbly crafting for yourselves. The offending line is:
if (!result) ForceTradeClosure= true;

and should be:
if (!result) WholePositionForceTradeClosure = true;

:xm:
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.
eRIKb81
Trader
Posts: 22
Joined: Wed Jul 05, 2017 6:03 am

HGB's Candle Power multi-pair combined trader and dashboard

Post by eRIKb81 »

The cashUPL calculation still counted all the trades from all the magic numbers. I moved the block@1728 for "//Whole position monitor if TradeWholePositionAsBasket is enabled" to after the "//All conditions passed, so carry on" block, like i tried yesterday.

It worked, cashUPL display in Empty4 works now, it was higher than the profit target, only the right positions got closed. Profitable basket closed.

EDIT: Ignore the sum at the end, that's just the daily balance.
EDIT2: The Cash UPL display somehow is not working for every EA, moving the block back to it's original place and adding "if (OrderMagicNumber() != MagicNumber) continue;" worked better.
You do not have the required permissions to view the files attached to this post.
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.

HGB's Candle Power multi-pair combined trader and dashboard

Post by SteveHopwood »

eRIKb81 » Wed Dec 06, 2017 10:27 am wrote:The cashUPL calculation still counted all the trades from all the magic numbers. I moved the block@1728 for "//Whole position monitor if TradeWholePositionAsBasket is enabled" to after the "//All conditions passed, so carry on" block, like i tried yesterday.

It worked, cashUPL display in Empty4 works now, it was higher than the profit target, only the right positions got closed. Profitable basket closed.

EDIT: Ignore the sum at the end, that's just the daily balance.
Thanks again Eric. :clap: :clap:

The Peasants' fix is V 1l in post 1.

Members of the Nobility, do a search for "//Whole position monitor if TradeWholePositionAsBasket is enabled" and copy this over the top of the code block:

Code: Select all

      //Whole position monitor if TradeWholePositionAsBasket is enabled
      double pips = 0;
      if (TradeWholePositionAsBasket)
         if (OrderMagicNumber() == MagicNumber)
            if (OrderType() < 2)
            {
               WholePositionCashUpl+= (OrderProfit() + OrderSwap() + OrderCommission());
               pips = CalculateTradeProfitInPips(OrderType());
               WholePositionPipsUpl+= pips;
            }//if (OrderType() < 2)
 
I have added the extra conditional if (OrderMagicNumber() == MagicNumber). This is a little bit of future-proofing in case people decide they want to treat all open trades on the platform as basket members regardless of their origin. I can change the code to be:
if (OrderMagicNumber() == MagicNumber || IgnoreMagicNumbers) if anybody wants this feature.

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

HGB's Candle Power multi-pair combined trader and dashboard

Post by Barcode »

Steve,

What the chance of getting an option added to the EA that writes the reason for the trade closure to the TradeComment. At present I am never quite sure why the trade closed.

This should be a big help for tuning the EA.

Bob
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

HGB's Candle Power multi-pair combined trader and dashboard

Post by renexxxx »

Barcode » Thu Dec 14, 2017 1:48 pm wrote: What the chance of getting an option added to the EA that writes the reason for the trade closure to the TradeComment.
The chance for that is 0.0%. The TradeComment field is set at the time the trade is opened and it can not be altered through code.

R.
Post Reply

Return to “Thingy Bob EA's”