Raw Ideas - page 17

 

Problem with breakeven and trailing stop

Hello,

I am learning coding using the MQL4 tutorial from Codersguru, and I'm working on "My_First_EA". It really is my first EA. It works very well, but I am trying to write a breakeven stop and I can't figure it out. The problem I have is that the breakeven stop follows the price just like a trailing stop. I would like the initial stoploss to move to keep 1 pip profit when I make 15 pips (for example), then I want the stoploss to stay at the breakeven stop (1 pip profit) until the trailing stop begins working at 25 pips profit. Then I want the trailing stop to work as usual moving every pip of profit. I think the problem might be the "OrderStopLoss()", but I don't know anything anymore. My brain is mush. Thankyou

Here is the relevent code I've done:

extern double TrailingStop=25.0;

extern double BreakEvenProfit=15;

extern double BreakEvenStop=1;

......................

my entry and open orders code here works fine

......................

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

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if (OrderType()<=OP_SELL&&OrderSymbol()==Symbol())

{

if(OrderType()==OP_BUY)//Long position is opened

{

//should it be closed?

if (FSAR > FMA) //my exit signal

{

//----CLOSE LONG POSITION

OrderClose(OrderTicket(),OrderLots(),Bid,3,Magenta);

return(0);//exit

}

////////////////////THIS IS THE PROBLEM AREA BELOW/////////

//----CHECK FOR BREAKEVEN STOP LONG POSITION------

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

{

if (OrderStopLoss() < OrderOpenPrice()+ BreakEvenStop*Point)

{

OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice() + BreakEvenStop*Point,OrderTakeProfit(),0,Yellow);

return(0);

}

}

//-----EVERYTHING BELOW HERE WORKS AS A TYPICAL TRAILING STOP

//----check for trailing stop LONG POSITION

if(TrailingStop>0)

{

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

{

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

{

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

return(0);

}

}

}

}

else//go to short position

 

RSI (Histogram) with color indication

I am looking for a RSI (Histogram) and the color will change when the value is greater or smaller than the previous bar. Anyone have it? can share it? Thanks in advanced.

Files:
rsi.jpg  15 kb
 

Set oscillation.

I made an indicator where the the value of the histogram is based on pips. I was wondering how I can have it oscillate between -50,50 so it's percentage based.

 

Some Interesting post!!!

Hey guys,...

I found this post in another forum :

Hi guys, about an year ago i bought an expert advisor for MT4. It's really doing well but i feel like blind using it and although i have never had a big loss i'm affraid not knowing how does it work, how it opens a trade, when it decides to close a trade. Is it possible to understand those things?

If you have any idea please write to me: fancofx@libero.it

He post it in September 2005. I've send an email to him and ask for his EA. Any informations about this guy?....

 

'small deposit' and 'every broker'

I visited many forums and sites trying to find the following:

1. EA or strategy working on the small deposit size (less than 500 for example);

I did not find it.

2. EA or some pieces of the codes to be inserted in EA to work in almost all the brokers with the same results. I mean how to improve EA to have the same results in almost every broker?

All that I found is to use pending orders. And some people are using D1 timeframe.

I will try to find everything. But may be the members are having some suggestion about it?

 

help needed!

hello everyone.

i want a specific indicator that will tell me the high and low for a hour 4 hours and the day.

i have no programming experience and i would like this indicator if it exists or if someone could make one for me that would be great.

a indicator i picked up a while back i need it to auto-refresh and have no idea how to do that either.

ive attached the indicator ide like to have refresh.

thank you in advance

god bless~

Files:
 

How to Experts & indicators

hi all

i have one expert (MyExpert) and one custom indicator (MyIndicator)

i need in MyExpert code

============================================

int init()

{

... another code ...

if (MyIndicator is ploted on chart)

{

configure params (MyIndicator ) for the MyExpert

}

else

{

add MyIndicator on chart and

configure params (MyIndicator ) for the MyExpert

}

... more code ...

return (0);

}

int deinit()

{

... another code ...

if (MyIndicator is ploted on chart)

{

remove indicator

}

... more code ...

return (0);

}

============================================

thanks for your help...

charles

 

Requote slippage code needed

I've recently switched from IBFX to MIG. One problem I am having is that I often am given a requote price! I changed my slippage to 0 and it seems that my orders only execute about 60% of the time. I was wondering if anyone knows how to change the code to accept the requote if it goes in a more favorable direction (down if I'm closeing a sell or opening a buy, etc.), but reject it if the requote price is in the other direction.

If no one knows how to do this I have some ideas that I'd like to try and that I can post here if I figure it out, but that might never work out, so I hope someone else here knows how to do this. THanks for the help!

 

straddle EA help?

Hello,

I need help with how to write an EA with a straddle idea:

If condition (lets say EMA cross over) then open two orders (buy stop and sell stop) each 10 pips away from current Bid/Ask spread. Then if one order is opened, don't cancel the other one immediatly. If the opened order made sufficient moves (e.g. 20-30 pips) cancel the other order. But If the opened order closed using a trailing stop with lets say 20 pips then immediatly modify the other order to open immediatly.

Thanks

 

do I need calculate previous data every time when I receive new quotation?

In an expert advisor, if I calculate very much with previous sticks data, and the conclusion affects current calculation, do I need calculate previous data every time when I receive new quotation?