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

Multi 10:4 Trader EA
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1619
Page 11 of 160
Author:  McNish [ Fri Mar 15, 2013 12:24 pm ]
Post subject:  Re: Multi 10:4 Trader EA

SteveHopwood wrote: :D
Just goes to show even the Smartest Brains can be taken for a ride sometimes. 8-)

@ Andy : While allisonmagic (aka GH) suggested to keep moving the pendings as price keeps moving further away in the opp direction, one need to keep couple of things in mind. 1) The RSI / Sto are still valid (above / below cut off) in the current bar. 2) The last H4 candle's high / low (as the case may be) is clear of the last pivot / SR's / mid SR's where the pendings are going to be placed (presuming that we are working / calculating from this TF). See pic for clarity.
usdcadh4.png
3) This is more of a request. In the YAD V4, there was filter check to see if the H / L of the day was clear of the 240 ma. Can we have this in the current DB / EA please?

Will post more as EA progresses.

In a weeks time or two, I believe we'll have a fully functional EA here. Courtesy of 'The Shrugged Atlas'.

Regards,
Author:  MrLong [ Fri Mar 15, 2013 12:31 pm ]
Post subject:  Re: Multi 10:4 Trader EA

slipshod wrote:Here's the changes I made on my end, hope they're useful! If there's anything incorrect or that could have been done better please let me know :)

firstly there's changes to function calls in start()...

Code: Select all

stop = CalculateStopLoss(CurrentPair, OP_BUY, price);
take = CalculateTakeProfit(CurrentPair, OP_BUY, price);
Do the same for sells as well, with OP_SELL of course. Now for the functions themselves:-

Code: Select all

double CalculateStopLoss(string symbol, int type, double entry) {
        // askPrice and bidPrice no longer needed as we're using the real entry value
	// double askPrice = MarketInfo(symbol, MODE_ASK);
	// double bidPrice = MarketInfo(symbol, MODE_BID);
	double stop, price = entry;

	RefreshRates();

	if (type == OP_BUY) {
		//price = askPrice;
		if (!CloseEnough(stopLoss, 0)) {
			stop = price - (stopLoss / factor);
		}

		
		if (UseMovingAverage)
			stop = MaVal;
	} 

	if (type == OP_SELL) {
		//price = bidPrice;
		if (!CloseEnough(stopLoss, 0)) {
			stop = price + (stopLoss / factor);
		}

		
		if (UseMovingAverage)
			stop = MaVal;
	} 

	return(stop);
} 

double CalculateTakeProfit(string symbol, int type, double entry) {
	// again, no need for askPrice and bidPrice anymore
	//double askPrice = MarketInfo(symbol, MODE_ASK);
	//double bidPrice = MarketInfo(symbol, MODE_BID);
	double take, price = entry;

	RefreshRates();

	if (type == OP_BUY) {
                // make sure that take is incorrect to start with, that way we can be sure when
                // we get a valid take value...
		take = entry - 20 * Point;

		if (!CloseEnough(takeProfit, 0)) {
			take = price + (takeProfit / factor);
		}
		
                // note that below I set take to higher resistance levels even if the Use flag for them
                // hasn't been set, but only if the desired resistance level is below our entry...
		if (UseMidSR1)
			take = MR1;
		if (UseSR1 || take < entry)
			take = R1;
		if (UseMidSR2 || take < entry)
			take = MR2;
		if (UseSR2 || take < entry)
			take = R2;
		if (take < entry)
                {
                        // still can't get a valid take value using the pivots, so I've defaulted
                        // to 2 * ATR as a placeholder to ensure we have something to use.
                        take = entry + iATR(symbol, PERIOD_H4, 20, 0)*2;
                }
	} 

	if (type == OP_SELL) {
		take = entry + 20 * Point;

		if (!CloseEnough(takeProfit, 0)) {
			take = price - (takeProfit / factor);
		}
		
		if (UseMidSR1)
			take = MS1;
		if (UseSR1 || take > entry)
			take = S1;
		if (UseMidSR2 || take > entry)
			take = MS2;
		if (UseSR2 || take > entry)
			take = S2;
		if (take > entry)
		   take = entry - iATR(symbol, PERIOD_H4, 20, 0)*2;
	}

	return(take);
}
Btw another change I've made is to split the lotsize in half and enter twice, once with a TP and once without (I'll trail the market with the second order). I don't know if this is valid under 10.4 rules or would improve or harm its profitability, but its something I wanted to try. Its a simple change, can post it if anyone wants ... if it does prove useful perhaps its something Andy could add an option for in a future version?
Hi Slipshod,

