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
1Direction
Trader
Posts: 97
Joined: Sun Jan 29, 2017 8:37 pm
Location: London

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

Post by 1Direction »

Hi Steve

I'm receiving those entries in the log files using previous version 1e. Just wanted to let you know if you work on a new version over the weekend.

After a while the EA dashboard is removed and only the small smiley :) in the up right corner shows on the chart. I've set automateChartOpeningAndClosing to false maybe this has something to do with this behavior.

Thanks you for all the hard work and the most amazing EAs ever!

Have a nice weekend ;)
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 »

I have updated the bot with some basket information in the chart feedback and will upload tomorrow.

This post is for fledgling codeslingers or those of us who are coming to grips with CrapQl4 arrays.

Here is a pm I sent to Rene earlier:
SteveHopwood wrote:Ehup Rene

I hope you are keeping well.

My OnDeinit() functions have a lot of code such as this:

ArrayFree(TradePair);
ArrayResize(TradePair, 0);
ArrayFree(tradingStatus);
ArrayResize(tradingStatus, 0);

Once the memory is released by the ArrayFree(), is the ArrayResize() achieving anything?

Cheers
Here is his highly helpful reply:
renexxxx wrote:
Hi Steve,

No, i don't think it does. ArrayFree() already resizes the array to 0, as this script attests:

Code: Select all

int dynamicArray[];

void OnStart() {

   ArrayResize( dynamicArray, 100 );
   PrintFormat( "The size of dynamicArray = %d", ArraySize(dynamicArray) );
   ArrayFree( dynamicArray );
   PrintFormat( "The size of dynamicArray = %d", ArraySize(dynamicArray) );
}
Furthermore, whilst on the topic of freeing dynamic arrays, this: I think that Empty4 is freeing global dynamic memory automatically in the Deinit phase. However, in my programs I don't want to rely on that, as you never know for sure with Empty4. So, I think that it is a good practise to have the ArrayFree()'s in the Deinit(). However, in other functions that use global dynamic memory, you must use ArrayFree() to free the old memory, eg.

Code: Select all

int orderTickets[];

void getOrders() {

   ArrayFree(orderTickets);

   for(int iOrder=OrdersTotal()-1; iOrder >= 0; iOrder--) {
   
      if ( !OrderSelect(iOrder, SELECT_BY_POS, MODE_TRADES) ) continue;
   
      int currentSize = ArraySize(orderTickets);
      ArrayResize(orderTickets, currentSize+1);
      orderTickets[currentSize] = OrderTicket();
   }
}
In this code, getOrders() can be called many times in the program, and it won't autmatically free the old memory. If you would use ArrayResize(orderTickets,0) instead of ArrayFree(orderTickets) at the start of the routine, it would merely set the index to the end of the orderTickets to zero, without freeing the elements beyond that. Anyway, that it as far as I understand the mysteries of Empty4....

Have a good weekend!

Rene.
All my recent EA's have ArrayResize(SomeArray, 0) at the top of CountOpenTrades followed by an initialisation e.g.

Code: Select all

   ArrayResize(GridOrderBuyTickets, 0);
   ArrayInitialize(GridOrderBuyTickets, -1);
This whole snippet would be replaced by:

Code: Select all

   ArrayFree(GridOrderBuyTickets);
We continue to live and learn. Thanks Rene. :clap: :clap: :clap: :clap:

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

V 1f is in post 1. This both fixes the whole-position as a basket bug and includes a display of the targets etc.

On a technical note, bearing in mind what Rene taught us last night, I have replaced ArrayResize(SomeVariable, 0) with ArrayFree(SomeVariable) where appropriate.

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

I am trying to find settings that will allow noobs to load CP onto their tiny starter accounts and just leave to its own devices. I adapted Marx64's set from the single trader thread and loaded it onto a demo with a $300 starting balance. Here are the results from the first two weeks of trading:
XAUUSDH4.png
The balance is a few bits over $340. It has been an interesting ride:
  • end of week 1: balance $325 and flat for the weekend.
  • Tuesday of week 2: balance c. $340.
  • Wednesday night: balance $292. You can see the main culprit in the picture.
  • Thursday night: clawed back to a fraction over $300
  • Friday night: back to a fraction over $340 and flat for the weekend.
Friday was so good because CP caught the Euro strengthening and several EURxxx pairs closed at excellent profits at the new peak high. I had three different EURxxx pairs all buying at one point. It would have been a bloodbath if the market had suddenly turned back around.

This week I am adding the balance filters to make sure this cannot happen. I am also only trading the high swap pairs in the direction of the positive swap. I have attached the set file in case any of you guys want to tweak it further.

:xm:
You do not have the required permissions to view the files attached to this post.
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.

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

Post by SteveHopwood »

mOnk111 sent me a bloop spot yesterday, in the Candlestick trailing stop function. :clap: :clap: :clap:

I am guessing this has not surfaced before because nobody is using it, so I am not rushing out a fix - it will be in the next release.

If you want to feel proud of yourself, load the code into the editor and do a search for "NULL". NULL is a crapql4 constant that means the chart the EA/indi/script is loaded onto. For example, you will be taken to this line of code:
if (OldCstBars == iBars(NULL, CstTimeFrame)) return;


if (OldCstBars == iBars(OrderSymbol(), CstTimeFrame)) return;

Repeat this process until the search stops finding NULL.

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

I am using your set file and I have CadPairsPositiveOnly=true and OnlyTradePositiveSwap=false. USDCAD Trading Status is ticked and it's opened a chart window but has not opened a trade. No messages in the logs. Everything looks ok so hopefully my heads not on the chopping block :oops:

Bob
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 »

Barcode » Mon Nov 27, 2017 9:39 pm wrote:Steve,

I am using your set file and I have CadPairsPositiveOnly=true and OnlyTradePositiveSwap=false. USDCAD Trading Status is ticked and it's opened a chart window but has not opened a trade. No messages in the logs. Everything looks ok so hopefully my heads not on the chopping block :oops:

Bob
I will have a look. I have mentioned before how difficult it is to turn a single trader into a multi-pair trader, so it is always possible that I have mucked up adding the swap filter code. I haven't had a trade all day, so try turning the filter off and see if the bot takes the trades.

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

I have found the bloop. Invoking the filter turns off either TradeLong or TradeShort, depending upon which swap is negative.

Once turned off, they remain turned off. There is no place for TradeLong and TradeShort in this bot, so disable the swap filter for now. I will recode the filter tomorrow.

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

Ok, thanks Steve.
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 »

V 1g is in post 1 with a fix for the high swap filter bloop and the candlestick trailing stop bloop. Not using either of them? You do not need the update. Await a few more until you download the latest fixes. Just don'g miss any and then post something stupid, ok?

Codeslingers and DIYers, here is what I have done about the swap filter:
extern bool TradeLong=true;
extern bool TradeShort=true;

have become:
bool TradeLong=true;//Not needed as an extern here
bool TradeShort=true;//Not needed as an extern here

The go to void AutoTrading()
The first few lines of code are:

Code: Select all

void AutoTrading()
{
   //Think of this being the equivalent to OnTimer() in a multi-pair
   //EA without the dashboard element.
  
   for (int PairIndex = 0; PairIndex < ArraySize(TradePair); PairIndex++)
   {
      string symbol = TradePair[PairIndex];
      GetBasics(symbol);
  
Underneath GetBasics(symbol); I have added:

Code: Select all

      //For the swap filter. It will set these variable to false if the swap filter fails.
      //The variables are left behind from the conversion of the single pair trading EA
      //to the multi-pair one. This seems to me to be the easiest way of dealing with the problem
      //that the filter causes of not resetting here.
      TradeLong = true;
      TradeShort = true;
 
This saves having to rewrite the swap filter function. Let's hope it really is this simple.

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

Return to “Thingy Bob EA's”