Disliked{quote} HOW CAN YOU ADD THE CODE HERE IN FF IN THE FORMAT OF SCROLLED PAGE LIKE THE PICTURE HEREIgnored
Cheers!
Free mql4 programming 65 replies
What is the best way to get started learning MQL4 programming language? 20 replies
MQL4 programming help needed - simply combining indicators 0 replies
MQL4 Language Most Recent Version is it updated beyond the tutorial on the mql4 websi 6 replies
Disliked*Edit: I found a few things I needed to fix, getting an OrderModify error 1 now. I'll keep at it, thanks anyone that has already looked at this. **One more edit, code updated Ok. I have been reading, copying, pasting, compiling, and pulling hair out. I have done some of this myself, and some I have stolen from other EA generators. The only thing I can get it to do is open one trade. It will not close it, and no others will open. Interestingly, actually determining the buy and sell points is the easy part. Setting up the order and close seem significantly...Ignored
//+------------------------------------------------------------------+ //| Ultimate EA.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Zexchange" #property link "don't have one yet" #property version "1.00" #property strict extern int MagicNumber =2222; extern double Lots =0.1; extern double StopLoss =10; extern double TakeProfit =10; extern double TrailingStop =50; extern int Slippage =3; //RSI Values extern int RSIperiod =14; extern int RSIbuy =30; extern int RSIsell =70; extern int RSIbuyclose =70; extern int RSIsellclose =30; //CCI Values extern int CCIperiod =14; extern int CCIbuy =-250; extern int CCIsell =250; extern int CCIbuyclose =250; extern int CCIsellclose=-250; int buyTicket=0; int sellTicket=0; bool runawaybuy=false; //Stop concurrent buy losses bool runawaysell=false; //Stop concurrent sell losses //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { TakeProfit=convertPips(TakeProfit); TrailingStop=convertPips(TrailingStop); StopLoss=convertPips(StopLoss); Print("*****Here we go!*****"); //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double RSI = iRSI(NULL,0,RSIperiod,0,0); //RSI Value double CCI = iCCI(NULL,0,CCIperiod,0,0); //CCI Value double TP =0; double SL =0; int TotalOrdersCount=0; /* Place the closeOrder() outside TotalOrdersCount()==0 so it will be executed. If you have totalOrderCount > 0, it won't place any new order and won't process the close logic. */ closeOrder(runawaybuy,runawaysell); //+------------------------------------------------------------------+ //| Do while Loop | //+------------------------------------------------------------------+ if( TotalOrdersCount()==0 ) { //+------------------------------------------------------------------+ //| Buy Order | //+------------------------------------------------------------------+ if ((RSI<RSIbuy)&&(CCI<CCIbuy)&&!runawaybuy) //buy calculation and runaway check { buyTicket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"Buy order",MagicNumber,0,clrGreen); Print("Order number is ",buyTicket); if(buyTicket>0) { if(TakeProfit>0) TP=Ask+TakeProfit; if(StopLoss>0) SL=Ask-StopLoss; OrderSelect(buyTicket,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(SL,Digits),NormalizeDouble(TP,Digits),0,Green); runawaysell=true; //runaway reset } return; } //+------------------------------------------------------------------+ //| Sell order | //+------------------------------------------------------------------+ if ((RSI>RSIsell)&&(CCI>CCIsell)&&!runawaysell) //sell calculation and runaway check { sellTicket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"Sell order",MagicNumber,0,clrRed); Print("Order number is ",sellTicket); if(sellTicket>0) { if(TakeProfit>0) TP=Bid+TakeProfit; if(StopLoss>0) SL=Bid-StopLoss; OrderSelect(sellTicket, SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(SL,Digits),NormalizeDouble(TP,Digits),0,clrGreen); runawaybuy =true; //runaway reset } return; } } //+------------------------------------------------------------------+ //| End Loop | //+------------------------------------------------------------------+ } void closeOrder(bool &runawaybuy, bool &runawaysell){ double RSI = iRSI(NULL,0,RSIperiod,0,0); //RSI Value double CCI = iCCI(NULL,0,CCIperiod,0,0); //CCI Value //+------------------------------------------------------------------+ //| Order Close Loop | //+------------------------------------------------------------------+ for(int cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUY) { //+------------------------------------------------------------------+ //| Buy Close | //+------------------------------------------------------------------+ if ((RSI>RSIbuyclose)&&(CCI>CCIbuyclose)) { Print("Buy close"); OrderClose(OrderTicket(),Lots,Bid,Slippage,clrGreen); if(OrderClosePrice()>OrderOpenPrice()) //losing trade check { runawaybuy=false; //running away } return; } } //+------------------------------------------------------------------+ //| Sell Close | //+------------------------------------------------------------------+ if(OrderType()==OP_SELL) { { if((RSI<RSIsellclose)&&(CCI<CCIsellclose)) { Print("Sell close"); OrderClose(OrderTicket(),Lots,Bid,Slippage,clrRed); if(OrderClosePrice()<OrderOpenPrice()) //losing trade check { runawaysell=false; //running away } return; } } } } } } int TotalOrdersCount() { int ticket=0; for(int i=0;i<OrdersTotal();i++) { OrderSelect(i,SELECT_BY_POS ,MODE_TRADES); if (OrderMagicNumber()==MagicNumber) ticket++; } return (ticket); } //+------------------------------------------------------------------+ //| Errors | //+------------------------------------------------------------------+ /* int Fun_Error(int Error) // Function of processing errors { switch(Error) { // Not crucial errors case 4: Alert("Trade server is busy. Trying once again.."); Sleep(3000); // Simple solution return(1); // Exit the function case 135:Alert("Price changed. Trying once again.."); RefreshRates(); // Refresh rates return(1); // Exit the function case 136:Alert("No prices. Waiting for a new tick.."); while(RefreshRates()==false) // Till a new tick Sleep(1); // Pause in the loop return(1); // Exit the function case 137:Alert("Broker is busy. Trying once again.."); Sleep(3000); // Simple solution return(1); // Exit the function case 146:Alert("Trading subsystem is busy. Trying once again.."); Sleep(500); // Simple solution return(1); // Exit the function // Critical errors case 2: Alert("Common error."); return(0); // Exit the function /* case 5: Alert("Old terminal version."); Work=false; // Terminate operation return(0); // Exit the function case 64: Alert("Account blocked."); Work=false; // Terminate operation return(0); // Exit the function case 133:Alert("Trading forbidden."); return(0); // Exit the function case 134:Alert("Not enough money to execute operation."); return(0); // Exit the function default: Alert("Error occurred: ",Error); // Other variants return(0); // Exit the function } } } //+------------------------------------------------------------------+ */ double convertPips(double pips) { //4 ot 2 decimal currency/instrument pairs hence a 4 digit broker if(MathMod(Digits,2)==0){ return pips/MathPow(10,Digits); } //5 or 3 decimal currency/instrument pairs hence a 5 digit broker else{ return NormalizeDouble((pips/MathPow(10,Digits))*10,Digits); } }
double convertPips(double pips) { //4 ot 2 decimal currency/instrument pairs hence a 4 digit broker if(MathMod(Digits,2)==0){ return pips/MathPow(10,Digits); } //5 or 3 decimal currency/instrument pairs hence a 5 digit broker else{ return NormalizeDouble((pips/MathPow(10,Digits))*10,Digits); }
TakeProfit=convertPips(TakeProfit); TrailingStop=convertPips(TrailingStop); StopLoss=convertPips(StopLoss);
if( TotalOrdersCount()==0 ) { }
Dislikedhi yousername onehelp...is this right i want to show the price on right side of the rectange for top and bottom... so i did this but price is not coming even it shown no error... what could i do ObjectCreate(0,FIB_SUP1, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), B, Time[0], B1); ObjectSetInteger (0,FIB_SUP1, OBJPROP_BACK,1 ); ObjectSetInteger (0,FIB_SUP1, OBJPROP_COLOR, C'0,52,62'); ObjectSetInteger(0,FIB_SUP1, OBJPROP_STYLE, 2); ObjectCreate(FIB_SUP1,OBJ_ARROW,0,Time[0],B); ObjectSet(FIB_SUP1,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE); ObjectSet(FIB_SUP1,OBJPROP_COLOR,C'0,52,62');...Ignored
string FIB_SUP1="TEST"; string FIB_SUP2="TEST2"; void OnStart() { ObjectCreate(0,FIB_SUP1, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), Close[5], Time[0], Close[0]); ObjectSetInteger (0,FIB_SUP1, OBJPROP_BACK,1 ); ObjectSetInteger (0,FIB_SUP1, OBJPROP_COLOR, C'0,52,62'); ObjectSetInteger(0,FIB_SUP1, OBJPROP_STYLE, 2); ObjectCreate(FIB_SUP2,OBJ_ARROW,0,Time[0],Close[0]); ObjectSet(FIB_SUP2,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE); ObjectSet(FIB_SUP2,OBJPROP_COLOR,C'0,52,62'); }
Disliked{quote} You tried to create a new object with the same name. That is why the first object is not shown because it got replaced. string FIB_SUP1="TEST"; string FIB_SUP2="TEST2"; void OnStart() { ObjectCreate(0,FIB_SUP1, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), Close[5], Time[0], Close[0]); ObjectSetInteger (0,FIB_SUP1, OBJPROP_BACK,1 ); ObjectSetInteger (0,FIB_SUP1, OBJPROP_COLOR, C'0,52,62'); ObjectSetInteger(0,FIB_SUP1, OBJPROP_STYLE, 2); ObjectCreate(FIB_SUP2,OBJ_ARROW,0,Time[0],Close[0]); ObjectSet(FIB_SUP2,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);...Ignored
Disliked{quote} ok but for the sup1 is rectangel but need 2 lines top and bottom i tried to plot like this pic.. for that what i can do {image}Ignored
DislikedThanks yousername, I appreciate the help. I fixed what you suggested, got it to place trades, and my computer crashed =D. I am pretty sure it was due to the # of orders it was trying to place, I'll need to add code to only place once per candle. It seems to be a common question so I won't keep asking you fix it . Your videos are a great help!Ignored
Disliked{quote} ok but for the sup1 is rectangel but need 2 lines top and bottom i tried to plot like this pic.. for that what i can do {image}Ignored
//+------------------------------------------------------------------+ //| test.mq4 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ string FIB_SUP1="TEST"; string FIB_SUP2="TEST2"; string FIB_SUP3="TEST3"; void OnStart() { ObjectCreate(0,FIB_SUP1, OBJ_RECTANGLE, 0, iTime(NULL, PERIOD_D1, 0), Close[5], Time[0], Close[0]); ObjectSetInteger (0,FIB_SUP1, OBJPROP_BACK,1 ); ObjectSetInteger (0,FIB_SUP1, OBJPROP_COLOR, C'0,52,62'); ObjectSetInteger(0,FIB_SUP1, OBJPROP_STYLE, 2); ObjectCreate(FIB_SUP2,OBJ_ARROW,0,Time[0],Close[0]); ObjectSet(FIB_SUP2,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE); ObjectSet(FIB_SUP2,OBJPROP_COLOR,C'0,52,62'); ObjectCreate(FIB_SUP3,OBJ_ARROW,0,Time[0],Close[5]); ObjectSet(FIB_SUP3,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE); ObjectSet(FIB_SUP3,OBJPROP_COLOR,C'0,52,62'); }
Disliked{quote} are you dumb or annoying? Hire some one to make it for you if no one in FF doesn't want to do what you're requested.Ignored
Disliked{quote} thank you for such kindness..... i wont ask anymore here after ... to learn purpose i asked here... there i shared my idea too... for my small requests... i understand clearly how people are .... really hearty thanks... god shown me the real face of some people often to me...Ignored
DislikedHi yousername, Perhaps this is slightly pedantic, but I think as one learns to code that there should be some instruction of best practices. For example the use of the keywords extern and input. There's rarely a case that user-defined constants need to be changed by the program, and therefore it is best practice to use the keyword 'input' instead of 'extern' in order to prevent an accidental and potentially money-threatening modification. In fact, extern should only be used in the rare and specific case where modification of the user defined variable...Ignored
Disliked{quote} Hi Nicholishen, Thanks for the feedback. yeah I agree it is important to know the difference between extern and input because it could affect the whole thing. For instance if the extern variable got changed during the program flly and suddenly the program got restarted, the changed variable will be gone. It requires some complicated logic in order to retain the changes variable, one is by using global variable. Also when extern variable got changed, the changes won't be reflected to the indicator input or EA properties. For most cases, it...Ignored
Disliked{quote} No you didn't learn anything. If you did and wanted to learn something you should not unsubscribe.Ignored
Disliked{quote} yes i didnt learn anything..... see the pic i got mail from coding person.. and he refund the amount with out doing the work and the time gap is june 23rd to till today... sep 19th... 3 months almost... i didnt get work even though i was send money... ok. first understand others problems... simply you can say arrange coder and do pay..... but now if i get and paid also i didnt get work.. so what is wrong when i ask help where the possible ways are before me... if i being here means your rudeness will go to peak level and that is not good...Ignored