Thanks for you code, looks good.

Job for the boyz this debuugging, I can see why Steve climbs in that hot bath :lol: :lol:

Andy
Author:  McNish [ Fri Mar 15, 2013 12:39 pm ]
Post subject:  Re: Multi 10:4 Trader EA

Know What ! There's hardly anyone at the DBM threads that I'm so keenly working on. You've stolen the show here at SHF Andy. :x :cry:

I vow to get even. :evil:

With Warm Regards, MAX.
Author:  MrLong [ Fri Mar 15, 2013 12:46 pm ]
Post subject:  Re: Multi 10:4 Trader EA

websie wrote:I know absolutely nothing about coding but when looking at this EA this bit here about the time of deleting the pendings you have set for 16.00 which is 4pm, was it really meant to be 6pm, in which case it's 18.
Is that correct to change the 16 to 18?
extern int PendingTradeDeletionHour = 16; //6.00 pm
if you would like to delete the orders at 18 thats ok.
Author:  MrLong [ Fri Mar 15, 2013 1:36 pm ]
Post subject:  Re: Multi 10:4 Trader EA

McNish wrote:
SteveHopwood wrote: :D
Just goes to show even the Smartest Brains can be taken for a ride sometimes. 8-)

@ Andy : While allisonmagic (aka GH) suggested to keep moving the pendings as price keeps moving further away in the opp direction, one need to keep couple of things in mind. 1) The RSI / Sto are still valid (above / below cut off) in the current bar. 2) The last H4 candle's high / low (as the case may be) is clear of the last pivot / SR's / mid SR's where the pendings are going to be placed (presuming that we are working / calculating from this TF). See pic for clarity.
usdcadh4.png
3) This is more of a request. In the YAD V4, there was filter check to see if the H / L of the day was clear of the 240 ma. Can we have this in the current DB / EA please?

Will post more as EA progresses.

In a weeks time or two, I believe we'll have a fully functional EA here. Courtesy of 'The Shrugged Atlas'.

Regards,
OK, thanks.
Author:  och [ Fri Mar 15, 2013 1:40 pm ]
Post subject:  Re: Multi 10:4 Trader EA

slipshod wrote:I added a few debugging lines to see what trades its trying to take, and am seeing it trying to open a sell on EURAUD at the price -0.0004, which is predictably failing.

It also tried a Buy Stop on AUDCAD at 1.0604 with a TP at 1.0599 (less than the entry price), and similar TP errors on EURUSD and GBPAUD.

(I've got Stealth turned off, as I can't run a computer 24 hours a day).
Same issue with AUDNZD. I made a little debugging and this is coming from GetNextSupport and/or GetNextResistance as it never fit the conditions and so Pivot remain to 0. Then Price is calculated using Pivot - (Buffer/factor), so negative... In that case Last resistance is below Price ,so bid can never be between two last resistances...

I am quite new to that system, so as I do not fully undersand rules, I have no clue what to change...
Author:  Baluda [ Fri Mar 15, 2013 2:03 pm ]
Post subject:  Re: Multi 10:4 Trader EA

Here is something strange. I do not know if this has been reported yet.

Journal tab:
AUDNZD Journal.png
Experts tab:
AUDNZD Experts.png
A pending AUDNZD order was opened, triggered and closed because of a 'reversal'. All within 20 seconds.

FWIW times are local, GMT+2. Subtract one hour for Cowboy IBFX server times.

Paul
Author:  Pippa [ Fri Mar 15, 2013 2:13 pm ]
Post subject:  Re: Multi 10:4 Trader EA

Hello Everyone,

Following this thread with great interest.

Due to my lack of any Coding skills am avidly watching, learning and very impressed!

Thank you Mr. Long!

Regards,

Pippa
Author:  aworex [ Fri Mar 15, 2013 2:27 pm ]
Post subject:  Re: Multi 10:4 Trader EA

:o
Baluda wrote:Here is something strange. I do not know if this has been reported yet.

Journal tab:
AUDNZD Journal.png
Experts tab:
AUDNZD Experts.png
A pending AUDNZD order was opened, triggered and closed because of a 'reversal'. All within 20 seconds.

FWIW times are local, GMT+2. Subtract one hour for Cowboy IBFX server times.

Paul

I experienced the same error with the AUDNZD with it opening and closing the trade several times, with my FXCM broker here in the UK :cry:
Author:  Kruspe [ Fri Mar 15, 2013 2:32 pm ]
Post subject:  Re: Multi 10:4 Trader EA

Same experience here with audnzd (Cowboy IBFX)
All times are UTC Page 11 of 160