done, sorry and thanks
done, sorry and thanks
thanks i change te code but the program does the same...
SMA4 = iMA( NULL, MATimeFrame, MA4Period, MMAShift, MODE_SMA, PRICE_CLOSE, MAShift ); SMA9 = iMA( NULL, MATimeFrame, MA9Period, MMAShift, MODE_SMA, PRICE_CLOSE, MAShift ); SMA4_ant = iMA( NULL, MATimeFrame, MA4Period, MMAShift, MODE_SMA, PRICE_CLOSE, 2 ); SMA9_ant = iMA( NULL, MATimeFrame, MA9Period, MMAShift, MODE_SMA, PRICE_CLOSE, 2); if(SMA4 > SMA9 && SMA4_ant<=SMA9_ant ) { OrderSend( Symbol(), OP_BUY, 0.01, Ask, 0, 0, 0, "basketNumber", MAGIC ) ; Alert(Symbol() + " - " + "B SMA4 : " + SMA4 + " SMA4 anterior: " + SMA4_ant + " - " + "SMA9 : "+ SMA9 + " - " + "SMA9 anterior: "+ SMA9_ant); Alert("",GetLastError()); totalTrades=totalTrades+1; } else{ if(SMA4 < SMA9 && SMA4_ant>=SMA9_ant ) { OrderSend( Symbol(), OP_SELL, 0.01, Bid, 0, 0, 0, "basketNumber", MAGIC ) ; Alert(Symbol() + " - " + "S SMA4 : " + SMA4 + " SMA4 anterior: " + SMA4_ant + " - " + "SMA9 : "+ SMA9 + " - " + "SMA9 anterior: "+ SMA9_ant); Alert("",GetLastError()); totalTrades=totalTrades+1;
hi again i change mi code but I have a problem, I can only open a single operation. and what I want is to open multiple operations and closing them go when they get to profit.
someone could give me a hand??
thanks
void openPosition(){ if( AccountFreeMargin() > 0 ){ if((SMA4 >= SMA9 && SMA4_ant<=SMA9_ant)&& (RSI >= SignalRSImiddle && RSI <= SignalRSIhigh)) { if (OrdersTotal()==0){ if(Ask>SMA4) { OrderSend( Symbol(), OP_BUY, lotSize, Ask, slippage, 0, 0, CommentName, MAGIC,0,Green ) ; Alert(Symbol() + " - " + "B>4 SMA4 : " + SMA4 + " SMA4 anterior: " + SMA4_ant + " - " + "SMA9 : "+ SMA9 + " - " + "SMA9 anterior: "+ SMA9_ant); Alert(Symbol() + " - " + "B>4 RSI : " + RSI + " RSI Middle: " + SignalRSImiddle + " - " + "RSI HIGH : "+ SignalRSIhigh + " - " + "RSI Low : "+ SignalRSIlow); Alert(Symbol() + " - " + "B>4 Ask: " + Ask + " Bid: " + Bid); Alert(Symbol() + " - " + "B>4 pippoint: " + pipPoints); } if(Bid<SMA4) { OrderSend( Symbol(), OP_SELL, lotSize, Bid, slippage, 0, 0, CommentName, MAGIC,0,Red ) ; Alert(Symbol() + " - " + "S>4 SMA4 : " + SMA4 + " SMA4 anterior: " + SMA4_ant + " - " + "SMA9 : "+ SMA9 + " - " + "SMA9 anterior: "+ SMA9_ant); Alert(Symbol() + " - " + "S>4 RSI : " + RSI + " RSI Middle: " + SignalRSImiddle + " - " + "RSI HIGH : "+ SignalRSIhigh + " - " + "RSI Low : "+ SignalRSIlow); Alert(Symbol() + " - " + "S>4 Bid: " + Bid + " Ask: " + Ask); Alert(Symbol() + " - " + "S>4 pippoint: " + pipPoints); } } } if((SMA4 <= SMA9 && SMA4_ant>=SMA9_ant) && (RSI <= SignalRSImiddle && RSI >= SignalRSIlow)) { if (OrdersTotal()==0){ if(Ask>SMA4) { OrderSend( Symbol(), OP_BUY, lotSize, Ask, slippage, 0, 0, CommentName, MAGIC ,0,Yellow) ; Alert(Symbol() + " - " + "B<4 SMA4 : " + SMA4 + " SMA4 anterior: " + SMA4_ant + " - " + "SMA9 : "+ SMA9 + " - " + "SMA9 anterior: "+ SMA9_ant); Alert(Symbol() + " - " + "B<4 RSI : " + RSI + " RSI Middle: " + SignalRSImiddle + " - " + "RSI HIGH : "+ SignalRSIhigh + " - " + "RSI Low : "+ SignalRSIlow); Alert(Symbol() + " - " + "B<4 Ask: " + Ask + " Bid: " + Bid); Alert(Symbol() + " - " + "B<4 pippoint: " + pipPoints); } if(Bid<SMA4) { OrderSend( Symbol(), OP_SELL, lotSize, Bid, slippage, 0, 0, CommentName, MAGIC ,0,PaleGreen) ; Alert(Symbol() + " - " + "S<4 SMA4 : " + SMA4 + " SMA4 anterior: " + SMA4_ant + " - " + "SMA9 : "+ SMA9 + " - " + "SMA9 anterior: "+ SMA9_ant); Alert(Symbol() + " - " + "S<4 RSI : " + RSI + " RSI Middle: " + SignalRSImiddle + " - " + "RSI HIGH : "+ SignalRSIhigh + " - " + "RSI Low : "+ SignalRSIlow); Alert(Symbol() + " - " + "S<4 Bid: " + Bid + " Ask: " + Ask); Alert(Symbol() + " - " + "S<4 pippoint: " + pipPoints); } } //Alert("Error Number: "+GetLastError() + "Description: " + ErrorDescription()); } } } void closeAll(){ for( int i = 0; i < OrdersTotal(); i++ ) { if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false ) break; if( OrderSymbol() == Symbol() ){ RefreshRates(); // if( OrderProfit() > MinProfit) | ( OrderProfit() > MinProfit/2) | ( OrderProfit() > MinProfit/3){ if( OrderProfit() > MinProfit){ if( OrderType() == OP_BUY ) OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 0,White ); if( OrderType() == OP_SELL ) OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 0,Blue ); } } } }
hi again i change mi code but I have a problem, I can only open a single operation. and what I want is to open multiple operations and closing them go when they get to profit.
someone could give me a hand??
thanks
hi again i change mi code but I have a problem, I can only open a single operation. and what I want is to open multiple operations and closing them go when they get to profit.
someone could give me a hand??
thanks
if (OrdersTotal()==0){ if(Ask>SMA4) { ..... }
hi, yes i see it, and i put it because but opens many operations in the same candle....
Do your OrderSend() calls fail ? don't you want to know ? and if they do fail don't you want to know why ? Please read and implement this: What are Function return values ? How do I use them ?
thanks for the suggestions, I have a pending error handling and optimizing the code.
I'm just starting to get the robot to work as I want ..
serdan:
thanks for the suggestions, I have a pending error handling and optimizing the code.I'm just starting to get the robot to work as I want ..
Error checking and reporting should go in from the start, how else will you find the cause of some errors in your code ?
Your CloseAll() function will not close all, your loop MUST count down not up: Loops and Closing or Deleting Orders
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I have a problem with my code. I'm trying to use two sma (4.9), and when they reach the intersection of two open a position, the first candle goes well but in others no achievement to come out. I'm doing wrong?
Another question is how when I have to make buy or sell, the theory says that when the 4 ma ma intersects the 9 top-down favorite. but I can not do that function.
someone can give me a hand.
thanks
this is the code