Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 221
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Just on that page, the link to which you posted in your post. Read it there more carefully.
Yes, I was stupid. I just need to start(); start additionally via init(){}...
int init(){start();}
...
void start(){...}
Thanks, I figured it out.
How do I redeem my bonuses for money?
Whose bonuses?
I have the following code:
extern datetime start = D'2013.10.17 23:59';
int start()
{
int b1=iBarShift(Symbol(),0,start,0);
double hb=iHigh(Symbol(),0,b1); //bar
double hb2=iHigh(Symbol(),0,b1-1); //bar of tomorrow from specified date
Could you please tell me how to put yesterday's day from specified date, because double hb3=iHigh(Symbol(),0,b1+1); doesn't work...
Hi all!!! I have an EA opening orders against the movement, how to change or advise where to change???
string GLOB_START;
int init()
{
GLOB_START = "@" + DoubleToStr(ID,0) + "@" + "_start";
if !GlobalVariableCheck( GLOB_START )GlobalVariableSet(GLOB_START,TimeCurrent());
return(0);
}
int deinit()
{
switch( UninitializeReason() )
{
case REASON_REMOVE: delete_glob ("@" + DoubleToStr(ID,0) + "@" );
}
if ( IsTesting() )delete_glob ("@" + DoubleToStr(ID,0) + "@" );
return(0);
}
void delete_glob ( string c )
{
int i;
for ( i = GlobalVariablesTotal()-1; i>= 0 ; i-- )if ( StringFind(GlobalVariableName(i),c) >= 0 )GlobalVariableDel(GlobalVariableName(i))
}
int start()
{
Comment(Info());
int KOL_BUY = order_total(0);
int KOL_SELL = order_total(1);
double l;
if ( order_total() == 0 )
{
open(0,Lot,0,TP);
open(1,Lot,0,TP);
}
if ( KOL_BUY == 0 && KOL_SELL != 0 )
{
open(0,Lot,0,TP);
l = last_trade(1);
open(1,l,0,0);
modify_orders(1);
}
if ( KOL_BUY != 0 && KOL_SELL == 0 )
{
open(1,Lot,0,TP);
l = last_trade(0);
open(0,l,0,0);
modify_orders(0);
}
return(0);
}
string Info()
{
int i;
double buff_1 = 0, buff_2 = 0, buff_3 = 0;
string res = "\n";
for( i = OrdersHistoryTotal() - 1; i >= 0; i-- )
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if( OrderMagicNumber() == ID )
{
if ( OrderOpenTime() >= iTime(NULL,PERIOD_D1,0) )buff_1 += OrderProfit();
if ( OrderOpenTime() >= iTime(NULL,PERIOD_D1,1) && OrderOpenTime() < iTime(NULL,PERIOD_D1,0) )buff_2 += OrderProfit();
if ( OrderOpenTime() >= GlobalVariableGet(GLOB_START) )buff_3 += OrderProfit();
}
}
res = res + "Profit in the deposit currency for " + TimeToStr(iTime(NULL,PERIOD_D1,0)) + ": " + DoubleToStr(buff_1,0) + "\n" + "\n";
res = res + "Profit in deposit currency for " + TimeToStr(iTime(NULL,PERIOD_D1,1)) + ": " + DoubleToStr(buff_2,0) + "\n" + "\n";
res = res + "Profit in the deposit currency total:" + DoubleToStr(buff_3,0) + "\n";
return(res);
}
void modify_orders( int type )
{
int i;
datetime time_last = 0, time_first = TimeCurrent();
double SPREAD = MarketInfo(Symbol(),MODE_SPREAD)*MarketInfo(Symbol(),MODE_POINT), op_pr_last, op_pr_first, level;
for( i = OrdersTotal() - 1; i >= 0; i-- )
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if( OrderMagicNumber() == ID && OrderType() == type )
{
if ( OrderOpenTime() > time_last )
{
op_pr_last = OrderOpenPrice();
time_last = OrderOpenTime();
}
if ( OrderOpenTime() < time_first )
{
op_pr_first = OrderOpenPrice();
time_first = OrderOpenTime();
}
}
}
if ( type == 0 )level = op_pr_last + MathAbs(op_pr_last-op_pr_first) * (SL/100);
if ( type == 1 )level = op_pr_last - MathAbs(op_pr_last-op_pr_first) * (SL/100);
for( i = OrdersTotal() - 1; i >= 0; i -- )
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if( OrderMagicNumber() == ID && OrderType() == type && NormalizeDouble(OrderTakeProfit(),Digits) != NormalizeDouble(level,Digits) )OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),level,0)
}
}
double last_trade( int t )
{
int i;
double res = -1;
datetime time=0;
for(i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderOpenTime()>time && OrderMagicNumber()==ID && OrderType() == t)
{
res = OrderLots();
time = OrderOpenTime();
}
}
if ( multiplier )return(res * Lot_koeff);
if ( !multiplier )return(res + Lot_koeff);
}
int open(int type, double l, double sl=0, double tp=0, string comm = "")
{
int isOpened = 0, try = 0;
double s,t;
while ( IsTradeContextBusy() ){Sleep(500);}
RefreshRates();
if ( sl != 0 && sl < MarketInfo(Symbol(),MODE_STOPLEVEL) )sl = MarketInfo(Symbol(),MODE_STOPLEVEL);
if ( tp != 0 && tp < MarketInfo(Symbol(),MODE_STOPLEVEL) )tp = MarketInfo(Symbol(),MODE_STOPLEVEL);
if ( type == 0 )
{
if ( tp == 0 )t = 0;
if ( tp != 0 )t = Ask + tp * Point;
if ( sl == 0 )s = 0;
if ( sl != 0 )s = Bid - sl * Point;
}
if ( type == 1 )
{
if ( tp == 0 )t = 0;
if ( tp != 0 )t = Bid - tp * Point;
if ( sl == 0 )s = 0;
if ( sl != 0 )s = Ask + sl * Point;
}
s = NormalizeDouble(s,Digits);
t = NormalizeDouble(t,Digits);
if(type==0)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Ask,Digits),10,s,t,comm,ID);
if(type==1)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Bid,Digits),10,s,t,comm,ID);
Sleep(500);
while(isOpened<0)
{
while ( IsTradeContextBusy() ){Sleep(500);}
RefreshRates();
if ( type == 0 )
{
if ( tp == 0 )t = 0;
if ( tp != 0 )t = Bid + tp * Point;
if ( sl == 0 )s = 0;
if ( sl != 0 )s = Bid - sl * Point;
}
if ( type == 1 )
{
if ( tp == 0 )t = 0;
if ( tp != 0 )t = Ask - tp * Point;
if ( sl == 0 )s = 0;
if ( sl != 0 )s = Ask + sl * Point;
}
s = NormalizeDouble(s,Digits);
t = NormalizeDouble(t,Digits);
try++;
if(type==0)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Ask,Digits),10,s,t,comm,ID);
if(type==1)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Bid,Digits),10,s,t,comm,ID);
if(try > 5) break;
if(isOpened>=0)break;
Sleep(500);
}
if(isOpened<0) Alert("Order not opened, error :", GetLastError());
return(isOpened);
}
int order_total( int type_1 = -1, int type_2 = -1 )
{
int i;
int kol=0;
for(i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==ID && (OrderType() == type_1 || OrderType() == type_2) )kol++;
if(OrderMagicNumber()==ID && type_1 == -1 && type_2 == -1 )kol++;
}
return(kol);
}
double check_lot(double &lo)
{
double l = MarketInfo(Symbol(),MODE_LOTSTEP);
int ok = 0;
while ( l < 1 ){l*=10;ok++;}
if( lo < MarketInfo(Symbol(),MODE_MINLOT) )lo = MarketInfo(Symbol(),MODE_MINLOT);
if( lo > MarketInfo(Symbol(),MODE_MAXLOT) )lo = MarketInfo(Symbol(),MODE_MAXLOT);
return(NormalizeDouble(lo,ok));
How do I make a trawl for "Funds:" (AccountEquity())?
Parameters
extern double TrailingStart = 10000; // Trailing level
extern double TrailingStop = 100; // Trailing size
extern double TrailingStep = 10; // Trailing step
How do I find two top/bottom fractals in a row? The picture below.
I tried to write an indicator, but I didn't think it through.
Maybe someone has seen such an indicator ready?