Macd Stochastic Fractal MA5/25 Daily Marylin

Locked
phil_trade

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by phil_trade »

Patience is the key in forex

after 3 weeks up/down...and some bigs news :
You do not have the required permissions to view the files attached to this post.
User avatar
niepce
Trader
Posts: 152
Joined: Wed Jul 04, 2012 11:00 pm
Location: Grenoble, France

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by niepce »

aSushiRoll wrote:
Actually Philippe, first thanks for your wonderful EA. I've read the first few pages of this thread and skimmed trough the last few. This is a link to my Merilynn EA:
https://www.myfxbook.com/portfolio/1-mt ... mon/606234
Up +56% since June 12th DD 11%.


Sushi

Hi Sushi ! I tried to display your myfxbook's, but im getting a "private" error message, can you make it public ?

EDIT, my bad, here's http://www.myfxbook.com/members/Mautje/ ... mon/606234

:)
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by Radar »

Looking good, Phil :)

Regarding the OrderModify errors... I haven't been able to pinpoint what causes them, but by having Marilyn tell me what order number she's trying to modify, I have seen that she eventually succeeds.

It's a pita, but it *is* working.

Have fun!

Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by milanese »

Phil thanks for your update, yes patience is the key in forex trading ;)

wish you all a nice weekend :)

Cheers,
Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by Radar »

Greets peeps :)

Found the cause of the OrderModify errors...

The multiple errors were caused by nested loops... On the first iteration of the outer loop + first iteration of the inner loop, OrderModify is successful, and control is returned to the outer loop... On all successive iterations of the outer and inner loops, we get Error1, (stop values haven't changed). Removing the outer loop fixed the multiple attempts.

To get rid of the multiple errors, change this...

Code: Select all

void ModifyOrder(int ticket, double stop, double take)
{
	//Modifies an order already sent if the crim is ECN.

	if (stop == 0 && take == 0) return; //nothing to do

	if (!OrderSelect(ticket, SELECT_BY_TICKET) ) return;//Trade does not exist, so no mod needed

	//RetryCount is declared as 10 in the Trading variables section at the top of this file   
	for (int cc = 0; cc < RetryCount; cc++)
	{
		for (int d = 0; (d < RetryCount) && IsTradeContextBusy(); d++) Sleep(100);
		if (take > 0 && stop > 0)
		{
			while(IsTradeContextBusy()) Sleep(100);
			if (OrderModify(ticket, OrderOpenPrice(), stop, take, OrderExpiration(), CLR_NONE)) 
			{
			    Alert("Modify Order Succeeded !");
			    Print("Modify Order Succeeded !");
			    return;             
			}
		}//if (take > 0 && stop > 0)

		if (take != 0 && stop == 0)
		{
			while(IsTradeContextBusy()) Sleep(100);
			if (OrderModify(ticket, OrderOpenPrice(), OrderStopLoss(), take, OrderExpiration(), CLR_NONE)) 
			{
			    Alert("Modify Order Succeeded !");
			    Print("Modify Order Succeeded !");
			    return;   
			}
		}//if (take == 0 && stop != 0)

		if (take == 0 && stop != 0)
		{
			while(IsTradeContextBusy()) Sleep(100);
			if (OrderModify(ticket, OrderOpenPrice(), stop, OrderTakeProfit(), OrderExpiration(), CLR_NONE)) 
			{
			    Alert("Modify Order Succeeded !");
			    Print("Modify Order Succeeded !");
			    return;   			
			}
		}//if (take == 0 && stop != 0)
	}//for (int cc = 0; cc < RetryCount; cc++)

	//Got this far, so the order modify failed
	int err=GetLastError();
	Print(Symbol(), " SL/TP  order modify failed with error(",err,"): ",ErrorDescription(err));               
	Alert(Symbol(), " SL/TP  order modify failed with error(",err,"): ",ErrorDescription(err));               

}//void ModifyOrder(int ticket, double tp, double sl)
...to this...

Code: Select all

void ModifyOrder(int ticket, double stop, double take)
{
	//Modifies an order already sent if the crim is ECN.

	if (stop == 0 && take == 0) return; //nothing to do

	if (!OrderSelect(ticket, SELECT_BY_TICKET) ) return;//Trade does not exist, so no mod needed

	//RetryCount is declared as 10 in the Trading variables section at the top of this file   
		for (int d = 0; (d < RetryCount) && IsTradeContextBusy(); d++) Sleep(100);
		{
		    if (take > 0 && stop > 0)
		    {
			      while(IsTradeContextBusy()) Sleep(100);
			      if (OrderModify(ticket, OrderOpenPrice(), stop, take, OrderExpiration(), CLR_NONE)) 
			      {
			         Alert("Modify Order Succeeded !");
			         Print("Modify Order Succeeded !");
			         return;
			      }
		    }//if (take > 0 && stop > 0)

		    if (take != 0 && stop == 0)
		    {
			      while(IsTradeContextBusy()) Sleep(100);
			      if (OrderModify(ticket, OrderOpenPrice(), OrderStopLoss(), take, OrderExpiration(), CLR_NONE)) 
			      {
			         Alert("Modify Order Succeeded !");
			         Print("Modify Order Succeeded !");
			         return;
			      }
		    }//if (take == 0 && stop != 0)

		    if (take == 0 && stop != 0)
		    {
			      while(IsTradeContextBusy()) Sleep(100);
			      if (OrderModify(ticket, OrderOpenPrice(), stop, OrderTakeProfit(), OrderExpiration(), CLR_NONE)) 
			      {
			         Alert("Modify Order Succeeded !");
			         Print("Modify Order Succeeded !");
			         return;
			      }
		    }//if (take == 0 && stop != 0)
	     }//for (int d = 0; (d < RetryCount) && IsTradeContextBusy(); d++)

	//Got this far, so the order modify failed
	int err=GetLastError();
	if (err > 0)
	Print(OrderTicket()," ",Symbol(), " SL/TP  order modify failed with error(",err,"): ",ErrorDescription(err));               
	Alert(OrderTicket()," ",Symbol(), " SL/TP  order modify failed with error(",err,"): ",ErrorDescription(err));               

}//void ModifyOrder(int ticket, double tp, double sl)

Retracements/ranging was the cause of the remaining errors, as StochOBOSToMoveSL would be reached, (along with DeltaPipsMoveSLOnStoch), and out SL is moved to BE (or BEP, if enabled)... If either value dropped below the required values for longs, (above for shorts), then returned, Marilyn would attempt to move the SL to BE or BEP again.

The fix...

Change form this...

Code: Select all

if((NewSL-Bid)>(DeltaPipsMoveSLOnStoch*Point))
{
	   NewSL=ReturnLowOpenPrice(strSymbol,MagicNumber,OrderTicket());
	   if(         ((NewSL<OrderStopLoss())||(OrderStopLoss()<(1*Point))) &&   (NewSL!=9999) && (NewSL > Bid + (10*multiplier*Point))   )
       {
         //OrderModify(OrderTicket(),OrderOpenPrice(),NewSL,OrderTakeProfit(),0,CLR_NONE);
	Alert("MoveSLOnStoch :Attempting to move SL of ",strSymbol," to ",NewSL);
	Print("MoveSLOnStoch :Attempting to move SL of ",strSymbol," to ",NewSL);
	ModifyOrder(OrderTicket(),NewSL,0);
	}
}
...to this...

Code: Select all

if((NewSL-Ask)>(DeltaPipsMoveSLOnStoch*Point))
{
   if ((NormalizeDouble(OrderStopLoss(), Digits) != NormalizeDouble(NewSL, Digits))) // <== Added This
   if(         ((NewSL<OrderStopLoss())||(OrderStopLoss()<(1*Point))) &&   (NewSL!=9999) && (NewSL > Ask + (10*multiplier*Point))   )
  {
        //OrderModify(OrderTicket(),OrderOpenPrice(),NewSL,OrderTakeProfit(),0,CLR_NONE);
        Alert("MoveSLOnStoch :Attempting to move SL of ",OrderTicket()," ",strSymbol," from ",OrderStopLoss()," to ",NewSL);
        Print("MoveSLOnStoch :Attempting to move SL of ",OrderTicket()," ",strSymbol," from ",OrderStopLoss()," to ",NewSL);
        ModifyOrder(OrderTicket(),NewSL,0);
  }
}
No more OrderModify errors :)

