Phoenix - Development+Suggestions - MQ4 in Post#1 - page 23

 

Here are some alternative TrailingStop/Breakeven code.

ExitTS=1, this is a tiered TS that has Breakeven as 1st tier.

ExitTS=2, this is a 3 candle approach to TS. GapTS sets pips in profit to trigger TS. The attached 3-Candles Graphic demonstrates concept. This is the EA code to set the 3-Candles TS value.

double LongTS, ShortTS;

int c, n, p;

c=1; p=0;

for(n=0;n<=6;n++)

{

if(High[c]Low[c+1]) {n--;}

c++;

p++;

if(n==3) break;

}

ShortTS=NormalizeDouble(High,Digits);

LongTS=NormalizeDouble(Low,Digits);[/CODE]

ExitTS=3, this is TS code that is used presently in many EAs.

Below is the base TS code witht the 3 ExitTS options. I've found that different pairs prefer different TS method to maximize profits. Having these 3 TS options in current EAs that I have coded has made a big improvement in profits.

I have an OrderModify call in each in method. I did this because I like to copy and paste complete code sequences. It would not be difficult at all to revise code to have only one OrderModify call for all Buy TS options and one for Sell.

[CODE]

extern int ExitTS = 1; // ExitTS 1= Tiered Level TS, 2= 3 Candles TS, 3= Normal TS

extern int GapTS = 20; // Pips in profit to trigger TS in ExitTS=2

int total = OrdersTotal();

int ts = 0;

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()==_MagicNumber)

