What are the variables highestPrice and lowestPrice, where are they assigned a value.?
NULL is not a documented replacement for Symbol() in the OrderSend() function.
How do you know that you get error code 2 for the OrderSend(), you don't print anything when/if OrderSend() fails ?
ResetLastError(); |
right before your OrderSend()
I'm printing:
This is one of the else conditions!
I'm printing:
This is one of the else conditions!
That else is coupled with
Nothing to do with placing orders
Liokewise
Alert("Error by getting SuperTrend! - Please inform the programmer! #03");
is coupled with
What are the variables highestPrice and lowestPrice, where are they assigned a value.?
NULL is not a documented replacement for Symbol() in the OrderSend() function.
How do you know that you get error code 2 for the OrderSend(), you don't print anything when/if OrderSend() fails ?
I repeat
What are the variables highestPrice and lowestPrice, where are they assigned a value.?
also
if(succeeded == true){
if(trade == true){
Yes, it is coupled with the LoweIsEmpty and UpperIsEmpty because it must be one of those. It can only be 0 and 1 or 1 and 0... - It can never be 1 and 1 or 0 and 0...
That is the reason for it. And it is coupled because I need to know if my EA is getting the right SuperTrend, more specifically any value of the SuperTrend. But it looks like that my EA isn't getting the value...
That is the reason why I'm getting #02 or #03 error...
HighestPrice and Lowest Price are both some values entered by the user.
Scceeded is only a value to check if the entered values are right but they are, otherwise I would get until the #02 or #03 error...
Trade is only a value which is turned to false if one order is placed. Because this EA is only forced to place one order!
Just print the buffer values to see if that works correctly or not.
There are seven of them so:
Print("Buffer 1: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",1,0));
Print("Buffer 2: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",2,0));
Print("Buffer 3: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",3,0));
Print("Buffer 4: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",4,0));
Print("Buffer 5: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",5,0));
Print("Buffer 6: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",6,0));
Print("Buffer 7: ",iCustom(Symbol(),PERIOD_CURRENT,"SuperTrend",7,0));
- Exactly. Need to know which buffer and all the parameters.
- Write a self documenting function instead of calling iCustom directly, see Detailed explanation of iCustom - MQL4 forum
Why does this EA have 7 Buffers? - Which one is for what
An EA doesn't have buffers, it gets buffer values from an indicator with iCustom().
Your code is confusing
if(sT_l == EMPTY_VALUE && sT_u != EMPTY_VALUE){
Comment("sT_l == EMPTY_VALUE && sT_u != EMPTY_VALUE");
UpperIsEmpty = 1;
LowerIsEmpty = 0;
I don't know whether UpperIsEmpty and LowerIsEmpty are bools or ints. Ideally they should be bools and you should use true or false instead of 0 and 1.
You are using 0 for true and 1 for false which is the opposite of the way they will be read by other coders.
if(LowerIsEmpty == 0 && UpperIsEmpty == 1){ //SuperTrend Lower is Empty = SuperTrend Upper is above market price!
if(EMA25 > EMA50){
if(Ask > sT_l){
If the first if is true, sT_1 must = EMPTY_VALUE
so
if(Ask > sT_l){
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey Guys,
I programmed a EA with an Indicator called SuperTrend. My problem is that if the market triggered the line to sell or buy, I am getting the Error "#02" and the Order isn't placed...
Does anyone has a idea and can help me? (SuperTrend is attached!)
hitTarget = true;
}
if(tpSell > Ask){
hitTarget = true;
}
EMA25 = iMA(NULL, 0, 25, 0, MODE_EMA, PRICE_MEDIAN, 0);
EMA50 = iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_MEDIAN, 0);
sT_l = iCustom(NULL, 0, "SuperTrend", 10, 3.0, 0, 0);
sT_u = iCustom(NULL, 0, "SuperTrend", 10, 3.0, 1, 0);
Comment("EMA25(e): ",EMA25," - EMA50(e): ",EMA50," - SuperTrend (Lower): ",sT_l," - SuperTrend (Upper): ",sT_u);
//SuperTrend (Lower): 1.124628 - SuperTrend (Upper): 2147483647.0
if(sT_l == EMPTY_VALUE && sT_u != EMPTY_VALUE){
Comment("sT_l == EMPTY_VALUE && sT_u != EMPTY_VALUE");
UpperIsEmpty = 1;
LowerIsEmpty = 0;
}else if(sT_l != EMPTY_VALUE && sT_u == EMPTY_VALUE){
Comment("sT_u == EMPTY_VALUE && sT_l != EMPTY_VALUE");
UpperIsEmpty = 0;
LowerIsEmpty = 1;
}else{
Alert("Error by getting SuperTrend! - Please inform the programmer! #01");
}
if(succeeded == true){
if(trade == true){
if(Ask > highestPrice){
if(LowerIsEmpty == 0 && UpperIsEmpty == 1){ //SuperTrend Lower is Empty = SuperTrend Upper is above market price!
if(EMA25 > EMA50){
if(Ask > sT_l){
ticketNr = OrderSend(NULL, OP_BUY, lots, Ask, 100, lowestPrice, 0, NULL, magicNr, 0, clrGreen);
Alert("Buyed ",Symbol()," at ",(tpBuy - span),"wih S/L @",lowestPrice," !");
trade = false;
}
}
}else{
Alert("Error by getting SuperTrend! - Please inform the programmer! #02");
}
}else if(Bid < lowestPrice){
if(LowerIsEmpty == 1 && UpperIsEmpty == 0){ //SuperTrend Upper is Empty = SuperTrend Lower is above market price!
if(EMA25 < EMA50){
if(Bid < sT_u){
ticketNr = OrderSend(NULL, OP_SELL, lots, Bid, 100, highestPrice, 0, NULL, magicNr, 0, clrRed);
Alert("Sold ",Symbol()," at ",(tpSell + span),"wih S/L @",highestPrice," !");
trade = false;
}
}
}else{
Alert("Error by getting SuperTrend! - Please inform the programmer! #03");
}
}
}
}else{
Print("404 - Error!");
}
if(trade == false){
if(hitTarget == true){
if(Bid > tpBuy){
if(tvkClosed == false){
if(OrderSelect(ticketNr, SELECT_BY_TICKET)){
OrderClose(ticketNr, tvk, OrderClosePrice(), 100, clrGold);
tvkClosed = true;
Alert("Closed ",Symbol()," Trade with ",tvk," Lot!");
}
}
}else if(Ask < tpSell){
if(tvkClosed == false){
if(OrderSelect(ticketNr, SELECT_BY_TICKET)){
OrderClose(ticketNr, tvk, OrderClosePrice(), 100, clrGold);
tvkClosed = true;
Alert("Closed ",Symbol()," Trade with ",tvk," Lot!");
}
}
}
}
}
}
//+------------------------------------------------------------------+