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

Secret Bob's Basket
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3896
Page 24 of 40
Author:  SteveHopwood [ Tue Nov 11, 2014 9:20 pm ]
Post subject:  Secret Bob's Basket

In light of KapguHaJI's post above, I am briefly locking this thread so I do not forget its importance in the morning.

It is heading for late at night here in the UK and I have imbibed a bit - and we all know what that does to my memory.

There us much more to converting a single trade EA to a multi trader than you guys might imagine, and I have clearly missed a step or two/three. I will sort this out in the morning.

KapguHaJI, I am most grateful. Sorting this out is my responsibility, but should you care to pm me a fixed version of the above then I would be even more grateful. Whatever, all shf members applaud you. :clap:

:xm:
Author:  SteveHopwood [ Wed Nov 12, 2014 9:12 am ]
Post subject:  Secret Bob's Basket

Thanks for your patience folks. We are back up and running as normal.

:xm:
Author:  SteveHopwood [ Wed Nov 12, 2014 10:00 am ]
Post subject:  Secret Bob's Basket

Thanks to KapguHaJI, :clap: V 1j is in post 1 and the IndiIntervalReadSeconds delay should work properly now.

The problem arose from the conversion of Simple Bob the single trader to SBB the multi-pair trader. Coders have seen my stuff so many times now that they know where to look for everything. Calls to indicators are all contained within a function called ReadIndicatorValues().

The delay works fine in a single trader because the function is only called once a tick. SBB calls ReadIndicatorValues() for every pair traded, so the delay was kicking in after the first pair and so the rest were not tested. That explains why those of us using the delay were not getting trades even though there was a signal. I would have worked this out eventually, but eventually might have been a while away and so KapguHaJI has saved us some pain. :clap: :clap: :clap:

For those of you who do not understand what the delay is all about, here is the explanation I send to people grumbling that the EA they paid me to code for their trading system involving 19 crap custom abortions slows their machine to a crawl:
The biggest problem with Crap Custom Abortions (known by the uninitiated as 'custom indicators') is one that lies at the heart of CrapTx. When an EA consults an indicator, the platform loads it into memory, then unloads it again once it has responded to the EA call. This takes time.

An indi has to do a lot of work up front when loaded onto a chart. Most of them are based on some sort of moving average, and the calculation has to be done over every bar on the chart. On subsequent ticks, the indi only has to update its calculation by updating the last x bars actually involved – the reason that, say, a moving average indi does not make your cpu emit blue smoke.

Custom indis typically consist of a number of calls to the regular indicators that ship with Empty4, and manipulate the information thus gleaned according to what the coder requires. An indicator such as AllAverages will make a number of calls to standard indicators. At each tick; each standard indi called by the custom indi is loaded, does all the up-front stuff, used, then unloaded. This takes a long time. Ridiculous, but that is how it works, and is the reason that custom indis such as AA and VQ slow your machine.

And then, we put the EA/Crap Custom Abortion on multiple charts.................................
Tommaso's indi is light-years ahead in standard of the kind of rubbish that most coders produce but it does rely on multiple calls to the usual indicators. We have it called to examine over 20 pairs twice a second - on several testing platforms. Once we have a basket open, we need the calculations done as often as possible, but do not need the indicators reading anything like as often. So, if your cpu appears to be struggling, then simply introduce a delay using IndiIntervalReadSeconds.

:xm:
Author:  mobthehop [ Wed Nov 12, 2014 10:54 am ]
Post subject:  Secret Bob's Basket

Steve, if you allow me one question that I am puzzling over for days now and cant resolve by myself...

Why is "factor" not also in an array or called every time it is needed via PFactor(symbol)?

It is pair defendant and, though it is a fixed value per pair, functionally I do not see a difference to the ATR value of any individual pair (which is kept in an array)

Referring to the latest version:

line 1275 for slippage calculation you indeed call PFactor(symbol), which I believe is the correct way

but everywhere else it is the "simple" factor variable (eg line 748, 784, etc etc)

As so often I probably don't get it - feel free to simply delete this post if I am wrong... but am still curious....

Cheers / Mop
Author:  SteveHopwood [ Wed Nov 12, 2014 11:11 am ]
Post subject:  Secret Bob's Basket

mobthehop » Wed Nov 12, 2014 10:54 am wrote:Steve, if you allow me one question that I am puzzling over for days now and cant resolve by myself...

Why is "factor" not also in an array or called every time it is needed via PFactor(symbol)?

It is pair defendant and, though it is a fixed value per pair, functionally I do not see a difference to the ATR value of any individual pair (which is kept in an array)

Referring to the latest version:

line 1275 for slippage calculation you indeed call PFactor(symbol), which I believe is the correct way

but everywhere else it is the "simple" factor variable (eg line 748, 784, etc etc)

As so often I probably don't get it - feel free to simply delete this post if I am wrong... but am still curious....

Cheers / Mop
Every time the bot iterates through either the trading pairs or open trades, it calls this function before doing anything else:

Code: Select all

void GetBasics(string symbol)
{
   //Sets up bid, ask, digits, factor for the passed pair
   bid = MarketInfo(symbol, MODE_BID);
   ask = MarketInfo(symbol, MODE_ASK);
   digits = MarketInfo(symbol, MODE_DIGITS);
   factor = PFactor(symbol);
   spread = (ask - bid) * factor;
   LongSwap = MarketInfo(symbol, MODE_SWAPLONG);
   ShortSwap = MarketInfo(symbol, MODE_SWAPSHORT);

     
}//End void GetBasics(string symbol)
The variables it sets are available throughout the program.

Line 1275 is not my code.

:xm:
Author:  Baluda [ Wed Nov 12, 2014 11:30 am ]
Post subject:  Secret Bob's Basket

[b]mobthehop[/b] wrote:Why is "factor" not also in an array or called every time it is needed via PFactor(symbol)?
And why is this:

Code: Select all

   ArrayResize(TradePair, NoOfPairs);
   ArrayResize(AtrVal, NoOfPairs);
   ArrayResize(MaTrend, NoOfPairs);
   ArrayResize(MaVal, NoOfPairs);
   ArrayResize(SecretTradeStatus, NoOfPairs);
   ArrayResize(HistoricStatus, NoOfPairs);
   ArrayResize(PairTrades, NoOfPairs);
   ArrayResize(PairCashUPL, NoOfPairs);
   ArrayResize(PairPipsUPL, NoOfPairs);
   ArrayResize(PairTicketNo, NoOfPairs);
   ArrayResize(PairAverageSpread, NoOfPairs);
   ArrayResize(PairSpreadTotal, NoOfPairs);
   ArrayResize(PairCountedTicks, NoOfPairs);
   ArrayResize(PairOldBid, NoOfPairs);
   ArrayResize(PairRecoveryStatus, NoOfPairs);
   ArrayResize(PairMostRecentTime, NoOfPairs);
not part of (an array of) a struct like this:

Code: Select all

struct         structSymbol
{
   string       Name;
   double      PointValue;
   double      BidValue;
   double      AskValue;
   double      ATR;
   ENUM_TREND      MATrend;
   double      MAValue;
   double      SecretStatus;
   int            TradeCount;
   double       CashUPL;
   etc..
   etc...
}; 

structSymbol   Symbols[];
And use it like this:

Code: Select all

Symbols[0].Name = "EURUSD";
Symbols[0].PointValue = PFactor( "EURUSD" );
Symbols[0].BidValue = MarketInfo( "EURUSD", MODE_BID );
etc..
And why do we need a struct when a class is even better?

Baby steps, Mob, baby steps.

Paul
Author:  mobthehop [ Wed Nov 12, 2014 12:01 pm ]
Post subject:  Secret Bob's Basket

Guys, thanks a lot for your replies:

Baluda - I guess your comments were more directed at Steve as they are way over my head....

Steve - I apologize for the typo - I was referring to

line 1274 double slippage=MaxSlippagePips*MathPow(10,digits)/PFactor(symbol);

Will stop here.... Guess I was barking up the wrong tree...
Author:  SteveHopwood [ Wed Nov 12, 2014 12:30 pm ]
Post subject:  Secret Bob's Basket

Hehe. Now you see why I would never even dream of calling myself a 'Proper Coder'. :lol: :lol: :lol:

:xm:
Author:  forextraderaz [ Wed Nov 12, 2014 5:01 pm ]
Post subject:  Secret Bob's Basket

What is everyone's favorite time frame so far to run this on? So far it seems for me the m30 but hour chart seems good also.
Author:  gringoh [ Wed Nov 12, 2014 5:16 pm ]
Post subject:  Secret Bob's Basket

forextraderaz » 12 Nov 2014, 18:01 wrote:What is everyone's favorite time frame so far to run this on? So far it seems for me the m30 but hour chart seems good also.

Agreed on M30 for maximum pips profit, but DD is high as well. I am more comfortable with H4, less pips but less DD also. H1 is not doing good for the moment.

It is still too early to conclude.

Cheers,

:smile:
All times are UTC Page 24 of 40