{

if(ExitTS==1 && ts!=OrderStopLoss())

{

if(OrderClosePrice()-OrderOpenPrice() > 15*Point

&& OrderClosePrice()-OrderOpenPrice()< 20*Point) { ts=(OrderOpenPrice()); }

if(OrderClosePrice()-OrderOpenPrice() > 20*Point

&& OrderClosePrice()-OrderOpenPrice()< 30*Point) { ts=(OrderOpenPrice()+10*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 30*Point

&& OrderClosePrice()-OrderOpenPrice()< 35*Point) { ts=(OrderOpenPrice()+15*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 35*Point

&& OrderClosePrice()-OrderOpenPrice()< 40*Point) { ts=(OrderOpenPrice()+20*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 40*Point

&& OrderClosePrice()-OrderOpenPrice()< 45*Point) { ts=(OrderOpenPrice()+25*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 45*Point) { ts=Bid-(5*Point); }

if(ts==0) break;

if(ts>OrderStopLoss())

{

OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,GreenYellow);

}

}

if(ExitTS==2 && OrderClosePrice()-OrderOpenPrice() > GapTS*Point)

{

OrderModify(OrderTicket(),OrderOpenPrice(),LongTS,OrderTakeProfit(),0,GreenYellow);

}

if(ExitTS==3 && TrailingStop > 0)

{

if((Bid-OrderOpenPrice()) > (Point*TrailingStop))

{

if((OrderStopLoss()) < (Bid-Point*TrailingStop))

{

OrderModify( OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point, OrderTakeProfit(), 0,GreenYellow);

}

}

}

}

ts=0;

if(OrderType()==OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==_MagicNumber)

{

if(ExitTS==1 && ts!=OrderStopLoss())

{

if(OrderOpenPrice()-OrderClosePrice() > 15*Point

&& OrderOpenPrice()-OrderClosePrice() < 20*Point) { ts=(OrderOpenPrice()); }

if(OrderOpenPrice()-OrderClosePrice() > 20*Point

&& OrderOpenPrice()-OrderClosePrice() < 30*Point) { ts=(OrderOpenPrice()-10*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 30*Point

&& OrderOpenPrice()-OrderClosePrice() < 35*Point) { ts=(OrderOpenPrice()-15*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 35*Point

&& OrderOpenPrice()-OrderClosePrice() < 40*Point) { ts=(OrderOpenPrice()-20*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 40*Point

&& OrderOpenPrice()-OrderClosePrice() < 45*Point) { ts=(OrderOpenPrice()-25*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 45*Point) { ts=Ask+(5*Point); }

if(ts==0) break;

if(ts<OrderStopLoss())

{

OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,Red);

}

}

if(ExitTS==2 && OrderOpenPrice()-OrderClosePrice() > GapTS*Point)

{

OrderModify(OrderTicket(),OrderOpenPrice(),ShortTS,OrderTakeProfit(),0,Red);

}

if(ExitTS==3 && TrailingStop > 0)

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop)

{

OrderModify( OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point, OrderTakeProfit(), 0, GreenYellow );

}

}

}

}

}

Also, if felt useful, I have coded a SpikeTrader EA. The SpikeTrader code tracks bar open to high and open to low and triggers Pending Orders call on preset span value, I believe this code could be use to indentify trends. EA utiltizes BuyStop, SellStop Orders and OCO techniques. The code has identified Spikes correctly about 70-80%.

I hope this may be useful for future Phoenix developement.

Wackena

Files:
 

Wackena,

This looks promising very nice screen shot!

Berdj

Wackena:
Here are some alternative TrailingStop/Breakeven code.

ExitTS=1, this is a tiered TS that has Breakeven as 1st tier.

ExitTS=2, this is a 3 candle approach to TS. GapTS sets pips in profit to trigger TS. The attached 3-Candles Graphic demonstrates concept. This is the EA code to set the 3-Candles TS value.

double LongTS, ShortTS;

int c, n, p;

c=1; p=0;

for(n=0;n<=6;n++)

{

if(High[c]Low[c+1]) {n--;}

c++;

p++;

if(n==3) break;

}

ShortTS=NormalizeDouble(High,Digits);

LongTS=NormalizeDouble(Low,Digits);[/CODE]

ExitTS=3, this is TS code that is used presently in many EAs.

Below is the base TS code witht the 3 ExitTS options. I've found that different pairs prefer different TS method to maximize profits. Having these 3 TS options in current EAs that I have coded has made a big improvement in profits.

I have an OrderModify call in each in method. I did this because I like to copy and paste complete code sequences. It would not be difficult at all to revise code to have only one OrderModify call for all Buy TS options and one for Sell.

[CODE]

extern int ExitTS = 1; // ExitTS 1= Tiered Level TS, 2= 3 Candles TS, 3= Normal TS

extern int GapTS = 20; // Pips in profit to trigger TS in ExitTS=2

int total = OrdersTotal();

int ts = 0;

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()==_MagicNumber)

{

if(ExitTS==1 && ts!=OrderStopLoss())

{

if(OrderClosePrice()-OrderOpenPrice() > 15*Point

&& OrderClosePrice()-OrderOpenPrice()< 20*Point) { ts=(OrderOpenPrice()); }

if(OrderClosePrice()-OrderOpenPrice() > 20*Point

&& OrderClosePrice()-OrderOpenPrice()< 30*Point) { ts=(OrderOpenPrice()+10*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 30*Point

&& OrderClosePrice()-OrderOpenPrice()< 35*Point) { ts=(OrderOpenPrice()+15*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 35*Point

&& OrderClosePrice()-OrderOpenPrice()< 40*Point) { ts=(OrderOpenPrice()+20*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 40*Point

&& OrderClosePrice()-OrderOpenPrice()< 45*Point) { ts=(OrderOpenPrice()+25*Point); }

if(OrderClosePrice()-OrderOpenPrice() > 45*Point) { ts=Bid-(5*Point); }

if(ts==0) break;

if(ts>OrderStopLoss())

{

OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,GreenYellow);

}

}

if(ExitTS==2 && OrderClosePrice()-OrderOpenPrice() > GapTS*Point)

{

OrderModify(OrderTicket(),OrderOpenPrice(),LongTS,OrderTakeProfit(),0,GreenYellow);

}

if(ExitTS==3 && TrailingStop > 0)

{

if((Bid-OrderOpenPrice()) > (Point*TrailingStop))

{

if((OrderStopLoss()) < (Bid-Point*TrailingStop))

{

OrderModify( OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point, OrderTakeProfit(), 0,GreenYellow);

}

}

}

}

ts=0;

if(OrderType()==OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==_MagicNumber)

{

if(ExitTS==1 && ts!=OrderStopLoss())

{

if(OrderOpenPrice()-OrderClosePrice() > 15*Point

&& OrderOpenPrice()-OrderClosePrice() < 20*Point) { ts=(OrderOpenPrice()); }

if(OrderOpenPrice()-OrderClosePrice() > 20*Point

&& OrderOpenPrice()-OrderClosePrice() < 30*Point) { ts=(OrderOpenPrice()-10*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 30*Point

&& OrderOpenPrice()-OrderClosePrice() < 35*Point) { ts=(OrderOpenPrice()-15*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 35*Point

&& OrderOpenPrice()-OrderClosePrice() < 40*Point) { ts=(OrderOpenPrice()-20*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 40*Point

&& OrderOpenPrice()-OrderClosePrice() < 45*Point) { ts=(OrderOpenPrice()-25*Point); }

if(OrderOpenPrice()-OrderClosePrice() > 45*Point) { ts=Ask+(5*Point); }

if(ts==0) break;

if(ts<OrderStopLoss())

{

OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,Red);

}

}

if(ExitTS==2 && OrderOpenPrice()-OrderClosePrice() > GapTS*Point)

{

OrderModify(OrderTicket(),OrderOpenPrice(),ShortTS,OrderTakeProfit(),0,Red);

}

if(ExitTS==3 && TrailingStop > 0)

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop)

{

OrderModify( OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point, OrderTakeProfit(), 0, GreenYellow );

}

}

}

}

}

Also, if felt useful, I have coded a SpikeTrader EA. The SpikeTrader code tracks bar open to high and open to low and triggers Pending Orders call on preset span value, I believe this code could be use to indentify trends. EA utiltizes BuyStop, SellStop Orders and OCO techniques. The code has identified Spikes correctly about 70-80%.

I hope this may be useful for future Phoenix developement.

Wackena
 

Hello Daraknor,

I have found this link and it might be of interest to you (and hopefully others too)....

http://www.forexfactory.com/showthread.php?t=3690

Have a good weekend

AZBOfin

 

An interesting observation.

In the past 2 weeks I was running P_V5_7_0 on USD/JPY & GBP/JPY I've noticed that there are some occations that the EA show one signal, and then, after a while, the opposite one. Since the EA igmores any other signals after taking a position, the deal moves on and sometimes ends in a loss.

Under the assumption that we do trust those signals since the false positive signals are within an acceptable range (and I think it is the case, after all it is still profitable), the question is how to minimise its damage.

I suggest that once a signal in the opposite direction to the current open position appears, the EA will close the open position.

Whats your opinion on that matter?

 

cre666:

there're always going to be loosing trades - it's part of trading. i think it would be wrong not to accept this fact.

AZBOfin

 
cre666:
In the past 2 weeks I was running P_V5_7_0 on USD/JPY & GBP/JPY I've noticed that there are some occations that the EA show one signal, and then, after a while, the opposite one. Since the EA igmores any other signals after taking a position, the deal moves on and sometimes ends in a loss.

Under the assumption that we do trust those signals since the false positive signals are within an acceptable range (and I think it is the case, after all it is still profitable), the question is how to minimise its damage.

I suggest that once a signal in the opposite direction to the current open position appears, the EA will close the open position.

Whats your opinion on that matter?

Before I answer your question here is a tip. Download the google toolbar for IE or Firefox as the case may be. It has a button that says ABC. Click on that and it will catch all your spelling mistakes, inside internet text entry boxes.

ANSWER

The following is take from the USDJPY preferred settings

TakeProfit = 42;

StopLoss = 84;

Before you started trading in the Forex you probably read something like

"always make your TakeProfit twice as far above your open position as your stoploss is below it".

This EA flies in the face of that advice and specifies the opposite. The way these values were arrived at was through the optimization process. The underlying reality of these settings is that "You have to let this EA run far into the negative most of the time in order to have obtained the best profit over the long run". It goes far into the negative but recovers to be profitable many times. As weird as these setting are relative to conventional Forex wisdom, this EA has a history of being profitable. If you change some of these variables and run some back testing you will see that these setting are usually the most profitable.

Your idea sounds logical, it could be worth looking at. I initially was thinking that your idea was the equivalent of setting the stoploss to 2, which we know is not going to end up being profitable at all. But in fact the signal for the other direction may occur much later or even when we are in a profit situation, and it may indeed be a warning that this trade is going to go all the way to the stoploss. There are two ways to play the suggestion. We could close the trades and wait for the next opportunity or we could close the trades and go with the new signal. I think it is worth a try with Phoenix Mode 1 in an unofficial way. I can't make a commitment to try it any time soon. If I were doing it, I would code it in the most up to date version. If it works with Mode 1 then it would then be a candidate for inclusion in an official release.

I wonder if this idea was already tried in an earlier version of Phoenix.

Perhaps you didn't notice the following setting. It takes 5 confirming signals in version 5.7.0 to have actually make the trade, when the signal comes in the opposite direction it would need to have the same or probably a different and optimizable number of signals before any action is taken.

extern int signal_count=5; //Set to number of consecutive confirming signals.

Have you done any optimization runs yourself? You should be the guy to code and test your new idea. If you aren't a coder you could still test it.

One more thing to consider.

extern int MaxTrades = 1; //set to number of trades to open

For mode 1 or 2, you can have multiple trades going in both directions already. So the change you are proposing I would interpret be to kill off all positions that are opposite to the current directions.

 
cre666:
In the past 2 weeks I was running P_V5_7_0 on USD/JPY & GBP/JPY I've noticed that there are some occations that the EA show one signal, and then, after a while, the opposite one. Since the EA igmores any other signals after taking a position, the deal moves on and sometimes ends in a loss.

Under the assumption that we do trust those signals since the false positive signals are within an acceptable range (and I think it is the case, after all it is still profitable), the question is how to minimise its damage.

I suggest that once a signal in the opposite direction to the current open position appears, the EA will close the open position.

Whats your opinion on that matter?

increase the required consecutive signal count. With different settings, maxtrades increased and signal count increased has good results even though it will open both buy and sell trades on one currency. So many options, most of them settings specific.

 

5.7.2 Changelog

Reserved for changelog. 5.7.2 released in post #1. catching up after being sick.

 

Hi Darak

I loaded P572a

I have that msg in Experts

2007.01.23 11:25:13 Phoenix_EA_v5_7_2a USDCHF,M15: Alert: Fast should be 5+ faster than Slow. P_Period settings invalid. USDCHF

After :

2007.01.23 11:25:13 Phoenix_EA_v5_7_2a USDCHF,M15: Alert: Fast 5 SLOW 20

And

2007.01.23 11:25:13 Phoenix_EA_v5_7_2a USDCHF,M15: initialized

Same 3 msg for GB/$

(and pop up appears)

Normal ?

Thks

 

hi, Darak

i 've the same bertbin's alert,

thanks, giapel