Basic questions ... - page 6

 
 

MTF RWI Trigger??

How would I program a buy trigger for all green and sell trigger for all red for these indicators?? Please help...

Nick,

Files:
 

EA for only once per tick

Hey guys,

I don't know if this has been posted before (I lack the patience to search through threads, sorry!) but I know it's been asked for a lot.

This code will ONLY run once per tick. It will run as soon as a new tick is introduced, and only then, and not function afterwards until another occurs.

Please keep in mind that can actually be a problem, at times. If your orders don't go through, for whatever reason, it will not initiate again. If you want to modify the code to do so, go ahead. I would suggest something like:

if order fails, fileseek to front of f, write Open[2] to f

This will make the next tick believe it's a new one.

Files:
newtick.mq4  3 kb
 

Are there any books, online tutorials or videos on writing MQL4?

 

Hello All,

I need help coding this:

Based on a daily chart:

a) Let's say my conditions are met on closing on day#1 and let's assume day# is June 9.

b) Now i want to place a BUY-Stop and a sell-stop at the High and Low on closing on day #2 or june 10

c) Finally, i want the trade to be triggered on day#3.

Additionally, if the LONG is triggered first, i want the sell-stop to be closed and vice-versa.

Thanks in advance for your help.

regards,

forexcel

 

EA for appointing day of a week ,and time

Do not you know EA which you choose the day,(For example, only Wednesday and Thursday) and appoint time for opening and closing?

In many cases,

A rate rises on Wednesday and Thursday since many people to get the SWAP.

I buy it at this time and take a position.

And the rate falls as soon as an SWAP occurred.

I am sold at this time and take a position.

I am looking for EA to use for like this trade.

 

I need help!

Hi guys,

I need help. I have this EA that I've created

#define SIGNAL_NONE 0

#define SIGNAL_BUY 1

#define SIGNAL_SELL 2

#define SIGNAL_CLOSEBUY 3

#define SIGNAL_CLOSESELL 4

#property copyright "FxAttack"

#property link "http://www.ioinvesto.com"

extern int MagicNumber = 0;

extern bool SignalMail = False;

extern bool EachTickMode = True;

extern double Lots = 0.1;

extern int Slippage = 3;

extern bool UseStopLoss = True;

extern int StopLoss = 25;

extern bool UseTakeProfit = True;

extern int TakeProfit = 25;

extern bool UseTrailingStop = False;

extern int TrailingStop = 30;

extern bool Use.Time.Filter = true;

extern string Server.Time.To.Start = "00:00";

extern string Server.Time.To.Stop = "17:00";

extern bool Not.Trade.Fri.Sun = True;

int BarCount;

int Current;

bool TickCheck = False;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init() {

BarCount = Bars;

if (EachTickMode) Current = 0; else Current = 1;

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit() {

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start() {

int Order = SIGNAL_NONE;

int Total, Ticket;

double StopLossLevel, TakeProfitLevel;

if (EachTickMode && Bars != BarCount) TickCheck = False;

Total = OrdersTotal();

Order = SIGNAL_NONE;

//+------------------------------------------------------------------+

//| Variable Begin |

//+------------------------------------------------------------------+

double OpenPrice = iOpen(NULL, PERIOD_D1, Current + 0);

double Buy_Sign = (OpenPrice + (30*Point));

double Sell_Sign = (OpenPrice - (30*Point));

double start_time = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + Server.Time.To.Start);

double end_time = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + Server.Time.To.Stop);

Comment("Open Price = ",OpenPrice);

//+------------------------------------------------------------------+

//| Variable End |

//+------------------------------------------------------------------+

if(Use.Time.Filter && (TimeCurrent() = end_time)) return(0);

if(Not.Trade.Fri.Sun && (DayOfWeek()==6 || DayOfWeek()==1 )) return(0);

//Check position

bool IsTrade = False;

for (int i = 0; i < Total; i ++) {

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

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

IsTrade = True;

if(OrderType() == OP_BUY) {

//Close

//+------------------------------------------------------------------+

//| Signal Begin(Exit Buy) |

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//| Signal End(Exit Buy) |

//+------------------------------------------------------------------+

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

OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

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

if (!EachTickMode) BarCount = Bars;

IsTrade = False;

continue;

}

//Trailing stop

if(UseTrailingStop && TrailingStop > 0) {

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

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

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

if (!EachTickMode) BarCount = Bars;

continue;

}

}

}

} else {

//Close

//+------------------------------------------------------------------+

//| Signal Begin(Exit Sell) |

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//| Signal End(Exit Sell) |

//+------------------------------------------------------------------+

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

OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);

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

if (!EachTickMode) BarCount = Bars;

IsTrade = False;

continue;

}

//Trailing stop

if(UseTrailingStop && TrailingStop > 0) {

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

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

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

if (!EachTickMode) BarCount = Bars;

continue;

}

}

}

}

}

}

//+------------------------------------------------------------------+

//| Signal Begin(Entry) |

//+------------------------------------------------------------------+

if (Bid > Buy_Sign) Order = SIGNAL_BUY;

if (Ask < Sell_Sign) Order = SIGNAL_SELL;

//+------------------------------------------------------------------+

//| Signal End |

//+------------------------------------------------------------------+

//Buy

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

if(!IsTrade) {

//Check free margin

if (AccountFreeMargin() < (1000 * Lots)) {

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

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, "MaxPower Buy Order", 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);

}

}

//Sell

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

if(!IsTrade) {

//Check free margin

if (AccountFreeMargin() < (1000 * Lots)) {

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;

if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "MaxPower Sell Order", MagicNumber, 0, DeepPink);

if(Ticket > 0) {

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

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

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

} else {

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

}

}

if (EachTickMode) TickCheck = True;

if (!EachTickMode) BarCount = Bars;

return(0);

}

}

if (!EachTickMode) BarCount = Bars;

return(0);

}

//+------------------------------------------------------------------+[/PHP]

......but I don't understand how to put the code below inner it.

[PHP]...

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() )

return(0);

....

The last block of code that I've written is: "If one order on one SYMBOL has been already opened, do not open new orders on that SYMBOL".

Can someone help me to integrate it?

Thanks,

Mauro

 

EA only makes one trade...

Hey guys, I have a quick question for you. I recently created an EA. The parameters are correct and when I added it to the chart, it placed an appropriate Buy and then later a Sell. But, the next time a Buy signal came, it never placed a trade. Seems that the EA is only taking the first trade and then none thereafter. Any idea why this might be? I'd appreciate any help. Thanks!!!

 

Maybe it is an idea to show the ea? So we can look at the code?

Reason: