EDIT:
Please see below for first post.
Changes requested:
1. Same request.
2. Same request.
3. Change this to simplify. Instead, just make current Pending Trade trail at the agreed upon stopGAP by X %. Make it so it is pending but trailing and updating every second/minute or so to follow. (I would think allowing it to breath and continue down might be a good idea, so giving it a variable to update every so many seconds would be AWESOME!)
4. If current candle is greater than x pips, then open 'hedge' position in opposite direction and send alert. If you are trading 5 minute chart and let's say 'x' pip bar comes in, then as soon as it exceeds 'x' (let's say '50') then it hedges current opposite positions and sends alert to you.
5. Same request.
6. Same request.
7. Same request.
8. A SECUREPROFIT update that no current orders are exited until at least minimum TP is estabilished. This would be by $. You would enter .00 for BE, or even negative number if wanted. This is needed because if L1, L2 and L3 are opened, but then it moves quickly and L4 follows it down 200 pips, then the TP for L4 will not recover for the first 3 levels.
Thanks for any assistance.
---------------------------------------------------------------------------------------------------
Hi,
I am no 'coder', but I do understand the code to a point (past life) but would never have the time or ability to do what I would like done.
I have been demo'ing several EA's and this EA seems to be the most profitable out of all of them thus far. (although these changes would allow me to trade smaller time-frame's and be hopefully more profitable!
This is a counter-trend strategy
And it enters stop orders at a 'gap' distance from current price. It already does quite a bit right, but if you trade on shorter time-frame's, it will not work unless you can move lightning quick when there is a big move.
Here are the enhancements that I am hoping someone can help me with:
1. OrdersToProtect - I would like an 'all' option so if you change the number of levels deep, it will automatically use the SecureProfitProtection to however many levels you have dynamically. I believe this is how this functions, but please feel free to educate me!
2. Ability to delete pending orders. Currently, a pending order is put in and once your L1 trade is established, if you delete a pending L2 trade, then it will close out your L1 trade as well and start you over on the martingale. But, I would like to keep the current functionality that if it is an open order and you close it, then it closes all pending and open orders for that currency.
3. This is similar to 2. except; If L1 trade is not opened (because it didn't fill the order gap), then the pending order will be updated to the new order entry location.
-- Currency is at 140.7 and it puts in an L1 trade (buy stop) at 140.75, but price does not retrace and continues down where it would normally enter L2 trade. Instead of entering L2 (with martingale x 2) when price hits 140.3, then it would just cancel/change the existing pending order (L1 in this instance) to the new price of say 140.35. If it continues to trend hard, then that order will not get opened up either and where it would normally enter L3 at say 139.9 it would move/change the L1 trade to 139.95
-- Another example if L1 were opened: L1 was entered at 100.00 even. Price goes up to 100.4 so it puts in a pending sell stop at 100.35 but price continues up to 100.7 where normally the L3 order would be opened (martingale x 3), but since the L2 order was not opened, then cancel the L2 trade, and leave the L3 (martingale 3x) so it can make its way back more quickly to pay off the existing order.
I am thinking the difference between these two makes it sound complicated but it isn't. I think having an option in the EA to turn this on/off would be good. I hope this makes sense.
4. No Trade if candle is greater than 'x'. If candle is greater than x pips, then no trading until candle reaches < specific size 'x'. I wonder how you incorporate this systematically though if you are already in the trade? hmmm.
5. Alerts:
-- Email and pop-up alerts (separate) for L2, L4, L6 or some other dynamic way to put in the levels of alerts. Maybe 3 text boxes asking what levels for alerts to be executed? box 1: 2 box 2: 5 box 3: 7
6. If Magic Number = 0, than dynamic
7. My broker "IAMFX" uses .005 increments or $500.00 or 5 cent (.05) as the smallest unit. But, for some reason, this only uses .01 as I think something is wrong. If there is a way to use the .005 increments as well, that would be awesome?
I hope this is clear as can be and I can explain in further detail. I believe this is a very profitable EA, but I think by adding this functionality that we will be making it even better.
Please see below for first post.
Changes requested:
1. Same request.
2. Same request.
3. Change this to simplify. Instead, just make current Pending Trade trail at the agreed upon stopGAP by X %. Make it so it is pending but trailing and updating every second/minute or so to follow. (I would think allowing it to breath and continue down might be a good idea, so giving it a variable to update every so many seconds would be AWESOME!)
4. If current candle is greater than x pips, then open 'hedge' position in opposite direction and send alert. If you are trading 5 minute chart and let's say 'x' pip bar comes in, then as soon as it exceeds 'x' (let's say '50') then it hedges current opposite positions and sends alert to you.
5. Same request.
6. Same request.
7. Same request.
8. A SECUREPROFIT update that no current orders are exited until at least minimum TP is estabilished. This would be by $. You would enter .00 for BE, or even negative number if wanted. This is needed because if L1, L2 and L3 are opened, but then it moves quickly and L4 follows it down 200 pips, then the TP for L4 will not recover for the first 3 levels.
Thanks for any assistance.
---------------------------------------------------------------------------------------------------
Hi,
I am no 'coder', but I do understand the code to a point (past life) but would never have the time or ability to do what I would like done.
I have been demo'ing several EA's and this EA seems to be the most profitable out of all of them thus far. (although these changes would allow me to trade smaller time-frame's and be hopefully more profitable!
This is a counter-trend strategy
Inserted Code
//+------------------------------------------------------------------+ //| Sixth Screen EA v3.2z(Zurathustra MOD) based on the original | //| 4H Sixth EA ver3.MQ4 by an unknown author. | //| Zurathustra | //| | //| This EA finds the range of the highest high and the lowest low | //| of the past X bars of the current chart. It then splits the | //| into six equal parts and places a counter trend BUY or SELL | //| order based on the highest or lowest value. TP is determined by| //| the range and dividing by 7(Highest High - Lowest Low) / 7). | //| | //| Zurathustra | //| If you found this EA to be usefull or profitable, please make a | //| donation via paypal to [email protected] | //+------------------------------------------------------------------+ extern string sb="--TRADE SETTING--"; extern double Lots = 0.005; // We start with this lots number extern int BarCount = 45; //80 on 30 minute, 240 on 4H extern string ABF="If 1 trade A line, if 2 trade B line"; extern double ABFlag = 2; // If 1 trade A line, if 2 trade B line extern int BarTF = 5; extern string comments = "Sixth"; extern double multiply= 1.5; extern int MaxTrades= 6; // Maximum number of orders to open extern int StopLoss = 1000; // StopLoss extern double StopGapRatio = 1.0; // Ratio of StopGap to Pips (Layer Distance) extern bool MyMoneyProfitTarget=False; extern double My_Money_Profit_Target=50; extern int TrailingStop = 0;// Pips to trail the StopLoss extern string MM="--MOney Management--"; // (from order 2, not from first order extern string MMSwicth="if one the lots size will increase based on account size"; extern int mm=0; // if one the lots size will increase based on account size extern string riskset="risk to calculate the lots size (only if mm is enabled)"; extern int risk=1; // risk to calculate the lots size (only if mm is enabled) extern string accounttypes="0 if Normal Lots, 1 for mini lots, 2 for micro lots"; extern int AccountType=2; // 0 if Normal Lots, 1 for mini lots, 2 for micro lots extern string magicnumber="--MAgic No--"; extern int MagicNumber= 0; // Magic number for the orders placed extern string so="--CUTLOSS SETTING--"; extern bool SecureProfitProtection=True; extern string SP="If profit made is bigger than SecureProfit we close the orders"; extern int SecureProfit=5; // If profit made is bigger than SecureProfit we close the orders extern string OTP="Number of orders to enable the account protection"; extern int OrderstoProtect=5; // Number of orders to enable the account protection extern string ASP="if one will check profit from all symbols, if cero only this symbol"; extern bool AllSymbolsProtect=False; // if one will check profit from all symbols, if cero only this symbol extern string EP="if true, then the expert will protect the account equity to the percent specified"; extern bool EquityProtection=False; // if true, then the expert will protect the account equity to the percent specified extern string AEP="percent of the account to protect on a set of trades"; extern int AccountEquityPercentProtection=90; // percent of the account to protect on a set of trades extern string AMP="if true, then the expert will use money protection to the USD specified"; extern bool AccountMoneyProtection=False; extern double AccountMoneyProtectionValue=3000.00; string s1="--seting berapa jam dia nak open order--"; bool UseHourTrade = false; int FromHourTrade = 0; int ToHourTrade = 23; extern string TradingTime="--trading time setting--"; extern bool UseTradingHours = false; extern bool TradeAsianMarket = true; extern int StartHour1 = 0; // Start trades after time extern int StopHour1 = 3; // Stop trading after time extern bool TradeEuropeanMarket = true; extern int StartHour2 = 9; // Start trades after time extern int StopHour2 = 11; // Stop trading after time extern bool TradeNewYorkMarket = true; extern int StartHour3 = 15; // Start trades after time extern int StopHour3 = 17; // Stop trading after time extern bool TradeOnFriday=True; extern string OtherSetting="--Others Setting--"; int OrdersTimeAlive=0; // in seconds extern string reverse="if one the desition to go long/short will be reversed"; extern bool ReverseCondition=False; // if one the desition to go long/short will be reversed extern string limitorder="if true, instead open market orders it will open limit orders "; extern bool SetLimitOrders=False; // if true, instead open market orders it will open limit orders int Manual=0; // If set to one then it will not open trades automatically color ArrowsColor=White; // color for the orders arrows extern color A_High = Red; extern color B_High = White; extern color Center = Red; extern color B_Low = White; extern color A_Low = Red; int OpenOrdersBasedOn=16; // Method to decide if we start long or short bool ContinueOpening=True; int OpenOrders=0, cnt=0; int MarketOpenOrders=0, LimitOpenOrders=0; int slippage=5; double sl=0, tp=0; double BuyPrice=0, SellPrice=0; double lotsi=0, mylotsi=0; int mode=0, myOrderType=0, myOrderTypetmp=0; double LastPrice=0; int PreviousOpenOrders=0; double Profit=0; int LastTicket=0, LastType=0; double LastClosePrice=0, LastLots=0; double Pivot=0; double PipValue=0; bool Reversed=False; double tmp=0; double iTmpH=0; double iTmpL=0; datetime NonTradingTime[][2]; bool FileReaded=false; string dateLimit = "2030.01.12 23:00"; int CurTimeOpeningFlag=0; datetime LastOrderOpenTime=0; bool YesStop; int TakeProfit = 0; // Profit Goal for the latest order opened int Pips = 0; // Distance in Pips from one order to another double StopGap = 0; // distance of stop order from the line double SellLevel = 0;// Sell limit double BuyLevel = 0; // Enter buy limit here.If 0 no trades taken //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators ObjectCreate("A Low",1,0,TimeCurrent(),Low[BarCount]); ObjectSet("A Low",OBJPROP_COLOR,A_Low); ObjectSet("A Low",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("A Low",OBJPROP_WIDTH,2); ObjectSet("A Low",OBJPROP_FONTSIZE,20); ObjectCreate("B Low",1,0,TimeCurrent(),Low[BarCount]); ObjectSet("B Low",OBJPROP_COLOR,B_Low); ObjectSet("B Low",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("B Low",OBJPROP_WIDTH,2); ObjectCreate("Center",1,0,TimeCurrent(),Low[BarCount]); ObjectSet("Center",OBJPROP_COLOR,Center); ObjectSet("Center",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("Center",OBJPROP_WIDTH,2); ObjectCreate("B High",1,0,TimeCurrent(),Low[BarCount]); ObjectSet("B High",OBJPROP_COLOR,B_High); ObjectSet("B High",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("B High",OBJPROP_WIDTH,2); ObjectCreate("A High",1,0,TimeCurrent(),Low[BarCount]); ObjectSet("A High",OBJPROP_COLOR,A_High); ObjectSet("A High",OBJPROP_STYLE,STYLE_SOLID); ObjectSet("A High",OBJPROP_WIDTH,2); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- DeleteAllObjects(); //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int cnt=0; bool result; string text=""; string version=""; // skrip masa trading if (UseTradingHours) { YesStop = true; // Check trading Asian Market if (TradeAsianMarket) { if (StartHour1 > 18) { // Check broker that uses Asian open before 0:00 if (Hour() >= StartHour1) YesStop = false; if (!YesStop) { if (StopHour1 < 24) { if ( Hour() <= StopHour1) YesStop = false; } // These cannot be combined even though the code looks the same if (StopHour1 >=0) { if ( Hour() <= StopHour1) YesStop = false; } } } else { if (Hour() >= StartHour1 && Hour() <= StopHour1) YesStop = false; } } if (YesStop) { // Check trading European Market if (TradeEuropeanMarket) { if (Hour() >= StartHour2 && Hour() <= StopHour2) YesStop = false; } } if (YesStop) { // Check trading European Market if (TradeNewYorkMarket) { if (Hour() >= StartHour3 && Hour() <= StopHour3) YesStop = false; } } if (YesStop) { // Comment ("Trading has been stopped as requested - wrong time of day"); return (0); } } // skrip masa trading if (AccountType==0) { if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000); } else { lotsi=Lots; } } if (AccountType==1) { // then is mini if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000)/10; } else { lotsi=Lots; } } if (AccountType==2) { if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000)/100; } else { lotsi=Lots; } } if (lotsi<0.01) lotsi=0.01; if (lotsi>100) lotsi=100; OpenOrders=0; MarketOpenOrders=0; LimitOpenOrders=0; for(cnt=0;cnt<OrdersTotal();cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber) { if (OrderType()==OP_BUY || OrderType()==OP_SELL) { MarketOpenOrders++; LastOrderOpenTime=OrderOpenTime(); } if (OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYLIMIT ||OrderType()==OP_SELLSTOP || OrderType()==OP_BUYSTOP) LimitOpenOrders++; OpenOrders++; } } } if (OpenOrders<1) { if (!TradeOnFriday && DayOfWeek()==5) { Comment("TradeOnfriday is False"); return(0); } } PipValue=MarketInfo(Symbol(),MODE_TICKVALUE); if (PipValue==0) { PipValue=5; } if (AccountMoneyProtection && AccountBalance()-AccountEquity()>=AccountMoneyProtectionValue) { text = text + "nClosing all orders and stop trading because account money protection activated.."; Print("Closing all orders and stop trading because account money protection activated.. Balance: ",AccountBalance()," Equity: ",AccountEquity()); PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; return(0); } ////aku masukkan time if (UseHourTrade){ if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) { text = text + "nORDER TELAH DI TUTUP KERANA MASA DAH TAMAT."; Print("ORDER HAS REACHED CLOSING TIME ",AccountProfit()," EKUITI: ",AccountEquity()); PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; return(0); } } //set my profit for one Day if (MyMoneyProfitTarget && AccountProfit()>= My_Money_Profit_Target) { text = text + "nClosing all orders and stop trading because mymoney profit target reached.."; Print("Closing all orders and stop trading because mymoney profit target reached.. Profit: ",AccountProfit()," Equity: ",AccountEquity()); PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; return(0); } // Account equity protection if (EquityProtection && AccountEquity()<=AccountBalance()*AccountEquityPercentProtection/100) { text = text + "nClosing all orders and stop trading because account money protection activated."; Print("Closing all orders and stop trading because account money protection activated. Balance: ",AccountBalance()," Equity: ", AccountEquity()); //Comment("Closing orders because account equity protection was triggered. Balance: ",AccountBalance()," Equity: ", AccountEquity()); //OrderClose(LastTicket,LastLots,LastClosePrice,slippage,Orange); PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; return(0); } // if dont trade at fridays then we close all if (!TradeOnFriday && DayOfWeek()==5) { PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; text = text +"nClosing all orders and stop trading because TradeOnFriday protection."; Print("Closing all orders and stop trading because TradeOnFriday protection."); } // Orders Time alive protection if (OrdersTimeAlive>0 && CurTime() - LastOrderOpenTime>OrdersTimeAlive) { PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; text = text + "nClosing all orders because OrdersTimeAlive protection."; Print("Closing all orders because OrdersTimeAlive protection."); } if (PreviousOpenOrders>OpenOrders) { for(cnt=OrdersTotal()-1;cnt>=0;cnt--) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { mode=OrderType(); if ((OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber) || AllSymbolsProtect) { if (mode==OP_BUY || mode==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,ArrowsColor); return(0); } } } } for(cnt=0;cnt<OrdersTotal();cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { mode=OrderType(); if ((OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber) || AllSymbolsProtect) { if (mode==OP_SELLLIMIT || mode==OP_BUYLIMIT || mode==OP_BUYSTOP || mode==OP_SELLSTOP) { OrderDelete(OrderTicket()); return(0); } } } } } PreviousOpenOrders=OpenOrders; if (OpenOrders>=MaxTrades) { ContinueOpening=False; } else { ContinueOpening=True; } if (LastPrice==0) { for(cnt=0;cnt<OrdersTotal();cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { mode=OrderType(); if (OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber) { LastPrice=OrderOpenPrice(); if (mode==OP_BUY||mode==OP_BUYSTOP ) { myOrderType=2; } if (mode==OP_SELL||mode==OP_SELLSTOP) { myOrderType=1;} } } } } // SecureProfit protection //if (SecureProfitProtection && MarketOpenOrders>=(MaxTrades-OrderstoProtect) // Modified to make easy to understand if (SecureProfitProtection && MarketOpenOrders>=OrderstoProtect) { Profit=0; for(cnt=0;cnt<OrdersTotal();cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { if ((OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) || AllSymbolsProtect) Profit=Profit+OrderProfit(); } } if (Profit>=SecureProfit) { text = text + "nClosing orders because account protection with SecureProfit was triggered."; Print("Closing orders because account protection with SeureProfit was triggered. Balance: ",AccountBalance()," Equity: ", AccountEquity()," Profit: ",Profit); PreviousOpenOrders=OpenOrders+1; ContinueOpening=False; return(0); } } myOrderTypetmp=3; switch (OpenOrdersBasedOn) { case 16: myOrderTypetmp=OpenOrdersBasedOnSTOCH(); break; default: myOrderTypetmp=OpenOrdersBasedOnSTOCH(); break; } if (OpenOrders<1 && Manual==0) { myOrderType=myOrderTypetmp; if (ReverseCondition) { if (myOrderType==1) { myOrderType=2; } else { if (myOrderType==2) { myOrderType=1; } } } } if (ReverseCondition) { if (myOrderTypetmp==1) { myOrderTypetmp=2; } else { if (myOrderTypetmp==2) { myOrderTypetmp=1; } } } // if we have opened positions we take care of them cnt=OrdersTotal()-1; while(cnt>=0) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==false) break; if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) // && Reversed==False) { //Print("Ticket ",OrderTicket()," modified."); if (OrderType()==OP_SELL) { if (TrailingStop>0) { if ((OrderOpenPrice()-OrderClosePrice())>=(TrailingStop*Point+Pips*Point)) { if (OrderStopLoss()>(OrderClosePrice()+TrailingStop*Point)) { result=OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()+TrailingStop*Point,OrderClosePrice()-TakeProfit*Point-TrailingStop*Point,0,Purple); if(result!=TRUE) Print("LastError = ", GetLastError()); else OrderPrint(); return(0); } } } } if (OrderType()==OP_BUY) { if (TrailingStop>0) { if ((OrderClosePrice()-OrderOpenPrice())>=(TrailingStop*Point+Pips*Point)) { if (OrderStopLoss()<(OrderClosePrice()-TrailingStop*Point)) { result=OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()-TrailingStop*Point,OrderClosePrice()+TakeProfit*Point+TrailingStop*Point,0,ArrowsColor); if(result!=TRUE) Print("LastError = ", GetLastError()); else OrderPrint(); return(0); } } } } } cnt--; } if (!IsTesting()) { if (myOrderType==3 && OpenOrders<1) { text=text + "nTIADA KONDISI UTK OPEN ORDER"; } //else { text= text + "n "; } // Comment("HARGA TERAKHIR=",LastPrice," OPEN ODER YG LEPAS=",PreviousOpenOrders,"nBUKA LAGI=",ContinueOpening," JENISORDER=",myOrderType,"nLOT=",lotsi,text); } if (OpenOrders<1) OpenMarketOrders(); else if (SetLimitOrders) OpenLimitOrders(); else OpenMarketOrders(); //---- return(0); } //+------------------------------------------------------------------+ void OpenMarketOrders() { int cnt=0; if (myOrderType==1 && ContinueOpening ) { if ((Bid-LastPrice)>= (Pips+StopGap)*Point || OpenOrders<1) { SellPrice= Bid - StopGap*Point; LastPrice=0; if (TakeProfit==0) { tp=0; } else { tp=SellPrice-TakeProfit*Point; } if (StopLoss==0) { sl=0; } else { sl=SellPrice+StopLoss*Point; } if (OpenOrders!=0) { mylotsi=lotsi; for(cnt=0;cnt<OpenOrders;cnt++) { if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*multiply,2); } else { mylotsi=NormalizeDouble(mylotsi*multiply,2); } } } else { mylotsi=lotsi; } if (mylotsi>50) { mylotsi=49; } { OrderSend(Symbol(),OP_SELLSTOP,mylotsi,SellPrice,slippage,sl,tp,comments,MagicNumber,0,ArrowsColor); return(0); } } // Sleep(6000); ////aku letak // RefreshRates(); } if (myOrderType==2 && ContinueOpening) { if ((LastPrice-Ask)>=(Pips+StopGap)*Point || OpenOrders<1) { BuyPrice=Ask+StopGap*Point; LastPrice=0; if (TakeProfit==0) { tp=0; } else { tp=BuyPrice+TakeProfit*Point; } if (StopLoss==0) { sl=0; } else { sl=BuyPrice-StopLoss*Point; } if (OpenOrders!=0) { mylotsi=lotsi; for(cnt=0;cnt<OpenOrders;cnt++) { if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*multiply,2); } else { mylotsi=NormalizeDouble(mylotsi*multiply,2); } } } else { mylotsi=lotsi; } if (mylotsi>50) { mylotsi=49; } { OrderSend(Symbol(),OP_BUYSTOP,mylotsi,BuyPrice,slippage,sl,tp,comments,MagicNumber,0,ArrowsColor); return(0); } } } } void OpenLimitOrders() { int cnt=0; //int StopLoss = valueS; if (myOrderType==1 && ContinueOpening) { //if ((Bid-LastPrice)>=Pips*Point || OpenOrders<1) //{ //SellPrice=Bid; SellPrice = LastPrice+Pips*Point; LastPrice=0; if (TakeProfit==0) { tp=0; } else { tp=SellPrice-TakeProfit*Point; } if (StopLoss==0) { sl=0; } else { sl=SellPrice+StopLoss*Point; } if (OpenOrders!=0) { mylotsi=lotsi; for(cnt=0;cnt<OpenOrders;cnt++) { if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*multiply,2); } else { mylotsi=NormalizeDouble(mylotsi*multiply,2); } } } else { mylotsi=lotsi; } if (mylotsi>100) { mylotsi=100; } OrderSend(Symbol(),OP_SELLLIMIT,mylotsi,SellPrice,slippage,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor); return(0); //} } if (myOrderType==2 && ContinueOpening) { //if ((LastPrice-Ask)>=Pips*Point || OpenOrders<1) //{ //BuyPrice=Ask; BuyPrice=LastPrice-Pips*Point; LastPrice=0; if (TakeProfit==0) { tp=0; } else { tp=BuyPrice+TakeProfit*Point; } if (StopLoss==0) { sl=0; } else { sl=BuyPrice-StopLoss*Point; } if (OpenOrders!=0) { mylotsi=lotsi; for(cnt=0;cnt<OpenOrders;cnt++) { if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*multiply,2); } else { mylotsi=NormalizeDouble(mylotsi*multiply,2); } } } else { mylotsi=lotsi; } if (mylotsi>100) { mylotsi=100; } OrderSend(Symbol(),OP_BUYLIMIT,mylotsi,BuyPrice,slippage,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor); return(0); //} } } void DeleteAllObjects() { int obj_total=ObjectsTotal(); string name; for(int i=0;i<obj_total;i++) { name=ObjectName(i); if (name!="") ObjectDelete(name); } ObjectDelete("FLP_txt"); ObjectDelete("P_txt"); } // 16 int OpenOrdersBasedOnSTOCH() { int myOrderType=3; //---- lot setting and modifications //Sell order double value = High[iHighest(NULL,BarTF,MODE_HIGH,BarCount,1)] - Low[iLowest(NULL,BarTF,MODE_LOW,BarCount,1)]; //value top of the chart - value bottom double sixth = value/6; double value2 = High[iHighest(NULL,0,MODE_HIGH,BarCount,1)] - Low[iLowest(NULL,0,MODE_LOW,BarCount,1)]; double sixth2 = value2/6; double valueSTEMP = (value*(MathPow(10,Digits))); double valueS = NormalizeDouble(valueSTEMP,0); double sixthSTEMP = (sixth*(MathPow(10,Digits))); double sixthS = NormalizeDouble(sixthSTEMP,0); double seventh = value/7; double seventhSTEMP = (seventh*(MathPow(10,Digits))); double seventhS = NormalizeDouble(seventhSTEMP,0); TakeProfit = seventhS; Pips = sixthS; double StopGapTEMP = (Pips * StopGapRatio); StopGap = NormalizeDouble(StopGapTEMP,0); double SellLevel = High[iHighest(NULL,BarTF,MODE_HIGH,BarCount,1)] - (sixth * ABFlag); double BuyLevel = Low[iLowest(NULL,BarTF,MODE_LOW,BarCount,1)] + (sixth * ABFlag); if(ObjectFind("A High")==-1)init(); //Comment(ObjectFind("sixth")); ObjectMove("A Low",0,TimeCurrent(),Low[iLowest(NULL,0,MODE_LOW,BarCount,1)]+sixth2); ObjectMove("B Low",0,TimeCurrent(),Low[iLowest(NULL,0,MODE_LOW,BarCount,1)]+sixth2+sixth2); ObjectMove("Center",0,TimeCurrent(),Low[iLowest(NULL,0,MODE_LOW,BarCount,1)]+sixth2+sixth2+sixth2); ObjectMove("B High",0,TimeCurrent(),Low[iLowest(NULL,0,MODE_LOW,BarCount,1)]+sixth2+sixth2+sixth2+sixth2); ObjectMove("A High",0,TimeCurrent(),Low[iLowest(NULL,0,MODE_LOW,BarCount,1)]+sixth2+sixth2+sixth2+sixth2+sixth2); RefreshRates(); Comment("TF SELECTED=",BarTF,"; BAR COUNT=",BarCount,"n","High = ", High[iHighest(NULL,BarTF,MODE_HIGH,BarCount,1)], "n", "Low = ", Low[iLowest(NULL,BarTF,MODE_LOW,BarCount,1)], "n", "High to Low = ", (valueS), " pips", "n" ,"Take Profit = ", (seventhS), " pips", "n", "Line Pip Distance = ", (sixthS), " pips", "n" ,"Sell Level = ", SellLevel, "n" ,"Buy Level = ", BuyLevel, "n" ,"Stop Gap = ", StopGap); int digits = MarketInfo(Symbol(),MODE_DIGITS); if( Bid > (SellLevel+StopGap*Point) > 0) { myOrderType=1;//SELL } //buy order if( Bid < (BuyLevel-StopGap*Point) > 0) { myOrderType=2;//BUY } return(myOrderType); }
And it enters stop orders at a 'gap' distance from current price. It already does quite a bit right, but if you trade on shorter time-frame's, it will not work unless you can move lightning quick when there is a big move.
Here are the enhancements that I am hoping someone can help me with:
1. OrdersToProtect - I would like an 'all' option so if you change the number of levels deep, it will automatically use the SecureProfitProtection to however many levels you have dynamically. I believe this is how this functions, but please feel free to educate me!
2. Ability to delete pending orders. Currently, a pending order is put in and once your L1 trade is established, if you delete a pending L2 trade, then it will close out your L1 trade as well and start you over on the martingale. But, I would like to keep the current functionality that if it is an open order and you close it, then it closes all pending and open orders for that currency.
3. This is similar to 2. except; If L1 trade is not opened (because it didn't fill the order gap), then the pending order will be updated to the new order entry location.
-- Currency is at 140.7 and it puts in an L1 trade (buy stop) at 140.75, but price does not retrace and continues down where it would normally enter L2 trade. Instead of entering L2 (with martingale x 2) when price hits 140.3, then it would just cancel/change the existing pending order (L1 in this instance) to the new price of say 140.35. If it continues to trend hard, then that order will not get opened up either and where it would normally enter L3 at say 139.9 it would move/change the L1 trade to 139.95
-- Another example if L1 were opened: L1 was entered at 100.00 even. Price goes up to 100.4 so it puts in a pending sell stop at 100.35 but price continues up to 100.7 where normally the L3 order would be opened (martingale x 3), but since the L2 order was not opened, then cancel the L2 trade, and leave the L3 (martingale 3x) so it can make its way back more quickly to pay off the existing order.
I am thinking the difference between these two makes it sound complicated but it isn't. I think having an option in the EA to turn this on/off would be good. I hope this makes sense.
4. No Trade if candle is greater than 'x'. If candle is greater than x pips, then no trading until candle reaches < specific size 'x'. I wonder how you incorporate this systematically though if you are already in the trade? hmmm.
5. Alerts:
-- Email and pop-up alerts (separate) for L2, L4, L6 or some other dynamic way to put in the levels of alerts. Maybe 3 text boxes asking what levels for alerts to be executed? box 1: 2 box 2: 5 box 3: 7
6. If Magic Number = 0, than dynamic
7. My broker "IAMFX" uses .005 increments or $500.00 or 5 cent (.05) as the smallest unit. But, for some reason, this only uses .01 as I think something is wrong. If there is a way to use the .005 increments as well, that would be awesome?
I hope this is clear as can be and I can explain in further detail. I believe this is a very profitable EA, but I think by adding this functionality that we will be making it even better.
We are our own best indicator.