Hi, Its my very first post, I just tried to open a new thread but as i am a new member i couldn't
Anyway, as you said you will help for coding & programming of EA, well here i am...
I am using Tengri 1.4 EA & its a good EA with ONE single prob that It NEVER use "Stop Loss" yup... its creator programmed it to hold loss until your account completely wiped out
I tried to add stop loss feature but as i am almost noob... nop completely noob thats why i couldn't able to did...
So, this is what i want... see could you help me out
Whenever EA open a trade it will simultaneously set stop loss & this amount can be set on option...
Example:
Set Take Profit: 10
Set Take Loss: 20
like that...
And another feature I want to add "Trailing stop" & option will be their to modify
phew.... in my side, I wont able to do these... but as i seen in this forum... there are so many pro programmer... I think its too easy for you guys
btw... If you have this kind of good "Scalping M1" EA then plz share Thanks
Here Is the code of EA & I also attached the file
Anyway, as you said you will help for coding & programming of EA, well here i am...
I am using Tengri 1.4 EA & its a good EA with ONE single prob that It NEVER use "Stop Loss" yup... its creator programmed it to hold loss until your account completely wiped out
I tried to add stop loss feature but as i am almost noob... nop completely noob thats why i couldn't able to did...
So, this is what i want... see could you help me out
Whenever EA open a trade it will simultaneously set stop loss & this amount can be set on option...
Example:
Set Take Profit: 10
Set Take Loss: 20
like that...
And another feature I want to add "Trailing stop" & option will be their to modify
phew.... in my side, I wont able to do these... but as i seen in this forum... there are so many pro programmer... I think its too easy for you guys
btw... If you have this kind of good "Scalping M1" EA then plz share Thanks
Here Is the code of EA & I also attached the file
Attached File(s)
Silence2_02.mq4
6 KB
|
810 downloads
Attached File(s)
TENGRI 1.4.mq4
22 KB
|
861 downloads
Inserted Code
//TENGRI e , , , MagicNumber = 12345; // Silence2_02 , 1, // , // , - , // , . extern string af4 = " [email protected] [email protected]"; // , TF =1; 1-M1, 2-M5, 3-M15, 4-M30, 5-H1, 6-H4, 7-D1 // runik, extern string a = "------- 1- -------"; extern int TF_Op1 = 4; // , 1- , 1-1, 2-5, 3-15... extern string b = "-------Silence 1- -------"; extern int TFSilence1 = 2; // 1- Silence, 1-1, 2-5, 3-15... extern int PerSilence1 = 11; // Silence 1- extern int BuffSilence1= 220; //BuffSize Silence 1- extern int Sil_Level1 = 80; // Level Silence 1- extern string = "-------Silence -------"; extern int TFSilence2 = 3; // Silence, 1-1, 2-5, 3-15... extern int PerSilence2 = 12; // Silence extern int BuffSilence2= 96; //BuffSize Silence extern int Sil_Level2 = 80; // Level Silence extern string k = "------- -------"; extern int TF_MA2 = 3; // , 1-1, 2-5, 3-15... extern int Per_MA2 = 30; // MA extern string Block = "------- -------"; extern double PipStepExponent = 1; // extern double LotExponent1 = 1.70; // StepX extern double LotExponent2 = 2.08; // StepX extern int StepX = 5; //Step=5, 5 1, 5 2 extern double LotSize = 0.01; // 1- FixLot = true; extern bool FixLot = false; //true - , false - LotStep extern int LotStep = 2000; // . .. LotStep LotSize. 2000 0.01, 4000 0.02 extern int PipStep = 10; // . PipStepExponent Silence Level. extern int PipStep2 = 20; // . PipStepExponent Silence Level. extern int TP = 10; // extern int MaxTrades=10; // - extern string GeneralBlock = "------- -------"; extern bool Ostanov=true; // extern double Limit = 50; // ( ) extern int OpenNewTF = 1; // , 1-1, 2-5, 3-15... extern int OpenNextTF = 1; // , 1-1, 2-5, 3-15... extern int Povtor = 1; // extern string d = " "; extern bool CloseFriday=true; // true, false extern int CloseFridayHour=19; // extern string OfficialVariable = "------- -------"; extern string InformationOnChartString = "InformationOnChart - ()"; extern bool InformationOnChart = true; // , () extern int MagicNumber = 12345; // extern string af5 = "-===Kazakstan treider==- "; extern int LotDecimal = 0; datetime timeprevMIN=0; datetime timeprevMAX=0; int total, ticket, CountTrades; int mper[10]={0,1,5,15,30,60,240,1440,10080,43200}; bool LongTradeNew, ShortTradeNew; double Buy_NextLot,Sell_NextLot, Buy_NewLot, Sell_NewLot, Buy_LastLot, Sell_LastLot, Prof; string CommentTrades; //=========================== int init(){ LotDecimal = LotDecimal(); return(0);} //=========================== int deinit(){ return(0);} //============= = int ind_iOP; int ind_iOP2; //============= ======= int start(){ //== 1- ==================================================== double i_OP = iOpen (Symbol(), mper[TF_Op1], 0); // if (i_OP < Bid) ind_iOP = 1; // else if (i_OP > Bid) ind_iOP = - 1; // //====================================================================================== if (LotDecimal==0) LotDecimal = LotDecimal(); Information(); LongTradeNew=true; ShortTradeNew=true; //========= ================================================= if ((Ostanov)&&CountTrades("buy")>0&&CountTrades("sell")>0&&(Balance("buy","Balance")+Balance("sell", "Balance"))>=AccountEquity()/Limit){ int slippage=3; for (int i=OrdersTotal()-1; i>=0; i--) { if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break; if (OrderType()==OP_BUY ) OrderClose (OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),slippage); if (OrderType()==OP_SELL) OrderClose (OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),slippage); } } //====================================================================================== if(timeprevMIN!=iTime(NULL,mper[OpenNewTF],0)) { ticket=0; CountTrades = CountTrades("buy"); if(CloseFriday==true&&DayOfWeek()==5&&TimeCurrent()>=StrToTime(CloseFridayHour+":00"))return(0); // if (ind_iOP > 0) // , { if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 0) < 70.0) { if (iCustom(NULL, mper[TFSilence1], "Silence2_02", PerSilence1, BuffSilence1, 2, 0) < Sil_Level1) { if (CountTrades==0 && LongTradeNew==true) { CommentTrades = "TENGRI "+Symbol()+" - Buy "+(CountTrades+1); Buy_NewLot = NewLot("buy"); while(ticket<1) { Prof = Prof("buy"); Print(". . . ="+Symbol()+", ="+DoubleToStr(Buy_NewLot,2)+", ="+DoubleToStr(Ask,4)+" ="+DoubleToStr(Prof,4)+", ="+CommentTrades+" ="+MagicNumber); ticket = OrderSend(Symbol(),OP_BUY,Buy_NewLot,NormalizeDouble(Ask,Digits),3,0,Prof,CommentTrades,MagicNumber,0,Blue); if(ticket<1) {Print(": ",GetLastError()," "+(Povtor*60)+" ");Sleep(Povtor*60*1000);} RefreshRates(); } } } } } CountTrades = CountTrades("sell"); if(CloseFriday==true&&DayOfWeek()==5&&TimeCurrent()>=StrToTime(CloseFridayHour+":00"))return(0); // if (ind_iOP < 0) // , { if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 0) > 30.0) { if (iCustom(NULL, mper[TFSilence1], "Silence2_02", PerSilence1, BuffSilence1, 2, 0) < Sil_Level1) { if (CountTrades==0 && ShortTradeNew==true) { CommentTrades = "TENGRI "+Symbol()+" - Sell "+(CountTrades+1); Sell_NewLot = NewLot("sell"); while(ticket<1) { Prof = Prof("sell"); Print(". . . ="+Symbol()+", ="+DoubleToStr(Sell_NewLot,2)+", ="+DoubleToStr(Bid,4)+" ="+DoubleToStr(Prof,4)+", ="+CommentTrades+" ="+MagicNumber); ticket = OrderSend(Symbol(),OP_SELL,Sell_NewLot,NormalizeDouble(Bid,Digits),3,0,Prof,CommentTrades,MagicNumber,0,Red); if(ticket<1) {Print(": ",GetLastError()," "+(Povtor*60)+" ");Sleep(Povtor*60*1000);} RefreshRates(); } } } } } timeprevMIN=iTime(NULL,mper[OpenNewTF],0); } if(timeprevMAX!=iTime(NULL,mper[OpenNextTF],0)) { ticket=0; CountTrades = CountTrades("buy"); if (CountTrades>0 && NextOrder("buy")) { CommentTrades = "TENGRI "+Symbol()+" - Buy "+(CountTrades+1); Buy_NextLot = NextLot("buy"); while(ticket<1) { Print(". . . :"+Symbol()+", ="+DoubleToStr(Buy_NextLot,2)+", ="+DoubleToStr(Ask,4)+", ="+CommentTrades+", ="+MagicNumber); ticket = OrderSend(Symbol(),OP_BUY,Buy_NextLot,NormalizeDouble(Ask,Digits),3,0,0,CommentTrades,MagicNumber,0,Blue); if(ticket<1) {Print(": ",GetLastError()," "+(Povtor*60)+" ");Sleep(Povtor*60*1000);} else orrect("buy"); RefreshRates(); } } CountTrades = CountTrades("sell"); if (CountTrades>0 && NextOrder("sell")) { CommentTrades = "TENGRI "+Symbol()+" - Sell "+(CountTrades+1); Sell_NextLot = NextLot("sell"); while(ticket<1) { Print(". . . :"+Symbol()+", ="+DoubleToStr(Sell_NextLot,2)+", ="+DoubleToStr(Bid,4)+", ="+CommentTrades+", ="+MagicNumber); ticket = OrderSend(Symbol(),OP_SELL,Sell_NextLot,NormalizeDouble(Bid,Digits),3,0,0,CommentTrades,MagicNumber,0,Red); if(ticket<1) {Print(": ",GetLastError()," "+(Povtor*60)+" ");Sleep(Povtor*60*1000);} else orrect("sell"); RefreshRates(); } } timeprevMAX=iTime(NULL,mper[OpenNextTF],0); } return(0); } //+------------------------------------------------------------------+ double Prof(string OrdType) { double Zena=0; if (TP<MarketInfo(Symbol(),MODE_STOPLEVEL)) TP=MarketInfo(Symbol(),MODE_STOPLEVEL); if (OrdType=="buy")Zena=Ask+TP*Point; if (OrdType=="sell")Zena=Bid-TP*Point; return (Zena); } //+------------------------------------------------------------------+ void orrect(string OrdType) { int trade; double TP_all; double AveragePrice; AveragePrice = AveragePrice(OrdType); for(trade=OrdersTotal()-1;trade>=0;trade--) { OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) continue; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { //----- if (OrdType=="buy") { if(OrderType()==OP_BUY) { TP_all = AveragePrice+TP*Point; if (OrderTakeProfit() != TP_all) { Print(" . = "+DoubleToStr(AveragePrice,4)+", = "+DoubleToStr(TP,4)+" = "+DoubleToStr(TP_all,4)); OrderModify(OrderTicket(), AveragePrice, OrderStopLoss(), TP_all, 0, Yellow); } } } //---- if (OrdType=="sell") { if(OrderType()==OP_SELL) { TP_all = AveragePrice-TP*Point; if (OrderTakeProfit() != TP_all) { Print(" . = "+DoubleToStr(AveragePrice,4)+", = "+DoubleToStr(TP,4)+" = "+DoubleToStr(TP_all,4)); OrderModify(OrderTicket(), AveragePrice, OrderStopLoss(), TP_all, 0, Yellow); } } } //---- } } } //+------------------------------------------------------------------+ // double NewLot(string OrdType) { double tLots; double minlot = MarketInfo(Symbol(), MODE_MINLOT); if (OrdType=="buy") { if (FixLot) tLots = LotSize; else tLots = NormalizeDouble(LotSize * NormalizeDouble(AccountEquity()/LotStep,0), LotDecimal); } if (OrdType=="sell") { if (FixLot) tLots = LotSize; else tLots = NormalizeDouble(LotSize * NormalizeDouble(AccountEquity()/LotStep,0), LotDecimal); } if(tLots < minlot) tLots = minlot; return(tLots); } //+------------------------------------------------------------------+ // double NextLot(string OrdType){ double tLots; int st_P=CountTrades(OrdType); if (OrdType=="buy"){ if (st_P >= StepX) tLots = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent2, LotDecimal); else tLots = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent1, LotDecimal); } if (OrdType=="sell"){ if (st_P >= StepX) tLots = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent2, LotDecimal); else tLots = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent1, LotDecimal); } return(tLots); } //+------------------------------------------------------------------+ // bool NextOrder(string OrdType) { double MA_30 = iMA(Symbol(), mper[TF_MA2], Per_MA2, 0, 0, PRICE_CLOSE, 0); bool NextOrd = false; int PipStepEX; if (OrdType=="buy"&&MA_30<Bid) { if(iCustom(NULL, mper[TFSilence2], "Silence2_02", PerSilence2, BuffSilence2, 2, 0) < Sil_Level2) PipStepEX = NormalizeDouble(PipStep*MathPow(PipStepExponent,CountTrades(OrdType)),0); else PipStepEX = NormalizeDouble(PipStep2*MathPow(PipStepExponent,CountTrades(OrdType)),0); if (FindLastOrder(OrdType, "Price") - Ask >= PipStepEX * Point && CountTrades(OrdType)<MaxTrades) { { NextOrd = TRUE; } } } if (OrdType=="sell"&&MA_30>Bid) { if(iCustom(NULL, mper[TFSilence2], "Silence2_02", PerSilence2, BuffSilence2, 2, 0) < Sil_Level2) PipStepEX = NormalizeDouble(PipStep*MathPow(PipStepExponent,CountTrades(OrdType)),0); else PipStepEX = NormalizeDouble(PipStep2*MathPow(PipStepExponent,CountTrades(OrdType)),0); if (Bid - FindLastOrder(OrdType, "Price") >= PipStepEX * Point && CountTrades(OrdType)<MaxTrades) { { NextOrd = TRUE; } } } return(NextOrd); } //+------------------------------------------------------------------+ // double FindLastOrder(string OrdType, string inf) { double OrderPrice; double LastLot; int trade, oldticketnumber=0; for(trade=OrdersTotal()-1;trade>=0;trade--) { OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) continue; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { //---- if (OrdType=="buy") { if(OrderType()==OP_BUY) { if(OrderTicket()>oldticketnumber) { OrderPrice=OrderOpenPrice(); LastLot = OrderLots(); oldticketnumber=OrderTicket(); } } } //---- if (OrdType=="sell") { if(OrderType()==OP_SELL) { if(OrderTicket()>oldticketnumber) { OrderPrice=OrderOpenPrice(); LastLot = OrderLots(); oldticketnumber=OrderTicket(); } } } //---- } } if (inf=="Price") return(OrderPrice); if (inf=="Lots") return(LastLot); } //+------------------------------------------------------------------+ // int CountTrades(string OrdType) { int count=0; int trade; for(trade=OrdersTotal()-1;trade>=0;trade--) { OrderSelect(trade,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) continue; if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { //---- if (OrdType == "buy") { if(OrderType()==OP_BUY) count++; } //---- if (OrdType == "sell") { if(OrderType()==OP_SELL) count++; } //---- } } return(count); } //+------------------------------------------------------------------+ // double AveragePrice(string OrdType) { double AveragePrice=0; double Count=0; int trade; for(trade=OrdersTotal()-1;trade>=0;trade--) { OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) continue; if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { //----- if (OrdType == "buy") { if(OrderType()==OP_BUY) { AveragePrice=AveragePrice+OrderOpenPrice()*OrderLots(); Count=Count + OrderLots(); } } //---- if (OrdType == "sell") { if(OrderType()==OP_SELL) { AveragePrice=AveragePrice+OrderOpenPrice()*OrderLots(); Count=Count + OrderLots(); } } //---- } } AveragePrice=NormalizeDouble(AveragePrice/Count, Digits); return(AveragePrice); } //---------------------------------------------------------------------- // : void Information() { if (InformationOnChart) { Comment("" //+ "\n" + " TENGRI MARTINGEIL [email protected] "+Symbol() + "\n" + " ------------------------------------------------" + "\n" + " Broker: " + AccountCompany()+". AccountLeverage: 1:"+ DoubleToStr(AccountLeverage(), 0) + "\n" + " ------------------------------------------------" + "\n" + " Buy open -> "+CountTrades("buy")+" MaxTrades -> "+MaxTrades + "\n" + " Open balance: " + DoubleToStr(Balance("buy", "Balance"), 2) + "\n" + " Open lot: " + DoubleToStr(Balance("buy", "Lot"), 2) + "\n" + " ------------------------------------------------" + "\n" + " Sell open -> "+CountTrades("sell")+" MaxTrades -> "+MaxTrades + "\n" + " Open balance: " + DoubleToStr(Balance("sell", "Balance"), 2) + "\n" + " Open lot: " + DoubleToStr(Balance("sell", "Lot"), 2) + "\n" + " ------------------------------------------------" + "\n" + " Close Lock: " + DoubleToStr ((AccountEquity() / (Limit)), 2) + "\n" + " Balance Buy && Sell: " + DoubleToStr((Balance("buy", "Balance")+Balance("sell", "Balance")), 2) ); } } //--------------------------------------------------- // double Balance(string OrdType, string inf) { double result=0; int trade; for(trade=OrdersTotal()-1;trade>=0;trade--) { OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber) continue; if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber) { //----- if (OrdType == "buy") { if(OrderType()==OP_BUY) { if (inf=="Balance") result=result+OrderProfit()-OrderSwap()-OrderCommission(); if (inf=="Lot") result=result+OrderLots(); } } //---- if (OrdType == "sell") { if(OrderType()==OP_SELL) { if (inf=="Balance") result=result+OrderProfit()-OrderSwap()-OrderCommission(); if (inf=="Lot") result=result+OrderLots(); } } //---- } } return(result); } //--------------------------------------------------- double LotDecimal() { double steplot=MarketInfo(Symbol(), MODE_LOTSTEP); int LotsDigits = MathCeil(MathAbs(MathLog(steplot)/MathLog(10))); return(LotsDigits); } //=================================================== //
It is the dust where you came from & it is the dust where you shall return