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

Secret Bob's Basket
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3896
Page 2 of 40
Author:  Radar [ Sun Oct 26, 2014 1:14 am ]
Post subject:  Secret Bob's Basket

Hey Steve,

Just had a look at the GV's, and noticed that date/time and highest don't have the magic number appended, which will be a problem if we try using SBB on multiple timeframes in the same instance of Empty4.

The obvious work-around for now is to have an instance of Empty4 for each timeframe ;)

The average spread GV's don't need a unique identifier, as the spread should be the same across all timeframes, unless some bucketboy decides to play with it to grab more of our balance. Hmmm, I might just add the magic to them and see.

Take care,

&

Have fun!

Radar =8^)
Author:  renexxxx [ Sun Oct 26, 2014 1:30 am ]
Post subject:  Secret Bob's Basket

Hi Radar,

The code in SBB was written --I believe-- with the assumption that no other EA's would be running in the same Empty4 terminal. For instance, Steve uses AccountProfit() to work out the total basket profit. If you were running other EA's or other instances of the same EA, AccountProfit() would give you the total UPL for the account and not for the basket.
Author:  Radar [ Sun Oct 26, 2014 3:05 am ]
Post subject:  Secret Bob's Basket

Hey Renexxxx,
renexxxx ยป Sun Oct 26, 2014 11:00 am wrote:Hi Radar,

The code in SBB was written --I believe-- with the assumption that no other EA's would be running in the same Empty4 terminal. For instance, Steve uses AccountProfit() to work out the total basket profit. If you were running other EA's or other instances of the same EA, AccountProfit() would give you the total UPL for the account and not for the basket.
Thanks for the heads-up :)

Whenever I mod EA's or indicators, I always assume that they'll be part of a portfolio of systems... With basket EA's, I check/set a GV with the starting date/time of a basket, and tally the profit/loss of both open and closed trades (filtered by magicnumber) back to that date to determine when to close on GEC, and delete the GV when closing the basket. That way, I don't need to know the balance or equity at the start of a new basket.

It takes a bit more code and processing time, but gives me the flexibility to test variations on settings or timeframes on the same account.

Have fun!

Radar =8^)
Author:  SteveHopwood [ Sun Oct 26, 2014 9:14 am ]
Post subject:  Secret Bob's Basket

You need to run one instance per platform if using SBB as a basket trader. The bot is complicated enough without adding extra layers of lunacy.

:xm:
Author:  SteveHopwood [ Sun Oct 26, 2014 9:39 am ]
Post subject:  Secret Bob's Basket

I forgot to add that I will include adding the magic number to the GV in time for the markets opening later on so people can run multiple baskets if they want to.

:xm:
Author:  SteveHopwood [ Sun Oct 26, 2014 10:24 am ]
Post subject:  Secret Bob's Basket

I have added the magic number to the global variable. Also added the usual minimum margin checks.

That is it for now. I am sick of coding and will be teaching later, so it is safe to assume the version in post 1 is the version that will go onto our demos later on.

:xm:
Author:  Radar [ Sun Oct 26, 2014 10:51 am ]
Post subject:  Secret Bob's Basket

Hey Steve,

Thanks for the MN on the GV's :)

As for the extra layers of lunacy... Join us! Joooiiin uuuuussss! ;)

Take care,

&

Have fun!

Radar =8^)
Author:  SteveHopwood [ Sun Oct 26, 2014 11:34 am ]
Post subject:  Secret Bob's Basket

I forgot to add the magic to the date global. Insert
GvNameDate="Date/time " + IntegerToString(MagicNumber);

at line 317.

:xm:
Author:  SteveHopwood [ Sun Oct 26, 2014 11:46 am ]
Post subject:  Secret Bob's Basket

renexxxx has just pointed out the need for another mod, in a pm a few minutes ago.

Line 3002 needs modifying from:
BasketCashUpl = AccountProfit();

to

BasketCashUpl = BasketCashUpl;

Cheers Rene

:xm:
Author:  renexxxx [ Sun Oct 26, 2014 12:19 pm ]
Post subject:  Secret Bob's Basket

Not sure if I am following this ... Shouldn't it be something like:

Code: Select all

BasketCashUpl = basketProfit( MagicNumber );
with:

Code: Select all

//+------------------------------------------------------------------+
//| basketProfit()                                                   |
//|    -- returns total profit (or loss) for basket                  |
//+------------------------------------------------------------------+
double basketProfit( int magic = -1 ) {

   double myProfit = 0.0;
   int allOrders = OrdersTotal();
   
   for (int i = 0; i < allOrders; i++) {
      if (OrderSelect(i, SELECT_BY_POS)) {
         if ( ( (magic == -1) || ( OrderMagicNumber() == magic ) ) && ( (OrderType() == OP_BUY) || (OrderType() == OP_SELL) ) ) {
            myProfit += OrderProfit() + OrderCommission() + OrderSwap();
         }
      }
   } // for
   return(myProfit);
}
?
All times are UTC Page 2 of 40