Coding help - page 667

 
i need someone to help me turn this ema crossover to an EA.  open buy when blue arrow appear and sell when the red arrow appear exit the trade when the candle next to the arrow close. pls let the SL AND TP be ajustable and the MAs .   i just want to use it to trade the candle
 
dotmund:
i need someone to help me turn this ema crossover to an EA.  open buy when blue arrow appear and sell when the red arrow appear exit the trade when the candle next to the arrow close. pls let the SL AND TP be ajustable and the MAs .   i just want to use it to trade the candle
Check this post : https://www.mql5.com/en/forum/180648/page940
 
mladen:

For candle time, best to use some indicator specialized for that (like the attached)

As for the period separator : it is already nmc but you might want to use the attached (it should be lighter on the cpu)

Thank you very much. I'm trying to add the option of "BarsLimit" but I have not succeeded. Could you help me, please. Thank you very much for your time.
 
Entropy:
Thank you very much. I'm trying to add the option of "BarsLimit" but I have not succeeded. Could you help me, please. Thank you very much for your time.

Entropy

Here is a version with that option added

Files:
 

Hello mladen can you teach me to solve the declaration .

This is what i get the warning .

declaration of 'MinLots' hides global declaration at line 93    
declaration of 'MaxLots' hides global declaration at line 94    
declaration of 'Magic' hides global declaration at line 118     
void CalculateMM()
{
   double MinLots=MarketInfo(Symbol(),MODE_MINLOT);
   double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
   Lots=AccountFreeMargin()/100000*RiskPercent;
   Lots=MathMin(MaxLots,MathMax(MinLots,Lots));
   if(MinLots<0.1)Lots=NormalizeDouble(Lots,2);
   else
   {
     if(MinLots<1)Lots=NormalizeDouble(Lots,1);
     else Lots=NormalizeDouble(Lots,0);
   }
   if(Lots<MinLots)Lots=MinLots;
   if(Lots>MaxLots)Lots=MaxLots;
   return;



int CloseBuyOrders(int Magic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) 
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY)
      {
       ClTicket= OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}

int CloseBuyOrdersHiddenTP(int Magic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) 
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY&&Bid>(OrderOpenPrice()+TakeProfit*Point))
      {
        ClTicket=OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}

Thank you .

 
stevenpun:

Hello mladen can you teach me to solve the declaration .

This is what i get the warning .



Thank you .

First this :

