Simple "Script"

 
Hello my name is Marlon and I'm from Spain
I'm new to this the programming ..

I'm trying to create a "script" simple, following the examples of the page, I did this:
//+------------------------------------------------------------------+
//| Orden Pen.mq4 |
//| marlon |
//| marloncol@hotmail.com |
//+------------------------------------------------------------------+
#property copyright " =)"
#property link " =)"
#property show_confirm
//+------------------------------------------------------------------+
//| script "send pending order with expiration data" |
//+------------------------------------------------------------------+
int start()
{
int ticket,expiration;
double point;
//----
point=MarketInfo(Symbol(),MODE_POINT);
expiration=CurTime()+PERIOD_D1*60;
//----
while(true)
{



ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*point,0,Ask+200*point,0,"some comment",16384,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*point,0,0,0,"some comment",16384,expiration,Green);

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-200*point,0,Bid+200*point,0,"some comment",16384,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-400*point,0,0,0,"some comment",16384,expiration,Green);


if(ticket<=0) Print("Error = ",GetLastError());
else { Print("ticket = ",ticket); break; }
//---- 10 seconds wait
Sleep(10000);
}
//----
return(0);
}
//+------------------------------------------------------------------+
What I do is to open the 4 orders pending with TP and SL

But you try all forms and not work for me the TP and S.L. Pending the Ordens,





What would be the right way to do ??????


If anyone can help me I would appreciate much

Greetings
 

Replace

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-200*point,0,Bid+200*point,0,"some comment",16384,expiration,Green);

to

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-200*point,0,Bid-400*point,0,"some comment",16384,expiration,Green);

 
Hi Roger .. thanks for answering ..
I already did that way and only works on S.L.
and no way to run the T.P.
everything works fine but the T.P. not running
I tried 1000 ways but does not work,
maybe some code is wrong from the beginning????
I did as indicated in the TP not working manualy

With the same encoding above, this is the result:
Just run the T.P. of the First Order and supersedes all others ..
!!!!!!HELP!!!!!!!!!!!PLEASE!!!!!!!!!
 
This is the result


TakeProfit

 

So, replace

ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*point,0,Ask+200*point,0,"some comment",16384,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*point,0,0,0,"some comment",16384,expiration,Green);

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-200*point,0,Bid+200*point,0,"some comment",16384,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-400*point,0,0,0,"some comment",16384,expiration,Green);

to

ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*point,0,Ask+200*point,Bid-400*point,"some comment",16384,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*point,0,Ask,Bid-600*point,"some comment",16384,expiration,Green);

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-200*point,0,Bid-600*point,Bid,"some comment",16384,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.01,Ask-400*point,0,Bid-800*point,Bid-200*point,"some comment",16384,expiration,Green);
 
Hi Roger.

Replace the codes, as in the example, but it still gives error, can not change the TP and S.L.

The "Script" I want to do is for use with progressions "Martingale" and that is why we need to be able to change the T.P. and S.L. of all pending orders.

I tried many ways and not what is the error.
This is how I did it: #1
//+------------------------------------------------------------------+
//| Orden Pen.mq4 |
//| marlon |
//| marloncol@hotmail.com |
//+------------------------------------------------------------------+
#property copyright " =)"
#property link " =)"
#property show_confirm
//+------------------------------------------------------------------+
//| script "send pending order with expiration data" |
//+------------------------------------------------------------------+
int start()
{
int ticket,expiration;

//----

expiration=CurTime()+PERIOD_D1*60;
//----
while(true)
{



OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-200*Point,Bid+200*Point,"some comment",0,0,CLR_NONE);


ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-600*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-800*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-1000*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-1200*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.02,Ask-200*Point,0,Bid-200*Point,Ask+200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.04,Ask-400*Point,0,Bid-200*Point,Ask+200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.08,Ask-600*Point,0,Bid-200*Point,Ask+200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.16,Ask-800*Point,0,Bid-200*Point,Ask+200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.32,Ask-1000*Point,0,Bid-200*Point,Ask+200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.64,Ask-1200*Point,0,Bid-200*Point,Ask+200*Point,"some comment",0,expiration,Green);


if(ticket<=0) Print("Error = ",GetLastError());
else { Print("ticket = ",ticket); break; }
//---- 10 seconds wait
Sleep(10000);
}
//----
return(0);
}
//+------------------------------------------------------------------+
This only works Buy and nothing else...and does not execute other orders..
The other way: # 2

OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Bid-200*Point,Bid+200*Point,"some comment",0,0,CLR_NONE);


ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-600*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-800*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-1000*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-1200*Point,0,0,0,"some comment",0,expiration,Green);

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.02,Ask-200*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.04,Ask-400*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.08,Ask-600*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.16,Ask-800*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.32,Ask-1000*Point,0,0,0,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.64,Ask-1200*Point,0,0,0,"some comment",0,expiration,Green);
This works the other way Buy and all outstanding orders,
and you can not T.P. or S.L.

Truth is not where this failure ...
!!!!! Help me!!!!! !!!!!Plaese!!!!!


( "Sorry for my bad English)


 

#1:

ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);

openprice equals tp


ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*Point,0,Ask+200*Point,Bid-200*Point,"some comment",0,expiration,Green);

openprice < TP in sell stop order

.................


the reason you can not find the error is that you used the same varaible "ticket" to save the return of 12 OrderSend, but only one if after the last one.

 

OK, try this:

ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-200*Point,0,Bid,Bid-400*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-400*Point,0,Bid-200,Bid-600*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-600*Point,0,Bid-400,Bid-800*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-800*Point,0,Bid-600,Bid-1000*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-1000*Point,0,Bid-800,Bid-1200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-1200*Point,0,Bid-1000,Bid-1400*Point,"some comment",0,expiration,Green);

ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.02,Ask-200*Point,0,Ask-400*Point,Ask,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.04,Ask-400*Point,0,Ask-600*Point,Ask-200*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.08,Ask-600*Point,0,Ask-800*Point,Ask-400*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.16,Ask-800*Point,0,Ask-1000*Point,Ask-600*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.32,Ask-1000*Point,0,Ask-1200*Point,Ask-800*Point,"some comment",0,expiration,Green);
ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.64,Ask-1200*Point,0,Ask-1400*Point,Ask-1000*Point,"some comment",0,expiration,Green);
 
!!!!!!Thanks !!!!!! Roger...
!!!!!!Thanks !!!!!! GreatShore

They're "Geniuses" :D
Reason: