ftwfx: Below is my EA code:
int Signal(){ double sig1=... if(sig1==2.0 && sig3==1.5 && sig5==1.0 && sig7==0.5) return(1); // 4 Green Bar = Buy Order if(sig2==2.0 && sig4==1.5 && sig6==1.0 && sig8==0.5) return(2); // 4 Red Bar = Sell Order }
I check the ea log, sometime when two bars are still green, one sell order is placed, i use the Print function to get the values :
If it's not 4 Green bars and not 4 red bars, what do you return from Signal?
Maybe the problem is not with your indicator code (Signal) but with what you do with it.
- Print the value from Signal()
- Check your return codes.
- Post your code. There are no mind-readers here.
thank for the reply, use the return value from Signal by this way
//New Buy Order if(Trend() && Signal()==1 && ok!=Time[0] && Mspread() && BuyOrderNumber()==0 && SellOrderNumber()==0) { BuyTicket=OrderSend(Symbol(),OP_BUY,GetLots(),Ask,SlipPage,0,0,TradeComment,MagicNumber,0,Blue); if (BuyTicket<0) { Alert(Symbol()+" Buy OrderSend failed with error # "+GetLastError()); } if (OrderModify(BuyTicket,OrderOpenPrice(),Bid-StopLoss*Point,Ask+TakeProfit*Point,0,0)==false) Alert(Symbol()+" "+BuyTicket+" Buy Order Modify Fail, Error: "+GetLastError()); else Alert(Symbol()+" "+BuyTicket+" Buy Order Modify Success"); Print ("K ",sig1," - ",sig3," - ",sig5," - ",sig7," - ",sig2," - ",sig4," - ",sig6," - ",sig8); ok=Time[0]; }
//New Sell Order if(Trend() && Signal()==2 && ok!=Time[0] && Mspread() && BuyOrderNumber()==0 && SellOrderNumber()==0) { SellTicket=OrderSend(Symbol(),OP_SELL,GetLots(),Bid,SlipPage,0,0,TradeComment,MagicNumber,0,Red); if (SellTicket<0) { Alert(Symbol()+" Sell OrderSend failed with error # "+GetLastError()); } if (OrderModify(SellTicket,OrderOpenPrice(),Ask+StopLoss*Point,Bid-TakeProfit*Point,0,0)==false) Alert(Symbol()+" "+SellTicket+" Sell Order Modify Fail, Error: "+GetLastError()); else Alert(Symbol()+" "+SellTicket+" Sell Order Modify Success"); Print ("K ",sig2," - ",sig4," - ",sig6," - ",sig8," - ",sig1," - ",sig3," - ",sig5," - ",sig7); ok=Time[0]; }
3Red bar + 1 Green bar, a new sell order is placed.
2013.02.24 17:31:49 2013.02.13 07:00 GodGift - I EURUSDpro,M15: K 2 - 1.5 - 1 - 0.5 - 0 - 0 - 0 - 0 2013.02.24 17:31:49 2013.02.13 07:00 GodGift - I EURUSDpro,M15: Alert: EURUSDpro 1 Sell Order Modify Success 2013.02.24 17:31:49 2013.02.13 07:00 GodGift - I EURUSDpro,M15: modify #1 sell 2.00 EURUSDpro at 1.34426 sl: 1.35454 tp: 1.34226 ok 2013.02.24 17:31:49 2013.02.13 07:00 GodGift - I EURUSDpro,M15: open #1 sell 2.00 EURUSDpro at 1.34426 ok
4 Red bar another new sell order is placed, this time works fine :)
2013.02.24 17:33:20 2013.02.15 08:15 GodGift - I EURUSDpro,M15: K 2 - 1.5 - 1 - 0.5 - 0 - 0 - 0 - 0 2013.02.24 17:33:20 2013.02.15 08:15 GodGift - I EURUSDpro,M15: Alert: EURUSDpro 2 Sell Order Modify Success 2013.02.24 17:33:20 2013.02.15 08:15 GodGift - I EURUSDpro,M15: modify #2 sell 2.08 EURUSDpro at 1.33401 sl: 1.34429 tp: 1.33201 ok 2013.02.24 17:33:20 2013.02.15 08:15 GodGift - I EURUSDpro,M15: open #2 sell 2.08 EURUSDpro at 1.33401 ok
thank for the reply, use the return value from Signal by this way
<CODE REMOVED>
Please edit your post . . .
finish editing, really sorry for that, i thought it is using the code mode, now i got it.
because i just want the Signal to return 1 or 2 for buy or sell, so i didn't add the code to return other value. Just now i tried to add some code like this
if(sig1==2.0 && sig3==1.5 && sig5==1.0 && sig7==0.5) { return(1); } if(sig2==2.0 && sig4==1.5 && sig6==1.0 && sig8==0.5) { return(2); } else return(3); }
but the same result, sometimes, 3 Green + 1 Red it still do the buy order, 3 Red + 1 Green still do the sell order
I think maybe the color changes with the price change during the new candle, so could i add a limit to this, only get the value once when the second that a new candle begins?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, guys, im new to mql4 and this forum~ i hope i can get some help with my problem here. A couple days ago, i just started my first simple ea by just using icustome function with some indicator, i thought everything is done until i started to backtest it. There was a serious problem: the ea couldn't get the right value from one mtf indicator, so i tried to solve it myself, two days passed, no solution...even i have Google searched the related topics and tried those ways mentioned in the threads, it still didn't work. Since i just know something basic to the proramming, so i decide to post my problem here hoping some experts can solve it. I will attach the two indicators, the "MTF_Bar" one is the one i wanna get value, and it need use the other indicator "NonLag".
Below is my EA code:
I check the ea log, sometime when two bars are still green, one sell order is placed, i use the Print function to get the values :
sig2=2.0 sig4=1.5 sig6=1.0 sig8=0.5 sig1=0 sig3=0 sig5=0 sig7=0 (it is same as 4 red bars)
Checked the indicator code, below is just my guess the reason for this unmatch issue, getting revalued everytime the price change??
Above is my problem, so im waiting for someone can help, i really appreaciate any help or advices, thanks!!!
Two indicators