Can anybody edit my Code please?

To add comments, please log in or register
idealist72
14
idealist72  

Hello All. i'm trying to write a simple indicator-based Expert which send Sell and Buy Signals , with iCustom Function. my problem is closing Orders. my code Sends Sell and Buy orders when buy or sell signals come , but now i need a code which close the last order before sending new order. can anybody please edit my code and add this code? i don't need someone to tell me what i have to do because i'm trying from the last week , i need someone to edit my code. thanks in advance.


//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2018, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+


extern int TimeFrame_indicator = 30;
extern double Lot = 0.01;
extern int Stoploss = 10;
extern int Takeprofit = 10;

int NumBuy = 0;
int NumSell = 0;




void start()

  {
   

   count();
  


   double buy_signal=iCustom(Symbol(), 0, "Indicator", 0 ,0);

   double sell_signal=iCustom(Symbol(), 0, "Indicator", 1 , 0);
   


  if(NumBuy == 0 && NumSell == 0)
     
      {
         
        

        if(buy_signal != EMPTY_VALUE )

        {

            OrderSend(Symbol(), OP_BUY, Lot, Ask, 0, 0, 0, 0 , 0 , 0, Green);

       
        }
     

         
         if(sell_signal != EMPTY_VALUE)
         
        {

            OrderSend(Symbol(), OP_SELL, Lot, Bid, 0, 0, 0 , 0, 0 , 0, Red);

        }
        
      
   }

//=================================================================
//=================================================================

void count()
 {
 
 NumBuy = 0; NumSell = 0;
 
 for(int i = OrdersTotal()-1 ; i>=0 ;i--)
   {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol() == Symbol())
    
      {
         if(OrderType() == OP_BUY)
           {
            NumBuy++;
           }
           
           else if(OrderType() == OP_SELL)
          {
           NumSell++;
          }
      }
   }
 }

   
//========================================================//
//========================================================//
//========================================================//
William Roeder
20210
William Roeder  
idealist72: please edit my code
You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help
          urgent help.

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum

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

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum

I guess this reply must be made ia short cut. 

idealist72:



 please refer to your Older Post of this same thread I sent you the solution but it is what you dont like 

Here

or better go to Freelance and ask someone to do it for you 

once done retuurn to my post  and see that whatI told you to do is the solution. 

here is the example. 

Driving a car. 

step 1:  are you inside car 
step 2 are you sitted by drivers seat
step 3 do you have keys
step 4. Is the car on
step 5 is your seatbelt okk
step 6. Take of with gear 1. 

but your code is 
Start driving 

This example is cause you ignored the Inital help I sent.

How to run ordersend just once?
How to run ordersend just once?
  • 2019.12.27
  • www.mql5.com
Hi. i'm trying to wrote a simple expert based on indicator buffers...
Jefferson Metha
2229
Jefferson Metha  
Your count function Very Good. 

but your code wont Compile 

Your Start function is still the same as the initial  in this post HERE

this is a perfect example of ignorance 

you want to close Orders yet your code has nothing regarding or any function that closes orders. 

would have been better if we saw an Order Closing function. 
How to run ordersend just once?
How to run ordersend just once?
  • 2019.12.27
  • www.mql5.com
Hi. i'm trying to wrote a simple expert based on indicator buffers...
To add comments, please log in or register