Now I've off to find out why Marilyn is adding trades 50 pips apart when I've asked her to add them 16 pips apart...

Have fun!

Radar =8^)
Last edited by Radar on Sat Aug 03, 2013 9:01 am, edited 1 time in total.
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
AGT
Trader
Posts: 889
Joined: Thu Nov 17, 2011 7:20 pm
Location: Germany

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by AGT »

Hi Radar ! Bcz a lot of members here aren't coders: could you plz add the fixed version here in mq4 form ?
Thanks a lot ! :)
phil_trade

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by phil_trade »

AGT wrote:Hi Radar ! Bcz a lot of members here aren't coders: could you plz add the fixed version here in mq4 form ?
Thanks a lot ! :)
Hi all

Could job Radar !

but, It will be safer that Niepce, who know well the strategy, look before at this modification (cut a loop), to ensure it's always good for Marilyn.

Philippe
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by Radar »

Hey AGT,
AGT wrote:Hi Radar ! Bcz a lot of members here aren't coders: could you plz add the fixed version here in mq4 form ?
Thanks a lot ! :)
I'm not really a coder myself ;) I just hunt and peck, copy/paste/edit ;)

Any changes I make I'll post in here so that proper coders can ensure that I haven't broken any trade/management logic ;)

Have fun!

Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by Radar »

Hey Phil,

It's brain-picking time... ;)

For scale-in trades... Do you wait for another signal to scale-in, or do you just use price-action?

I'm thinking that if you have DeltaPipsInterMacdToClose = DistanceInterTrade = (DeltaPipsMoveSLOnStoch minus a few pips), you can add trades every DistanceInterTrade pips, regardless of the current Stoch, MACD, etc... I think it would only work if you were using RelativeStoch, and had UnprotectedTrades set to 1, though.

I'm going to attempt to break the code down into smaller modules, so that it will be easier for me to add bits to test without breaking the overall logic.

Have fun!

Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Re: Macd Stochastic Fractal MA5/25 Daily Marylin

Post by milanese »

Hi Radar,

finally you got it :) nice work..

wish you a nice weekend :)

Cheers,

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Locked

Return to “Automated trading systems”