Please use this to post code . . . it makes it easier to read.
Are the other Brokers ECN type Brokers ? if they are . . . http://crum.be/ecn
You need to adjust for 4/5 digit Brokers . . . http://crum.be/45digit
Please use this to post code . . . it makes it easier to read.
Are the other Brokers ECN type Brokers ? if they are . . . http://crum.be/ecn
You need to adjust for 4/5 digit Brokers . . . http://crum.be/45digit
OK... here is my new code... I put a comment on the screen just so I can see it is calculating the SL and TP correctly. But the journal says it is modifying the order, but putting 0 for SL and TP, even though the comment shows something different.
Thanks for your help.
//+------------------------------------------------------------------+ //| 01-Sell.mq4 | //| | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "" #property link "http://www.metaquotes.net" #include <stdlib.mqh> #include <WinUser32.mqh> string script.1 = "Askobid Demo Account"; //[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] extern double lots.1 = 0.01; double lot.size; extern int lots.1.per = 100; extern double min.lots = 0.01; // minimum lot size //[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] extern double stop.loss = 0.00500; extern double take.profit = 0.00040; extern int decimal1 = 5; double pr1.spread.c; //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { Comment("\n "+ "\n "); pr1.spread.c = (MarketInfo(Symbol(),MODE_ASK)) - (MarketInfo(Symbol(),MODE_BID)); // pair 1 spread current Comment ( "\n Current Broker Spread"+ "\n "+Symbol()+" "+DoubleToStr(pr1.spread.c,decimal1)+ "\n " ); //[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] int LOT.size = AccountEquity() / lots.1.per; double lot.size = LOT.size * lots.1; if (lot.size < min.lots) lot.size = min.lots; //[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] if(MessageBox("Do you really want to SELL "+DoubleToStr(lot.size,2)+ " of "+Symbol()+" at BID price of "+DoubleToStr(Bid,5)+" ?"+ " take profit will be "+DoubleToStr((Bid-take.profit),5)+ " "+DoubleToStr((take.profit),5)+" pips", script.1,MB_YESNO|MB_ICONQUESTION)!=IDYES) { Comment("\n "+ "\n "); return(1);} //---- Comment("\n Order Pending ------------- lot size = "+DoubleToStr(lot.size,2)); int ticket=OrderSend(Symbol(),OP_SELL,lot.size,Bid,3,0,0,"01-Sell Script",255,0,CLR_NONE); if(ticket<1){ int error=GetLastError(); Comment("\n Error = ",ErrorDescription(error)); return; } { OrderSelect(ticket,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),(Bid-stop.loss),(Bid+take.profit),0,Blue); Comment("\n Order Placed < ------------ Spread "+DoubleToStr(pr1.spread.c,5)+" ----------------------- lot size = "+DoubleToStr(lot.size,2)+ //); "\n Order Placed < ------------ (Bid-stop.loss) "+DoubleToStr((Bid-stop.loss),5)+" ----------------------- (Bid+take.profit) = "+DoubleToStr((Bid+take.profit),5)); } //---- return(0); } //+------------------------------------------------------------------+
Let me check that I have this correct . . . you place a Sell order . .
int ticket=OrderSend(Symbol(),OP_SELL,lot.size,Bid,3,0,0,"01-Sell Script",255,0,CLR_NONE);
then a little later try to modify it . . .
OrderSelect(ticket,SELECT_BY_TICKET); OrderModify(OrderTicket(),OrderOpenPrice(),(Bid-stop.loss),(Bid+take.profit),0,Blue);
. . by setting the SL lower than Bid and the TP higher than Bid . . . for a SELL ?
Let me check that I have this correct . . . you place a Sell order . .
then a little later try to modify it . . .
. . by setting the SL lower than Bid and the TP higher than Bid . . . for a SELL ?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can someone look at my code and tell me why I am getting an error.... Error=invalid stops
this code actually works on one broker (Askobid) but I am getting the error on other brokers.
thanks for your help.
//+------------------------------------------------------------------+
//| 01-Sell.mq4 |
//| |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright ""
#property link "http://www.metaquotes.net"
#include <stdlib.mqh>
#include <WinUser32.mqh>
string script.1 = "Auto stops Order";
//[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
extern double lots.1 = 0.015; double lot.size;
extern int lots.1.per = 100;
extern double min.lots = 0.01; // minimum lot size
//[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
extern double stop.loss = 0.0100;
extern double take.profit = 0.0004;
extern int decimal1 = 5;
double pr1.spread.c;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
Comment("\n "+
"\n ");
pr1.spread.c = (MarketInfo(Symbol(),MODE_ASK)) - (MarketInfo(Symbol(),MODE_BID)); // pair 1 spread current
Comment (
"\n Current Broker Spread"+
"\n "+Symbol()+" "+DoubleToStr(pr1.spread.c,decimal1)+
"\n "
);
//[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
int LOT.size = AccountEquity() / lots.1.per;
double lot.size = LOT.size * lots.1;
if (lot.size < min.lots) lot.size = min.lots;
//[[[[[[[[[[[[[[[[[ lot size management ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
if(MessageBox("Do you really want to SELL "+DoubleToStr(lot.size,2)+
" of "+Symbol()+" at BID price of "+DoubleToStr(Bid,5)+" ?"+
" take profit will be "+DoubleToStr((Bid-take.profit),5)+
" "+DoubleToStr((take.profit),5)+" pips",
script.1,MB_YESNO|MB_ICONQUESTION)!=IDYES) {
Comment("\n "+
"\n ");
return(1);}
//----
Comment("\n Order Pending ------------- lot size = "+DoubleToStr(lot.size,2));
int ticket=OrderSend(Symbol(),OP_SELL,lot.size,Bid,3,(Ask+stop.loss),(Ask-take.profit-pr1.spread.c),"01-Sell Script",255,0,CLR_NONE);
if(ticket<1)
{
int error=GetLastError();
Comment("\n Error = ",ErrorDescription(error));
return;
}
{
Comment("\n Order Placed < ----------------------------------- lot size = "+DoubleToStr(lot.size,2));
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+