void CalculateMM()
{
   double tMinLots=MarketInfo(Symbol(),MODE_MINLOT);
   double tMaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
   Lots=AccountFreeMargin()/100000*RiskPercent;
   Lots=MathMin(tMaxLots,MathMax(tMinLots,Lots));
   if(tMinLots<0.1)Lots=NormalizeDouble(Lots,2);
   else
   {
     if(tMinLots<1)Lots=NormalizeDouble(Lots,1);
     else Lots=NormalizeDouble(Lots,0);
   }
   if(Lots<tMinLots)Lots=tMinLots;
   if(Lots>tMaxLots)Lots=tMaxLots;
   return;

and this

int CloseBuyOrders(int tMagic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) 
    if(OrderMagicNumber()==tMagic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY)
      {
       ClTicket= OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}

int CloseBuyOrdersHiddenTP(int tMagic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) 
    if(OrderMagicNumber()==tMagic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY&&Bid>(OrderOpenPrice()+TakeProfit*Point))
      {
        ClTicket=OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}
 

Hello Mladen, 

Would you mind me with this code sir, on what needs to be fix?

Also, when it goes higher timeframe, Is it possible to change from

     ===> 1Min ~ 30 Min ==> every 10 pips  

     ===> 1 Hour  ======>  every 50 pips 

     ===>  4 Hour, Daily ======> every 100 pips

     ===> Weekly, Monthly ===> every 1000 pips

 

 Rectangles are desired instead of lines sir. 

 

 

#property indicator_chart_window

#define ONDA_BEGINS   0

#define ONDA_CONTAINS 1



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

//---- indicators


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

int deinit()

  {

//----

    for (int ix = 0; ix < nLines; ix++) // delete my horizontal lines

      {

      ObjectDelete("tensLines"+ix);

      }


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int start()

  {

    int nLines = 40;                                   // Number of total line to draw

   double lineInterval = 0.0010;                      // Interval between lines

   double normPrice = NormalizeDouble(Close[1],3);    // Current price is rounded to nearest "10"


   for (int ix = 0; ix < nLines; ix++)                // Loop span number of times

      {

      if(ObjectFind("tensLines"+ix) < 0) 

         ObjectCreate("tensLines"+ix, OBJ_HLINE, 0, 0, normPrice+((ix-(nLines/2))*lineInterval));    // Place half above and half below the current price


      else ObjectSet("tensLines"+ix, OBJPROP_PRICE1, normPrice+((ix-(nLines/2))*lineInterval));

      ObjectSet("tensLines"+ix,OBJPROP_COLOR,DarkSlateGray);      // Make the lines look better

      }

 

//----

   return(0);

  }

//+------------------------------------------------------------------+


void ObjectNameDeleteAll(string name, int where=ONDA_BEGINS, int type=EMPTY)

{

    for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--)

    {

        string on   = ObjectName(iObj);

        int    iPos = StringFind(on, name);

        if (iPos < 0)                         continue;

        if (iPos > 0 && where == ONDA_BEGINS) continue;

        if      (type == EMPTY)         ObjectDelete(on);

        else if (type == ObjectType(on)) ObjectDelete(on);

    }

}




//--- 

 
murnathan32:

Hello Mladen, 

Would you mind me with this code sir, on what needs to be fix?

Also, when it goes higher timeframe, Is it possible to change from

     ===> 1Min ~ 30 Min ==> every 10 pips  

     ===> 1 Hour  ======>  every 50 pips 

     ===>  4 Hour, Daily ======> every 100 pips

     ===> Weekly, Monthly ===> every 1000 pips

 

 Rectangles are desired instead of lines sir. 

 

 

#property indicator_chart_window

#define ONDA_BEGINS   0

#define ONDA_CONTAINS 1



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

//---- indicators


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

int deinit()

  {

//----

    for (int ix = 0; ix < nLines; ix++) // delete my horizontal lines

      {

      ObjectDelete("tensLines"+ix);

      }


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int start()

  {

    int nLines = 40;                                   // Number of total line to draw

   double lineInterval = 0.0010;                      // Interval between lines

   double normPrice = NormalizeDouble(Close[1],3);    // Current price is rounded to nearest "10"


   for (int ix = 0; ix < nLines; ix++)                // Loop span number of times

      {

      if(ObjectFind("tensLines"+ix) < 0) 

         ObjectCreate("tensLines"+ix, OBJ_HLINE, 0, 0, normPrice+((ix-(nLines/2))*lineInterval));    // Place half above and half below the current price


      else ObjectSet("tensLines"+ix, OBJPROP_PRICE1, normPrice+((ix-(nLines/2))*lineInterval));

      ObjectSet("tensLines"+ix,OBJPROP_COLOR,DarkSlateGray);      // Make the lines look better

      }

 

//----

   return(0);

  }

//+------------------------------------------------------------------+


void ObjectNameDeleteAll(string name, int where=ONDA_BEGINS, int type=EMPTY)

{

    for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--)

    {

        string on   = ObjectName(iObj);

        int    iPos = StringFind(on, name);

        if (iPos < 0)                         continue;

        if (iPos > 0 && where == ONDA_BEGINS) continue;

        if      (type == EMPTY)         ObjectDelete(on);

        else if (type == ObjectType(on)) ObjectDelete(on);

    }

}




//--- 

Try like this

#property indicator_chart_window

#define ONDA_BEGINS   0

#define ONDA_CONTAINS 1


    int nLines = 40;                                   // Number of total line to draw

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

//---- indicators


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

int deinit()

  {

//----

    for (int ix = 0; ix < nLines; ix++) // delete my horizontal lines

      {

      ObjectDelete("tensLines"+ix);

      }


//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int start()

  {


   double lineInterval = 0.0010;                      // Interval between lines

   double normPrice = NormalizeDouble(Close[1],3);    // Current price is rounded to nearest "10"


   for (int ix = 0; ix < nLines; ix++)                // Loop span number of times

      {

      if(ObjectFind("tensLines"+ix) < 0) 

         ObjectCreate("tensLines"+ix, OBJ_HLINE, 0, 0, normPrice+((ix-(nLines/2))*lineInterval));    // Place half above and half below the current price


      else ObjectSet("tensLines"+ix, OBJPROP_PRICE1, normPrice+((ix-(nLines/2))*lineInterval));

      ObjectSet("tensLines"+ix,OBJPROP_COLOR,DarkSlateGray);      // Make the lines look better

      }

 

//----

   return(0);

  }

//+------------------------------------------------------------------+


void ObjectNameDeleteAll(string name, int where=ONDA_BEGINS, int type=EMPTY)

{

    for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--)

    {

        string on   = ObjectName(iObj);

        int    iPos = StringFind(on, name);

        if (iPos < 0)                         continue;

        if (iPos > 0 && where == ONDA_BEGINS) continue;

        if      (type == EMPTY)         ObjectDelete(on);

        else if (type == ObjectType(on)) ObjectDelete(on);

    }

}



 
hey guys looking to hire someone to write some code in python for me, willing to pay for someones work or if anyone does it for free that's cool too lol.  but just get back to me whenever and let me know if anyone can help me out, ill go into more detail once I have someone's attention.  It will be on Bollinger bands mainly with a couple of other indicators.  thanks for all the help guys! 
 
mladen:

Try like this

Wow. You are the man. Thanks mladen for the blessings.

One more request. Can you make the grid into rectangles like the attachment/pic below.  For Example 10 pips per rectangle. Have the rectangle project the future.

I feel like its more easier on the eyes than the default grid. And takes half a second to see how many pips movement youre looking at.

    ObjectCreate("Rect02", OBJ_RECTANGLE, 0, Time[0], Bid, Time[Bars], (Bid+0.0010) ); //make bar above cur price
      ObjectSet("Rect02", OBJPROP_COLOR, Silver );
      }
//================= Move the Rect with new ticks/candles ===========================
   
   else {
      ObjectMove("Rect01", 0, Time[0], WindowPriceMin()*0.95);
      ObjectMove("Rect02", 0, Time[0], Bid); 

        }   

Files:
Reason: