buy and sell every 10 points - page 2

 
georgioooo:

i fixed the problem i want to thank you devries :) and I hope to remain in contact :)
 
deVries:


hello devries how are you?

if you have time please can you see my code below: i want to do 1 sellstop every 10 pips:

#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
int start()                                    
{
double normPrice = NormalizeDouble(Ask,3);
double takeprofit1 = 0.0010;

int openbuy;

if(OrdersTotal()>0)
{
  
  for(int i=1; i<=OrdersTotal(); i++)  //Cycle searching in orders
   {         
  
      if (OrderSelect(i+1,SELECT_BY_POS)==true) // If the next is available       
        { 
        OrderDelete(OrderTicket(),CLR_NONE);
        
         }
   }
}

openbuy=OrderSend("EURUSD",OP_SELLSTOP,0.01,normPrice,0,0,normPrice-takeprofit1,0,0);

    



return(0); 
 
georgioooo:


hello devries how are you?

if you have time please can you see my code below: i want to do 1 sellstop every 10 pips:


It fails you have no clue what you are doing.... Again you are deleting the trade you just placed read this topic again from beginning

and come with better coding...

 
deVries:


It fails you have no clue what you are doing.... Again you are deleting the trade you just placed read this topic again from beginning

and come with better coding...


okey i will, :) i tried to do that Taking into considiration you Advice Previously:

i lunched this code into Mt4 chart window: he do do 1 order sell and when the order is closed he do another one so very good but i want also "if the current price == open price +10*Point and whatever the previous order is closed or no" to do another order sell.

can you help me please.

#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
int trade=0;
 int start()
  {
   double normPrice = NormalizeDouble(Ask,3); 
   double lineInterval1 = 0.0010;
    

if(trade==0)
OrderSend("EURUSD",OP_SELL,0.1,normPrice,3,0,normPrice-lineInterval1,"ExpertComment",22456,0,Green);
     {
   if(OrdersTotal()>1)
         {
   trade= OrdersTotal();
         }
     }
   
   return(0); 
   }
 
georgioooo:


okey i will, :) i tried to do that Taking into considiration you Advice Previously:

i lunched this code into Mt4 chart window: he do do 1 order sell and when the order is closed he do another one so very good but i want also "if the current price == open price +10*Point and whatever the previous order is closed or no" to do another order sell.

can you help me please.


So you want to do this . . .

if ( current price == open price + ( 10 * Point ) )
   OrderSend( . . . . );

What is open price the opening price of ? what if you have more than one open order ? your problem isn't simply one of coding, you also need to think through what you are trying to do and how you are going to do it . . then, and only then, should you start thinking about code.

What kind of Broker are you using ? is it an ECN Broker ? is it 4 digit or 5 digit ?

 
RaptorUK:


So you want to do this . . .

What is open price the opening price of ? what if you have more than one open order ? your problem isn't simply one of coding, you also need to think through what you are trying to do and how you are going to do it . . then, and only then, should you start thinking about code.

What kind of Broker are you using ? is it an ECN Broker ? is it 4 digit or 5 digit ?

open price is: if(OrderSelect(the last ticket, SELECT_BY_POS)==true)
Print("open price for the order 10 ",OrderOpenPrice()); the openprice of the last ticket and yes i found this problem before how can i return the open price of the last opening order.

i'm using a broker with 4 digits

 
georgioooo:

how can i return the open price of the last opening order.

i'm using a broker with 4 digits


Is your Broker an ECN Broker ?

This should get you the most recently opened Order, and place a new Sell . . . by the way, you Sell at Bid and Buy at Ask.

int OrderPosition;

if(OrdersTotal() > 1)
   {
   OrderPosition = 0;

   while(OrderPosition < OrdersTotal())
      {
      if( OrderSelect(OrderPosition, SELECT_BY_POS, MODE_TRADES) &&  
      OrderMagicNumber() == MagicNo &&
      OrderSymbol() == Symbol() && 
      OrderType() == OP_SELL )
         {
         if(Bid >= OrderOpenPrice() + (10 * Point))
            if(OrderSend("EURUSD", OP_SELL, 0.1, Bid, 3, 0, Bid - lineInterval1, "ExpertComment", 22456, 0, Green) < 0)
               Print("OrderSend failed, Error: ", getLastError());
         
         break;
         }
      OrderPosition++;
      
      }

   }
   
 
RaptorUK:


Is your Broker an ECN Broker ?

This should get you the most recently opened Order, and place a new Sell . . . by the way, you Sell at Bid and Buy at Ask.


thank you very much :) and i will try to put it into my expert

my broker is: DDE

 
georgioooo:


thank you very much :) and i will try to put it into my expert

my broker is: DDE


hello again :) i create this EA and i tested it in the
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
int trade=0;
 int start()
  {
   double normPrice = NormalizeDouble(Ask,3); 
   double lineInterval1 = 0.0005; 
   int MagicNo=22456;
   int lastorder; 
    
if(OrdersTotal() > 1) //searching for last opening order
   {
   int OrderPosition = 0;

   while(OrderPosition < OrdersTotal())
      {
      if( OrderSelect(OrderPosition, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == MagicNo && OrderSymbol() == Symbol() && OrderType() == OP_SELL )
       
      lastorder=1;
      OrderPosition++;
      
      }
   }

if(trade==0)
if(Ask>normPrice)
OrderSend("EURUSD",OP_SELL,0.1,normPrice,3,0,normPrice-lineInterval1,"ExpertComment",MagicNo,0,Green);
     {
   if(OrdersTotal()>1)
         {
   trade= OrdersTotal();
         }
     }
if (lastorder==1)
if(Bid >= OrderOpenPrice() + (5 * Point))
OrderSend("EURUSD", OP_SELL, 0.1, Bid, 3, 0, Bid - lineInterval1, "ExpertComment", MagicNo, 0, Green);


 return(0); 
   }
strategy tester and he give the result what i want:
 
georgioooo:

hello again :) i create this EA and i tested it in the strategy tester and he give the result what i want:

And if the OrderSend fails don't you want to know why ? or would you rather waste time scratching you head and asking for help here ?