Good morning.
I would like to know how to make this EA puts me a default TP and SL 20 pips as this code to run it I have already put a SL and TP but I wish that when I place an order me automatically 20 pips to put the stop loss and take profit on then I can directly change to the screen my SL and TP can you change it?
cordially
french
Bonjour.
je voudrais savoir comment faire pour que cet EA me mette par defaut un TP et un SL de 20 pips car ce code pour fonctionner il faut deja que je mette un SL et un TP mais moi je voudrais que quand je place un ordre automatiquement il me mette 20 pips pour le stop loss et pour le take profit ensuite je peut modifier directement a l'ecran mes SL et TP pouvez vous le modifier ?
cordialement
I would like to know how to make this EA puts me a default TP and SL 20 pips as this code to run it I have already put a SL and TP but I wish that when I place an order me automatically 20 pips to put the stop loss and take profit on then I can directly change to the screen my SL and TP can you change it?
cordially
french
Bonjour.
je voudrais savoir comment faire pour que cet EA me mette par defaut un TP et un SL de 20 pips car ce code pour fonctionner il faut deja que je mette un SL et un TP mais moi je voudrais que quand je place un ordre automatiquement il me mette 20 pips pour le stop loss et pour le take profit ensuite je peut modifier directement a l'ecran mes SL et TP pouvez vous le modifier ?
cordialement
Inserted Code
//+------------------------------------------------------------------+ //| VisualTrading.mq4 | //| Dmitry Yakovlev, Russia,Omsk, WM R865705290089 | //| [email protected] | //+------------------------------------------------------------------+ #property copyright "Dmitry Yakovlev, Russia,Omsk, WM R865705290089" #property link "[email protected]" #import "shell32.dll" //Connect a dll (provided with Windows) int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); #import "user32.dll" int MessageBoxA(int hWnd ,string lpText,string lpCaption,int uType); #import extern color OpenColor=Aqua; extern color TakeProfitColor=Lime; extern color StopLossColor=Red; extern bool lShowTargets=true; int cnt=0; int awh[]; void init() { int i=0,j=0; string n; DeleteHistory(); for(i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderSymbol()==Symbol())) { n=OrderSymbol()+"_"+DoubleToStr(OrderTicket(),0)+"_"+DoubleToStr(Period(),0); if(ObjectFind(n+"open")==-1) {ObjectCreate(n+"open",OBJ_HLINE,awh[j],Time[0],OrderOpenPrice()); ObjectSet(n+"open",OBJPROP_COLOR,OpenColor);} if(OrderStopLoss()!=0 && ObjectFind(n+"stop")==-1) {ObjectCreate(n+"stop",OBJ_HLINE,awh[j],Time[0],OrderStopLoss()); ObjectSet(n+"stop",OBJPROP_COLOR,StopLossColor);} if(OrderTakeProfit()!=0 && ObjectFind(n+"take")==-1) {ObjectCreate(n+"take",OBJ_HLINE,awh[j],Time[0],OrderTakeProfit()); ObjectSet(n+"take",OBJPROP_COLOR,TakeProfitColor);} } DeleteLabels(); ShowLabels(); cnt=OrdersTotal(); } void deinit() { string n; int i=0,j=0; for(i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderSymbol()==Symbol())) { n=OrderSymbol()+"_"+DoubleToStr(OrderTicket(),0)+"_"+DoubleToStr(Period(),0); if(ObjectFind(n+"open")!=-1) ObjectDelete(n+"open"); if(ObjectFind(n+"stop")!=-1) ObjectDelete(n+"stop"); if(ObjectFind(n+"take")!=-1) ObjectDelete(n+"take"); } DeleteHistory(); for(i=0;i<30;i++) { ObjectDelete(Symbol()+DoubleToStr(Period(),0)+"topen"+i); ObjectDelete(Symbol()+DoubleToStr(Period(),0)+"ttake"+i); ObjectDelete(Symbol()+DoubleToStr(Period(),0)+"tstop"+i); } DeleteLabels(); } void start() { string n; int i=0,j=0; if(cnt!=OrdersTotal()) init(); DeleteHistory(); DeleteLabels(); double popen, ptake, pstop; for(i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderSymbol()==Symbol())) { n=OrderSymbol()+"_"+DoubleToStr(OrderTicket(),0)+"_"+DoubleToStr(Period(),0); if((ObjectFind(n+"stop")==-1) && (OrderStopLoss()!=0)) //if(MessageBox("Убрать стоп лосс?","Убрать?",4)==6) //{ // OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderTakeProfit(),0,CLR_NONE); // ObjectDelete(n+"stop"); // continue; //} //else { ObjectCreate(n+"stop",OBJ_HLINE,awh[j],Time[0],OrderStopLoss()); ObjectSet(n+"stop",OBJPROP_COLOR,StopLossColor); } if((ObjectFind(n+"take")==-1) && (OrderTakeProfit()!=0)) //if(MessageBox("Убрать тейк профит?","Убрать?",4)==6) //{ // OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),0,0,CLR_NONE); // ObjectDelete(n+"take"); // continue; //} //else { ObjectCreate(n+"take",OBJ_HLINE,awh[j],Time[0],OrderTakeProfit()); ObjectSet(n+"take",OBJPROP_COLOR,TakeProfitColor); } if(ObjectFind(n+"open")==-1) if(MessageBox("Закрыть ордер "+OrderTicket()+"?","Закрыть?",4)==6) { if(OrderType()==OP_BUY) popen=Bid; if(OrderType()==OP_SELL) popen=Ask; OrderClose(OrderTicket(),OrderLots(),popen,3,CLR_NONE); OrderDelete(OrderTicket()); ObjectDelete(n+"take"); ObjectDelete(n+"stop"); continue; } else { ObjectCreate(n+"open",OBJ_HLINE,awh[j],Time[0],OrderOpenPrice()); ObjectSet(n+"open",OBJPROP_COLOR,OpenColor); } popen=NormalizeDouble(ObjectGet(n+"open",OBJPROP_PRICE1),Digits); ptake=NormalizeDouble(ObjectGet(n+"take",OBJPROP_PRICE1),Digits); pstop=NormalizeDouble(ObjectGet(n+"stop",OBJPROP_PRICE1),Digits); //Comment(""); if((popen!=NormalizeDouble(OrderOpenPrice(),Digits)) || (pstop!=NormalizeDouble(OrderStopLoss(),Digits)) || (ptake!=NormalizeDouble(OrderTakeProfit(),Digits))) { if((OrderType()!=OP_BUY) && (OrderType()!=OP_SELL) && (NormalizeDouble(popen,Digits)!=NormalizeDouble(OrderOpenPrice(),Digits))) { OrderModify(OrderTicket(),popen,OrderStopLoss(),OrderTakeProfit(),0,CLR_NONE);//continue; } if(((OrderType()==OP_BUY) || (OrderType()==OP_SELL)) && (NormalizeDouble(popen,Digits)!=NormalizeDouble(OrderOpenPrice(),Digits))) { ObjectSet(n+"open",OBJPROP_PRICE1,OrderOpenPrice());//continue; } if((OrderType()==OP_BUY) && (NormalizeDouble(pstop,Digits)>Bid)) { ObjectSet(n+"stop",OBJPROP_PRICE1,OrderStopLoss());//continue; } if((OrderType()==OP_SELL) && (NormalizeDouble(pstop,Digits)<Ask)) { ObjectSet(n+"stop",OBJPROP_PRICE1,OrderStopLoss());//continue; } if((NormalizeDouble(ptake,Digits)!=NormalizeDouble(OrderTakeProfit(),Digits)) && (OrderTakeProfit()!=0) && (ptake!=0)) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ptake,0,CLR_NONE);//continue; } if((NormalizeDouble(pstop,Digits)!=NormalizeDouble(OrderStopLoss(),Digits)) && (OrderStopLoss()!=0) && (pstop!=0)) { OrderModify(OrderTicket(),OrderOpenPrice(),pstop,OrderTakeProfit(),0,CLR_NONE);//continue; } } } ShowLabels(); if(lShowTargets) fShowTargets(); WindowRedraw(); } void DeleteHistory() { string n; int i=0,j=0; for(i=0;i<OrdersHistoryTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && (OrderSymbol()==Symbol())) { n=OrderSymbol()+"_"+DoubleToStr(OrderTicket(),0)+"_"+DoubleToStr(Period(),0); if(ObjectFind(n+"open")!=-1) ObjectDelete(n+"open"); if(ObjectFind(n+"stop")!=-1) ObjectDelete(n+"stop"); if(ObjectFind(n+"take")!=-1) ObjectDelete(n+"take"); } } void fShowTargets() { int i=0, prof_pts=0, ticket=0; double dist_stop_pts, dist_stop; double dist_take_pts, dist_take; double pr=(Ask+Bid)/2, prof=0; datetime CT=Time[0]+Period()*60*(WindowBarsPerChart()/20+2); // time shift double CP=5*Point; // price shift int FS=10; // font size color prof_clr=Blue; string txt=""; //------------------------------------------------------------- for(i=0;i<10;i++) { ObjectDelete(Symbol()+DoubleToStr(Period(),0)+"topen"+i); ObjectDelete(Symbol()+DoubleToStr(Period(),0)+"ttake"+i); ObjectDelete(Symbol()+DoubleToStr(Period(),0)+"tstop"+i); } for(i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { // <---считаем RefreshRates(); prof=OrderProfit(); if(OrderType()==OP_BUY || OrderType()==3 || OrderType()==4) { pr=Bid; prof_pts=pr/Point-OrderOpenPrice()/Point; } if(OrderType()==OP_SELL || OrderType()==2 || OrderType()==5) { pr=Ask; prof_pts=OrderOpenPrice()/Point-pr/Point; } prof_clr=Blue; if(prof_pts<0) prof_clr=Red; if(prof_pts>0) prof_clr=Green; ObjectCreate(Symbol()+DoubleToStr(Period(),0)+"topen"+i,OBJ_TEXT,0,CT,OrderOpenPrice()+CP); txt=""; if(OrderType()==0 || OrderType()==1) txt=" ("+DoubleToStr(MathAbs(prof),2)+"$)"; ObjectSetText(Symbol()+DoubleToStr(Period(),0)+"topen"+i,DoubleToStr(MathAbs(prof_pts),0)+txt,FS,"Arial",prof_clr); dist_take_pts=0;dist_take=0; if(OrderTakeProfit()!=0) { dist_take_pts=MathAbs(pr/Point-OrderTakeProfit()/Point); txt=DoubleToStr(dist_take_pts,0); dist_take_pts=MathAbs(OrderOpenPrice()/Point-OrderTakeProfit()/Point); txt=txt+"("+DoubleToStr(dist_take_pts,0)+"/"+DoubleToStr(dist_take_pts*OrderLots()*10,0)+"$)"; ObjectCreate(Symbol()+DoubleToStr(Period(),0)+"ttake"+i,OBJ_TEXT,0,CT,OrderTakeProfit()+CP); ObjectSetText(Symbol()+DoubleToStr(Period(),0)+"ttake"+i,txt,FS,"Arial",Green); } dist_stop_pts=0;dist_stop=0; if(OrderStopLoss()!=0) { dist_stop_pts=MathAbs(pr/Point-OrderStopLoss()/Point); txt=DoubleToStr(dist_stop_pts,0); dist_stop_pts=MathAbs(OrderOpenPrice()/Point-OrderStopLoss()/Point); txt=txt+"("+DoubleToStr(dist_stop_pts,0)+"/"+DoubleToStr(dist_stop_pts*OrderLots()*10,0)+"$)"; ObjectCreate(Symbol()+DoubleToStr(Period(),0)+"tstop"+i,OBJ_TEXT,0,CT,OrderStopLoss()+CP); ObjectSetText(Symbol()+DoubleToStr(Period(),0)+"tstop"+i,txt,FS,"Arial",Red); } // рисуем---> } } void DeleteLabels() { int i=0; string n=""; int t=Time[WindowFirstVisibleBar()]; for(i=0;i<OrdersHistoryTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==Symbol()) { n=OrderSymbol()+Period()+DoubleToStr(OrderTicket(),0); ObjectDelete(n+"stoplbl"); ObjectDelete(n+"takelbl"); } for(i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol()) { n=OrderSymbol()+Period()+DoubleToStr(OrderTicket(),0); ObjectDelete(n+"stoplbl"); ObjectDelete(n+"takelbl"); } } void ShowLabels() { int i=0; string n=""; int t=Time[WindowFirstVisibleBar()-(WindowBarsPerChart()/20)]; //Comment(WindowBarsPerChart()); for(i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol()) { n=OrderSymbol()+Period()+DoubleToStr(OrderTicket(),0); ObjectDelete(n+"stoplbl"); ObjectCreate(n+"stoplbl",OBJ_TEXT,0,t,OrderStopLoss()); ObjectSetText(n+"stoplbl","#"+DoubleToStr(OrderTicket(),0)+" stop",8,"Arial",StopLossColor); ObjectDelete(n+"takelbl"); ObjectCreate(n+"takelbl",OBJ_TEXT,0,t,OrderTakeProfit()); ObjectSetText(n+"takelbl","#"+DoubleToStr(OrderTicket(),0)+" take",8,"Arial",TakeProfitColor); } }