Download MetaTrader 5

Add horizontal arrow

To add comments, please log in or register
WiktorG
10
WiktorG  
Hello
I want to ask you, if it is possible to change the code so that the arrow shows the price when there has been a cross lines, and add second arrow with the price higher / lower by 50 points. Now the indicator shows arrows below and abow the bar.


int limit = 0;
int fontsize=10;
int i = 0;
bool InLTrade = false;
bool InSTrade = false;

/////////////////////////////////////////////////////////////////////////////////////////////
string NewArrow(datetime T1, double P1, color collor) 
{
   string N=StringConcatenate("A",collor,"-",TimeToStr(T1));
   int AC=SYMBOL_STOPSIGN;
   if(collor==Blue)
      AC=SYMBOL_ARROWUP;
   if(collor==Red) 
      AC=SYMBOL_ARROWDOWN;
   //
   ObjectCreate(N, OBJ_ARROW, 0, T1, P1);
   ObjectSet(N, OBJPROP_ARROWCODE, AC);
   ObjectSet(N, OBJPROP_COLOR, collor);
   ObjectSet(N, OBJPROP_WIDTH, 1);
   ObjectsRedraw();
   return(N);
}
/////////////////////////////////////////////////////////////////////////////////////////////

if (plotArrows)
   {
      ObjectsDeleteAll();
      InLTrade = false;
      InSTrade = false;
      for(int i=Bars;i>=0;i--)
      {
         if ((Buffer3[i-1]  > 0) && (Buffer3[i] < 0) && Buffer3[i-1] > HistThreshold)//Long Begin
         {
           string upArrow1=NewArrow(Time[i-1], High[i-1]+0.0005, Blue);
            InLTrade = true; 
         }
         if ((Buffer3[i-1]  < 0) && (Buffer3[i] > 0) && Buffer3[i-1] < -HistThreshold)//Short Begin
         {
            string dnArrow1=NewArrow(Time[i-1], Low[i-1]-0.0003, Red);
            InSTrade = true; 
            InLTrade = false;  
         }
         if ((InSTrade  == true) && (Buffer3[i-1] > Buffer3[i]))//Short End
         {
            string upArrow2=NewArrow(Time[i-1], Low[i-1]-0.0003, Aqua);
            InSTrade = false; 
         }
         if ((InLTrade == true) && (Buffer3[i-1] < Buffer3[i]))//Long End
         {
            string dnArrow2=NewArrow(Time[i-1], High[i-1]+0.0005, Aqua);
            InLTrade = false;   
         }
      }
   }

like this

macd

Files:
e_Macd.mq4 5 kb
Alain Verleyen
Moderator
33334
Alain Verleyen  
Yes it's possible, what have you tried ?
WiktorG
10
WiktorG  

now i see only one arrow below/above bar, i don't now how modify this code.

string upArrow1=NewArrow(Time[i-1], High[i-1]+0.0005, Blue);
            InLTrade = true; 

i want put arrow next to bar, exact in this place where the lines intersect.

Like on this image, blue line cross red line when price is 1.09712 and on chart arrow show the same price

macd cross

Alain Verleyen
Moderator
33334
Alain Verleyen  

Forum on trading, automated trading systems and testing trading strategies


Welcome,

  • Usually people who can't code don't receive free help on this forum, though it could happen if you are lucky, be patient.
  • If you show your attempts and describe well your problem, you will most probably receive an answer from the community.
  • If you don't want to learn to code, nothing bad, you can either look at the Codebase if something free already exists, or in the Market for paid products (sometimes free also).
  • Finally, you also have the option to hire a programmer in the Freelance section.

Good luck.


WiktorG
10
WiktorG  

OK,

I modified the indicator. Now send me Alert

 if(PrevSignal <= 0)
      {
        if(BufferGreen[SIGNAL_BAR] - BufferMagenta[SIGNAL_BAR] > 0 && 
           BufferMagenta[SIGNAL_BAR+1] - BufferGreen[SIGNAL_BAR+1] >= 0 && 
                   BufferBlue[SIGNAL_BAR] - BufferRed[SIGNAL_BAR] > 0
                   )
          {
            PrevSignal = 1;
             Alert("BUY1!!" + string(Bid), ", ", Symbol(), ", ", Period(), "TimeCurrent=", TimeToStr(TimeCurrent(),TIME_SECONDS));
             PlaySound("Alert.wav");
          } else if (BufferBlue[SIGNAL_BAR] - BufferRed[SIGNAL_BAR] > 0 && 
           BufferRed[SIGNAL_BAR+1] - BufferBlue[SIGNAL_BAR+1] >= 0 && 
                   BufferGreen[SIGNAL_BAR] - BufferMagenta[SIGNAL_BAR] > 0
                   ) {
                   PrevSignal = 1;
                      Alert("BUY!!" + string(Bid), ", ", Symbol(), ", ", Period(), "TimeCurrent=", TimeToStr(TimeCurrent(),TIME_SECONDS));
              PlaySound("Alert.wav");
                   }
      }
          

But I would like to create code with arrows, I would ask for advice on where should to look?

To add comments, please log in or register