Re: Simple Expert Advisors (EA's) for MT4

33
Zacaka wrote:hi guys,

if there EA or indicator samples like my trend magic please share here

got headache already

thanks
Hi Zacaka
As per my poor knowledge trend magic is same to old super trend (cci-atr),use some newest super trend indicator there are so many versions with a lot of options ad flexibility and form your EA or search for some already made ea based on super trend but experts can better guide you.
Indicator is just a tool.

Use it only if it can benefit you. Leave it if you don't know how to use it optimally.


Re: Simple Expert Advisors (EA's) for MT4

38
mladen wrote:Use calls to buffers 0 and 1 for that
Thanks Mladen... Ive already got that from you, master

Code: Select all

void GoMartingale()
{
         int      iCount      =  0;
         double   LastOP      =  0;
         double   LastLots    =  0;
         bool     LastIsBuy   =  FALSE;
         int      iTotalBuy   =  0;
         int      iTotalSell  =  0;
         int      Spread=0;
   
         Spread= MarketInfo(Symbol(), MODE_SPREAD);
         
         for(iCount=0;iCount<OrdersTotal();iCount++)
         {
                    
           OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);
           
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
           {
               if(LastOP==0) {LastOP=OrderOpenPrice();}
               if(LastOP>OrderOpenPrice()) {LastOP=OrderOpenPrice();}
               if(LastLots<OrderLots()) {LastLots=OrderLots();}
               LastIsBuy=TRUE;
               iTotalBuy++;
               
               if(iTotalBuy==MaxTrade) {return(0);}
           }
           if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
           {
               if(LastOP==0) {LastOP=OrderOpenPrice();}
               if(LastOP<OrderOpenPrice()) {LastOP=OrderOpenPrice();}         
               if(LastLots<OrderLots()) {LastLots=OrderLots();}
               LastIsBuy=FALSE;
               iTotalSell++;
               
               
               if(iTotalBuy==MaxTrade) {return(0);}
           }
         
         }      
         
         
         if(LastIsBuy)
         {
            if(Bid<=LastOP-(Spread*SetPoint)-(PipStep*SetPoint))
            {
               OrderSend(Symbol(), OP_BUY, Multiply*LastLots, Ask, Slippage, 0, Ask+TakeProfit*SetPoint, EAComment, EAMagicNumber);   
               ModifyTP();
               LastIsBuy=FALSE;
               return(0);
            }
         }
         
         else if(!LastIsBuy)
         {
            if(Ask>=LastOP+(Spread*SetPoint)+(PipStep*SetPoint))
            {
               OrderSend(Symbol(), OP_SELL, Multiply*LastLots, Bid, Slippage, 0, Bid-TakeProfit*SetPoint, EAComment, EAMagicNumber);           
               ModifyTP();
               return(0);
            }
         }
}
void ModifyTP()
{
   int      iCount=0;
   double   NewTP=0;
        
         for(iCount=0;iCount<OrdersTotal();iCount++)
         {
           
           OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);
       
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
           {
               if(NewTP==0) {NewTP=OrderTakeProfit();}
               if(NewTP>OrderTakeProfit()) {NewTP=OrderTakeProfit();}
               
           }
           
           if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
           {
               if(NewTP==0) {NewTP=OrderTakeProfit();}
               if(NewTP<OrderTakeProfit()) {NewTP=OrderTakeProfit();}         
           }
                     
         }
         for(iCount=0;iCount<OrdersTotal();iCount++)
         {
           
           OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES);
       
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
           {
               OrderModify(OrderTicket(), OrderLots(), 0, NewTP, 0);
           }
           
           if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
           {
               OrderModify(OrderTicket(), OrderLots(), 0, NewTP, 0);
           }             
         
         }        
}
Can u help me to add stoploss for that script? If I want only 2 level martingale, then if hit the stoploss it will be all close (same magic number) or open hedging with same lot...
btw, if open hedging... can the new open position make a new magicnumber after hedging or must be close the ea and re-start ea so they will create with new magicnumber?

Thanks

Re: Simple Expert Advisors (EA's) for MT4

39
Zacaka wrote:
Thanks Mladen... Ive already got that from you, master

Code: Select all

 void GoMartingale() { int iCount = 0; double LastOP = 0; double LastLots = 0; bool LastIsBuy = FALSE; int iTotalBuy = 0; int iTotalSell = 0; int Spread=0; Spread= MarketInfo(Symbol(), MODE_SPREAD); for(iCount=0;iCount<OrdersTotal();iCount++) { OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber) { if(LastOP==0) {LastOP=OrderOpenPrice();} if(LastOP>OrderOpenPrice()) {LastOP=OrderOpenPrice();} if(LastLots<OrderLots()) {LastLots=OrderLots();} LastIsBuy=TRUE; iTotalBuy++; if(iTotalBuy==MaxTrade) {return(0);} } if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber) { if(LastOP==0) {LastOP=OrderOpenPrice();} if(LastOP<OrderOpenPrice()) {LastOP=OrderOpenPrice();} if(LastLots<OrderLots()) {LastLots=OrderLots();} LastIsBuy=FALSE; iTotalSell++; if(iTotalBuy==MaxTrade) {return(0);} } } if(LastIsBuy) { if(Bid<=LastOP-(Spread*SetPoint)-(PipStep*SetPoint)) { OrderSend(Symbol(), OP_BUY, Multiply*LastLots, Ask, Slippage, 0, Ask+TakeProfit*SetPoint, EAComment, EAMagicNumber); ModifyTP(); LastIsBuy=FALSE; return(0); } } else if(!LastIsBuy) { if(Ask>=LastOP+(Spread*SetPoint)+(PipStep*SetPoint)) { OrderSend(Symbol(), OP_SELL, Multiply*LastLots, Bid, Slippage, 0, Bid-TakeProfit*SetPoint, EAComment, EAMagicNumber); ModifyTP(); return(0); } } } void ModifyTP() { int iCount=0; double NewTP=0; for(iCount=0;iCount<OrdersTotal();iCount++) { OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber) { if(NewTP==0) {NewTP=OrderTakeProfit();} if(NewTP>OrderTakeProfit()) {NewTP=OrderTakeProfit();} } if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber) { if(NewTP==0) {NewTP=OrderTakeProfit();} if(NewTP<OrderTakeProfit()) {NewTP=OrderTakeProfit();} } } for(iCount=0;iCount<OrdersTotal();iCount++) { OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber) { OrderModify(OrderTicket(), OrderLots(), 0, NewTP, 0); } if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber) { OrderModify(OrderTicket(), OrderLots(), 0, NewTP, 0); } } } 
Can u help me to add stoploss for that script? If I want only 2 level martingale, then if hit the stoploss it will be all close (same magic number) or open hedging with same lot...
btw, if open hedging... can the new open position make a new magicnumber after hedging or must be close the ea and re-start ea so they will create with new magicnumber?

Thanks
With  martingale in general you close all the orders with the same magic number and then start a new set with whatever magic number - it can be the same. No need for a new magic number
These users thanked the author mladen for the post:
ChuChu Rocket

Re: Simple Expert Advisors (EA's) for MT4

40
mladen wrote:With  martingale in general you close all the orders with the same magic number and then start a new set with whatever magic number - it can be the same. No need for a new magic number
ok.. thx..

This what I got this few weeks, open position with averaging
Last target to add stop loss and partial close the position when profit...
If u have time can u help me

tq tq tq


Who is online

Users browsing this forum: DaveTrader, DotNetDotCom [Bot], Grapeshot [Bot], IBM oBot [Bot], Proximic [Bot] and 81 guests