Hi there everyone… thanks for taking a look!
I’m trying to learn to program and I have a grand plan for what I want to do, but I need to take baby steps to first learn what I’m doing and second to make this thing work!
Currently, I’m wanting to start the trade manually and have the EA automate the Stop Loss, Trailing Stop, and Take Profit. But for the sake of simplicity… I just want it to automate the Stop Loss but for some reason the code is not changing the order or anything... I heard of problems with doing partial automation??? Is this true?
Could someone take a look at my code and tell me what I'm doing wrong?
I really appreciate your help!
I’m trying to learn to program and I have a grand plan for what I want to do, but I need to take baby steps to first learn what I’m doing and second to make this thing work!
Currently, I’m wanting to start the trade manually and have the EA automate the Stop Loss, Trailing Stop, and Take Profit. But for the sake of simplicity… I just want it to automate the Stop Loss but for some reason the code is not changing the order or anything... I heard of problems with doing partial automation??? Is this true?
Could someone take a look at my code and tell me what I'm doing wrong?
Inserted Code
extern double SL = 10; extern double TS = 10; extern double Protect = 0; extern double Initial = 0; extern double Profit = 0; int i; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int cnt, ticket, total; { total=OrdersTotal(); for (cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(OrderStopLoss()<0) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid-Point*SL,OrderTakeProfit(),0,CLR_NONE); return(0); } } } if(OrderType()==OP_SELL) { if(OrderStopLoss()<0) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid+Point*SL,OrderTakeProfit(),0,CLR_NONE); return(0); } } } } //---- return(0); }
I really appreciate your help!