How to code? - page 227

 

hi, i need some help from script code expert..i want to code 2 set of pending order like below..

set 1

pending order.

GBPUSD ( buy stop) ,

EURUSD ( buy stop ),

AUDUSD (buy stop),

NZDUSD (buy stop),

USDJPY (sell stop),

USDCAD (sell stop),

USDCHF (sell stop)

set 2

pending order.

GBPUSD ( sell stop) ,

EURUSD ( sell stop ),

AUDUSD (sell stop),

NZDUSD (sell stop),

USDJPY (buy stop),

USDCAD (buy stop),

USDCHF (buystop)

thank you.

 

Here is the trailing stop code and the buy code, I think the prob may be in here, but not sure......

//Trailing stop

if(UseTrailingStop && TrailingStop > 0) {

if((OrderOpenPrice() - Ask) > (Point * (TrailingStop+0.5))) {

if((OrderStopLoss() > (Ask + Point * (TrailingStop+0.5))) || (OrderStopLoss() == 0)) {

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

if (!EachTickMode) BarCount = Bars;

continue;

//Buy

if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

if(DecideToOpenTrade(OP_BUY) && TradeSlotsAvailable()) {

if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;

if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);

if(Ticket > 0) {

if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {

Print("BUY order opened : ", OrderOpenPrice());

if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");

} else {

Print("Error opening BUY order : ", GetLastError());

}

}

if (EachTickMode) TickCheck = True;

if (!EachTickMode) BarCount = Bars;

return(0);

 

EA not opening trades..... ??

Having a problem with my EA. It will open trades fine when just using a trailing stop, but when I try to use a trailing stop and and stoploss together it will not open trades. It works fine this way on the backtests, but will not open a real trade on the chart. I'm trying to run a trailing stop of 5 pips and a stoploss of 200 pips. Any thoughts? I can post the open trade coding if need be.

Thanks!

 

Please check Experts tab for error codes

 

I did, no errors there. Theres nothing there when its suppose to open a trade when I have a trailing stop and stoploss enabled. When its just the trailing stop, it has all the trades in the tab like normal.

 

time in secs or ms?

Hi i was looking for a specific time string for mt4 and found this:

if ((CurTime()-OrderOpenTime()>300))

my question now: those 300, are they 300 seconds or milliseconds or what?

thanks guys

 

Datetime variables in MT4 are internally stored as long integer values, or 4-byte (2^32) integer values, and they represent the number of seconds elapsed since epoch.

To answer your question, its 300 seconds.

 

Will this code do what I need?

Will this code get me the RSI on top of the CCI that I need for my strategy?

I need the EA to read the RSI using "Previous Indicator's Data" from CCI.

double Buy1_1 = iCCI(NULL, 0, 10, PRICE_OPEN, Current + 0);

double Buy2_1 = iRSI(NULL, 0, 3, 7, Current + 0);

 

Return High/Low for specified time range?

Hello all, long time lurker, 1st time poster.

Apologies if im posting this in the wrong section.... Im trying to determine a way of returning the high / low of a specified time range.

Im comfortable with the following method....

iLow(NULL, PERIOD_D1, 0);

But what im attempting to do is to specify the range as from say 23:00 from the previous day to 06:00 of the current day, and keep that range as a variable until 23:00 comes round again.

Any guidance on this would be more than helpful. Thanks!

 

MQL4 String Formatting

I have tried using '\x20' and '\xA0' to provide left pads in order to right justify strings. The spacing they provide are inadequate. Anyone know a better way to do this in MQL4?

Reason: