Hi,
I have a stop gap entry order system created from the Nanningbob 60x90 thread. http://www.forexfactory.com/showthread.php?t=150293
I have created a concept that will utilize this ea, but I realize that I have gotten a long way away from where I need to be due to my lack of programming skills.
Basically, you take both long & short with a stop gap entry calculated by the sixths indicator (see code or thread). You tell it that you want to enter if market goes up OR down 'X'% of distance measured from top to bottom which you want on the 4H chart to be around 10-15 pips. This makes it dynamic upon current market conditions!
It is a basic breakout on both sides. This concept utilizes Martingale and since you are trading off the 4HR chart, you will have a small trailing stop taking 10 pips at a time (or more, on testing I had a TS using MPTM that gave me 180 pips!)
Right now I have the following code running twice on each currency. One takes trades long if under the ABFLAG, the other takes shorts if under ABFLAG and VICE/VERSA. One has ReverseCondition=false to make this happen.
This WILL NOT work because as it adds positions and crosses the midpoint, it will 'double down' each position counter-trending until the martingale takes out the biggest losing trade. (I also tried hardcoding one EA to take only long, other to take only short all the time but it keeps deleting the pending orders over and over.... so...)
Doing this, I realize how difficult this is to explain what it is I am doing.
Basically, I just need an EA to:
1. Take long and short at a distance of stop gap % per the last so many bars on the 4H chart. NO INDICATOR FILTERS WHATSOEVER. This would also have a deadline to get filled in seconds, otherwise it closes out and opens a new one or it could just be a trailing pending order (either way). I would set it to like 60 seconds so in a fast moving market it doesn't get in the wrong direction.
2. Trailing stop on L1 trades ONLY that is configurable by me.
3. Martingaling up to 'X' levels
4. Take Profit for later (higher) levels to make back enough to cover previous level bad trades + 'X' dollars
5. One EA to handle both long and short management instead of doing two separate charts etc..
6. Visual presentation showing what is going on in the chart.
I have tested my faulty version and it was extremely profitable, however, when the currency crossed the midpoint and they were both now going long or short, the drawdown would grow substantially. I backtested this (22 currencies, FOREX.COM and IBFX MICRO) over 1.5 years and I never blew up w/ 6 levels, but AUDNZD was unprofitable on both...
The basic concept is that you are going in both directions. One trade will typically be a loser with a drawdown. This would be your L1 for instance and as it moves in the other direction, you are 'pecking' away and making money as it goes up with a Trailing stop and % stop entries.
As it moves away further, you will have L2, L3, L4 level trades all multiplied, however, most of this will be offset by your profit in the trading going the opposite direction. THE COOL THING ABOUT THIS IS THAT THE BROKER CAN'T KEEP YOU FROM MAKING YOUR LITTLE PIPS, PIPS, PIPS AS IT MOVES. If the price reverses, you win... The benefit too is that you are trading off the 4-hour chart and that you can keep small contracts invested (.01 micro or .001 nano) and make 1.00 here and a 1.00 there a whole lot of times as the market ranges. When it moves big and trends, you are in the trend as well.
It isn't perfect, but I do see this as an interesting strategy to play with! PLEASE HELP ME.
I have a stop gap entry order system created from the Nanningbob 60x90 thread. http://www.forexfactory.com/showthread.php?t=150293
I have created a concept that will utilize this ea, but I realize that I have gotten a long way away from where I need to be due to my lack of programming skills.
Basically, you take both long & short with a stop gap entry calculated by the sixths indicator (see code or thread). You tell it that you want to enter if market goes up OR down 'X'% of distance measured from top to bottom which you want on the 4H chart to be around 10-15 pips. This makes it dynamic upon current market conditions!
It is a basic breakout on both sides. This concept utilizes Martingale and since you are trading off the 4HR chart, you will have a small trailing stop taking 10 pips at a time (or more, on testing I had a TS using MPTM that gave me 180 pips!)
Right now I have the following code running twice on each currency. One takes trades long if under the ABFLAG, the other takes shorts if under ABFLAG and VICE/VERSA. One has ReverseCondition=false to make this happen.
This WILL NOT work because as it adds positions and crosses the midpoint, it will 'double down' each position counter-trending until the martingale takes out the biggest losing trade. (I also tried hardcoding one EA to take only long, other to take only short all the time but it keeps deleting the pending orders over and over.... so...)
Doing this, I realize how difficult this is to explain what it is I am doing.
Basically, I just need an EA to:
1. Take long and short at a distance of stop gap % per the last so many bars on the 4H chart. NO INDICATOR FILTERS WHATSOEVER. This would also have a deadline to get filled in seconds, otherwise it closes out and opens a new one or it could just be a trailing pending order (either way). I would set it to like 60 seconds so in a fast moving market it doesn't get in the wrong direction.
2. Trailing stop on L1 trades ONLY that is configurable by me.
3. Martingaling up to 'X' levels
4. Take Profit for later (higher) levels to make back enough to cover previous level bad trades + 'X' dollars
5. One EA to handle both long and short management instead of doing two separate charts etc..
6. Visual presentation showing what is going on in the chart.
I have tested my faulty version and it was extremely profitable, however, when the currency crossed the midpoint and they were both now going long or short, the drawdown would grow substantially. I backtested this (22 currencies, FOREX.COM and IBFX MICRO) over 1.5 years and I never blew up w/ 6 levels, but AUDNZD was unprofitable on both...
The basic concept is that you are going in both directions. One trade will typically be a loser with a drawdown. This would be your L1 for instance and as it moves in the other direction, you are 'pecking' away and making money as it goes up with a Trailing stop and % stop entries.
As it moves away further, you will have L2, L3, L4 level trades all multiplied, however, most of this will be offset by your profit in the trading going the opposite direction. THE COOL THING ABOUT THIS IS THAT THE BROKER CAN'T KEEP YOU FROM MAKING YOUR LITTLE PIPS, PIPS, PIPS AS IT MOVES. If the price reverses, you win... The benefit too is that you are trading off the 4-hour chart and that you can keep small contracts invested (.01 micro or .001 nano) and make 1.00 here and a 1.00 there a whole lot of times as the market ranges. When it moves big and trends, you are in the trend as well.
It isn't perfect, but I do see this as an interesting strategy to play with! PLEASE HELP ME.
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 string magicnumber="--MAgic No--"; extern int MagicNumber= 2; // Magic number for the orders placed extern double Lots = 0.01; // We start with this lots number extern int BarCount = 260; //80 on 30 minute, 240 on 4H extern string ABF="If 1 trade A line, if 2 trade B line"; extern double ABFlag = 6; // If 1 trade A line, if 2 trade B line extern int BarTF = 240; extern string comments = "2"; extern double multiply= 1.5; extern int MaxTrades= 6; // Maximum number of orders to open extern int StopLoss = 3600; // StopLoss extern double StopGapRatio = 0.05; // 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 so="--CUTLOSS SETTING--"; extern bool SecureProfitProtection=True; extern string SP="If profit made is bigger than SecureProfit we close the orders"; extern int SecureProfit=20; // 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=6; // 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=true; // 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=1; } if (mode==OP_SELL||mode==OP_SELLSTOP) { myOrderType=2;} } } } } // 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=2;//SELL } //buy order if( Bid < (BuyLevel-StopGap*Point) > 0) { myOrderType=2;//BUY } return(myOrderType); }
We are our own best indicator.