how would i be able to add into an EA that it will buy when the arrow is given? or do a sell when sellarrow is given?

 

i just like it to open 1 order when an arrow is given immediately. not every tick or every new bar. just 1 trade.

I have used icustom() function to merge indicator and expert advisor. and its work fine. but when indicator will give any arrow , then immediately i want to place trade.

For that I coded few lines which are given below.

   if(newbar==Time[0])
      return(0); 
   else newbar=Time[0];
   
   
   ArrowUp = iCustom(NULL,0,"vr",0,1);
   ArrowDown = iCustom(NULL,0,"vr",1,1);
   
   
   
   Print("ArrowUp: "+ArrowUp+", ArrowDown: "+ArrowDown+", Time: "+TimeToStr(Time[1]));
        if(ArrowDown != EMPTY_VALUE  )
        {
           Print("hello from Up    :  "+  ArrowUp);
         NumOrders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
             if (NumOrders < MaxOrdersCount) 
           {
               Print("hello from Down :   "+ArrowDown);
               Alert("Up");
               OpenSell(Lots);
           }
       
        }

      if(ArrowUp != EMPTY_VALUE  )
        {
           Print("hello from Down :   "+ArrowDown);
          NumOrders = OrdersTotalCountByTypeANDMagic(OP_BUY, BuyMagic) + OrdersTotalCountByTypeANDMagic(OP_SELL, SellMagic);
             if (NumOrders < MaxOrdersCount) 
           {
               Print("hello from Down :   "+ArrowDown);
               Alert("Down");
               OpenBuy(Lots);
           }
         
        }
 

Please use the </> button to insert your code.


 
KhanakKapoor_98: I have used icustom() function to merge indicator and expert advisor. and its work fine. but when indicator will give any arrow , then immediately i want to place trade.
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) You should have edited your original post, not reposted.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. You haven't stated a problem, you stated a want. Show us your attempt (using CODE button) and state the nature of your problem.
              No free help
              urgent help.

  3. Use the debugger or print out your variables, including _LastError and find out why.
Moderator: Edited original post and removed re-post
_LastError - Predefined Variables - MQL4 Reference
_LastError - Predefined Variables - MQL4 Reference
  • docs.mql4.com
_LastError - Predefined Variables - MQL4 Reference
 

Hello Whroeder1,

                         There is no problems or errors in above uploaded code but its place trade after giving signals or arrow by indicator and completing the current candle, means on starting of next candle it place the trade based on suggestion given by indicator. Actually, I want to place order of buy or sell immediately when indicator gives me signals, not after completing current candle.

Please suggest me what changes I have to made to getting this functionality in my expert adviser.

 
KhanakKapoor_98:

Hello Whroeder1,

                         There is no problems or errors in above uploaded code but its place trade after giving signals or arrow by indicator and completing the current candle, means on starting of next candle it place the trade based on suggestion given by indicator. Actually, I want to place order of buy or sell immediately when indicator gives me signals, not after completing current candle.

Please suggest me what changes I have to made to getting this functionality in my expert adviser.

Files:
 
KhanakKapoor_98:   There is no problems or errors in above uploaded code  

Please suggest me what changes

No problems with code, no changes required. Otherwise previously answered: #2.3

 
Yaah, I know that there is no error in code but what I want or requirement is already defined above, and for this type of functionality what changes I have to made in my code?