[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 140

 
Afternoon. MT4 has a Volumes indicator, does it show tick volume or not?
 
first_may:
Afternoon. MT4 has a Volumes indicator, does it show tick volume or not?

Tick volume
 
CLAIN:

The interesting thing is that the deposit is sufficient - I have a large reserve there.
Immediately after opening a position, output an error in Print() and see the reason.
 

Question.

I have written an indicator. The main functions Order and Account used are Symbol() everywhere iClose iOpen. But for some reason, the indicator works ONLY on EURUSD............ I tried other tools hangs ((.

The essence of the indicator: displays information on the Account, Free Funds, ko number of lots to open, how much is open, the ratio Profit / Risk in the money, set up ONLY if (OrderSymbol()!=Symbol()) continue;

Re-examined the reason 10-20 times. I don't understand...((((

Thanks in advance

 
sergeev:

tick

It turns out that all indicators in MT4 from the volume group show a tick volume?
 
paladin80:
Immediately after opening a position, print() output an error and see the reason.


The interesting thing is that there are no problems on the tester. Since 2000 to date it has worked without any drain.

would the code help?

//+------------------------------------------------------------------+ 
//| StMartin.mq4 | 
//| Sergey Kodolov | 
//| 84232676421@mail.ru | 
//+------------------------------------------------------------------+ 
#property copyright "Sergey Kodolov" 
#property link "84232676421@mail.ru" 

    extern int TP = 1000; 
    extern int TS = 1000; 
    extern double lots = 1.0; 

    double volumz; 
    int ticket,total; 
    int slip = 3; 
    int Magic = 7; 

 


//+------------------------------------------------------------------+ 
//| expert initialization function | 
//+------------------------------------------------------------------+ 
int init() 
  { 
//---- 

        ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,slip,Bid-TS*Point,Bid+TP*Point,"First order",Magic,0,Yellow); //открываем первый ордер 
 
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| expert deinitialization function | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
//---- 

//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| expert start function | 
//+------------------------------------------------------------------+ 
int start() 
  { 
//---- 

OrderOpenFunction(); 
StrahBuy();
StrahSell();

//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 

void OrderOpenFunction()
{
   OrderSelect(ticket,SELECT_BY_TICKET);
   if(OrderCloseTime()>0)
   {
      
      total = OrdersTotal();
      Comment("OrderCloseTime = ",OrderCloseTime()," ms");
      if(total < 1) 
      { 
         OrderSelect(ticket,SELECT_BY_TICKET); 
         volumz = OrderLots(); 
         Print("Orderlots = ", OrderLots());
         if(OrderType() == OP_BUY)
         {
            if(OrderClosePrice()-OrderOpenPrice()>0)
            {
               ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,slip,Bid-TS*Point,Bid+TP*Point,0,Magic,0,Green);
            }
            if(OrderClosePrice()-OrderOpenPrice()<0)
            {
               double lot1 = volumz*2; 
               ticket = OrderSend(Symbol(),OP_SELL,lot1,Bid,slip,Ask+TS*Point,Ask-TP*Point,0,Magic,0,Red); 
            }
         }
         if(OrderType() == OP_SELL)
         {
            if(OrderClosePrice()-OrderOpenPrice()<0)
            {
               ticket = OrderSend(Symbol(),OP_SELL,lots,Bid,slip,Ask+TS*Point,Ask-TP*Point,0,Magic,0,Red);
            }
            if(OrderClosePrice()-OrderOpenPrice()>0)
            {
               double lot2 = volumz*2; 
               ticket = OrderSend(Symbol(),OP_BUY,lot2,Ask,slip,Bid-TS*Point,Bid+TP*Point,0,Magic,0,Green);
            }
         }
      }
   }    
}      
  
void StrahBuy()
{
   total = OrdersTotal();
   if(total<1)
   {
      OrderSelect(0,SELECT_BY_POS);
      if(OrderType() == OP_BUY)
      {
         if(OrderClosePrice()-OrderOpenPrice()>0)
         {
            ticket = OrderSend(Symbol(),OP_BUY,lots,Ask,slip,Bid-TS*Point,Bid+TP*Point,0,Magic,0,Green);
         }
         if(OrderClosePrice()-OrderOpenPrice()<0)
         {
            double lot1 = volumz*2; 
            ticket = OrderSend(Symbol(),OP_SELL,lot1,Bid,slip,Ask+TS*Point,Ask-TP*Point,0,Magic,0,Red); 
         }
      }      
   }
}

void StrahSell()
{
   total = OrdersTotal();
   if(total<1)
   {
      OrderSelect(0,SELECT_BY_POS);
      if(OrderType() == OP_SELL)
      {
         if(OrderClosePrice()-OrderOpenPrice()<0)
         {
            ticket = OrderSend(Symbol(),OP_SELL,lots,Bid,slip,Ask+TS*Point,Ask-TP*Point,0,Magic,0,Red);
         }
         if(OrderClosePrice()-OrderOpenPrice()>0)
         {
            double lot2 = volumz*2; 
            ticket = OrderSend(Symbol(),OP_BUY,lot2,Ask,slip,Bid-TS*Point,Bid+TP*Point,0,Magic,0,Green);
         }
      }
   }   
}

I mean, I have one main function here and the other two just duplicate it. I've done it as insurance, but it still fails to work.

 
CLAIN:


the interesting thing is that there are no problems on the tester. It's been running since 2000 to date without draining.

maybe the code would help?

i.e. i have one main function here and the other two just duplicate it. Did it for insurance, but it still stops working

Very strange code. I'm very confused by the fact that you open a position in initialization and search for orders without for operator. I haven't seen anything like that before. Insert Print () in your code. Trust me, it helps.
 
CLAIN:


The interesting thing is that on the tester there's no problem. It's been working since 2000 to date without draining.

would the code help?

I mean, I have one main function here and the other two just duplicate it. Made it as insurance, but it still stops working.

Tester: stop loss #68 at 1.2887 (1.2885 / 1.2887)
16:56:31 2010.07.15 15:04 EURUSD,M30: Orderlots = 1
16:56:31 2010.07.15 15:04 Tester: not enough money to buy 2.00 EURUSD at 1.2887 sl: 1.1885 tp: 1.2905 [2010.07.15 15:04]
16:56:31 2010.07.15 15:04 Tester: PrevBalance: 1838.36, PrevPL: 0.00, PrevEquity 1838.36, PrevMargin: 0.00, NewMargin: 2577, FreeMargin: -738.84
16:56:31 2010.07.15 15:04 martin EURUSD,M30: OrderSend error 134

i think TP=1000 and SL=1000 is too much even if lots=1.0))

Try to put a smaller lot and TP=1000 and i think you'll be happy.

 

PEOPLE!!!!!!!!! Help!!! Please reiterate!!! QUESTION THEN: WHY the indicator opens in MT4 ONLY on EURUSD!!!!!!!!!!!!!!! What a mystery. There is no pair restriction in indicator, Symbol() is everywhere, the main functions on the account Order and Account. When I remove the indicator it doesn't work on another pair too, or rather MT4 hangs completely until I cut it off. I wrote the indicator by myself. I can't understand this behavior with other pairs. Since it's a long indicator, I don't want to display it. But I assure you there is nothing unnatural in it to work without problems ONLY on eurodollar???????????????????????

PRO SOLVE THE PUZZLE)))))))))))))))))))))))))))))))) I have no luck.................

Here is an excerpt on the functions used

++++++++++++++++++++++++++++++++++++ Skip Code

//--- Delet Totals Objects
Del_comment("MN1 Trend");
Del_comment("W1 Trend");
Del_comment("D1 Trend");
Del_comment("H4 Trend");
Del_comment("H1 Trend");
Del_comment("ord .no: ");
Del_comment("ord .#: ");
//---
TRENDS("MN1 Trend",PERIOD_MN1, 1,86, 33, Lab_Trend_Bull,Lab_Trend_Bear,Lab_Trend_Doj, 42);
TRENDS("W1 Trend", PERIOD_W1, 1,111, 48, Lab_Trend_Bull,Lab_Trend_Bear,Lab_Trend_Doj, 12);
TRENDS("D1 Trend", PERIOD_D1, 1,97, 48, Lab_Trend_Bull,Lab_Trend_Bear,Lab_Trend_Doj, 12);
TRENDS("H4 Trend", PERIOD_H4, 1,111, 62, Lab_Trend_Bull,Lab_Trend_Bear,Lab_Trend_Doj,12);
TRENDS("H1 Trend", PERIOD_H1, 1,97, 62, Lab_Trend_Bull,Lab_Trend_Bear,Lab_Trend_Doj, 12);

str=StringLen(AccountCompany());
if(str<=31) shf=31-str;
else
if(str>=31) shf=0;
Commen("NameCo",AccountCompany(), 1, shf, 40, "Times New Roman", color_Fon,7);
Commen("in",ABC v2, 1, 36, 51, "Times New Roman", color_Fon,11);
Commen("txt_symb",Symbol(), 1, 3, 64, "Times New Roman", color_Fon,16);

if(OffABC==true)
Commen("off+", "OFF", 1, 7, 51, "Times New Roman", color_Loss,10);

if(OffABC==false)
{
Commen("in+", "INC", 1, 7, 51, "Times New Roman", color_Profit,10);
int OneLot= MarketInfo(Symbol(),MODE_MARGINREQUIRED);
int TickValue= MarketInfo(Symbol(),MODE_TICKVALUE);

if(Digits==2) pips=100;
else
if(Digits==3) pips=1000;
else
if(Digits==4) pips=10000;
else
if(Digits==5) pips=100000;

if(!IsConnected())
{
ObjectDelete("in+");
Commen("off+", "OFF", 1, 7, 51, "Times New Roman", color_Loss,10);
Commen("noconnect", "no connected", 1, 7, 85, "Times New Roman", color_Loss,14);
}
else
if(IsConnected())
{
ObjectDelete("off+");
ObjectDelete("noconnect");
Commen("in+", "INC", 1, 7, 51, "Times New Roman", color_Profit,10);
}

if(AccountCurrency()=="RUB")
{
EQ_USD= AccountEquity()/iClose("USDRUB",PERIOD_M1,0);
FreeMargin_USD= (AccountFreeMargin()-AccountStopoutLevel())/iClose("USDRUB",PERIOD_M1,0);
PRF_USD= AccountProfit()/iClose("USDRUB",PERIOD_M1,0);
LOT_01= (AccountFreeMargin()-AccountStopoutLevel())/(OneLot/10);
LOT_1= (AccountFreeMargin()-AccountStopoutLevel())/OneLot;
ObjectDelete("nodepo");
}
else
if(AccountCurrency()=="RUR")
{
EQ_USD= AccountEquity()/iClose("USDRUR",PERIOD_M1,0);
FreeMargin_USD= (AccountFreeMargin()-AccountStopoutLevel())/iClose("USDRUR",PERIOD_M1,0);
PRF_USD= AccountProfit()/iClose("USDRUR",PERIOD_M1,0);
LOT_01= (AccountFreeMargin()-AccountStopoutLevel())/(OneLot/10);
LOT_1= (AccountFreeMargin()-AccountStopoutLevel())/OneLot;
ObjectDelete("nodepo");
}
else
if(AccountCurrency()=="EUR")
{
EQ_USD= AccountEquity()*iClose("EURUSD",PERIOD_M1,0);
FreeMargin_USD= (AccountFreeMargin()-AccountStopoutLevel())*iClose("EURUSD",PERIOD_M1,0);
PRF_USD= AccountProfit()*iClose("EURUSD",PERIOD_M1,0);
LOT_01= (AccountFreeMargin()-AccountStopoutLevel())*(OneLot/10);
LOT_1= (AccountFreeMargin()-AccountStopoutLevel())*OneLot;
ObjectDelete("nodepo");
}
else
if(AccountCurrency()=="USD")
{
EQ_USD= AccountEquity();
FreeMargin_USD= AccountFreeMargin()-AccountStopoutLevel();
PRF_USD= AccountProfit();
LOT_01= FreeMargin_USD/(OneLot/10);
LOT_1= FreeMargin_USD/OneLot;
ObjectDelete("nodepo");
}

if(IsConnected() && AccountCurrency()!="RUB" && AccountCurrency()!="RUR" && AccountCurrency()!="EUR" && AccountCurrency()!="USD")
{
ObjectDelete("in+");
ObjectDelete("noconnect");
Commen("off+", "OFF", 1, 7, 51, "Times New Roman", color_Loss,10);
Commen("depo_symbl",AccountCurrency(), 1, 112, 85, "Times New Roman", color_Equity_Account,14);
Commen("nodepo",impracticable",1, 7, 85, "Times New Roman",color_Free,14);
}
//---

if(Orders_OK==false) order=1;
else order=0;

if(OrdersTotal()>=order)
{
for(int pos=OrdersTotal(); pos>=0; pos--)
{
if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()!=Symbol()) continue;
{
SUMM= SUMM+OrderLots();
SWAP=SWAP+OrderSwap();
COMMIS=COMMIS+OrderCommission();
OpenPrice=OpenPrice+OrderOpenPrice();

//--- //BAY ORDERS
if(OrderType()==OP_BUY)
{
baylot= OrderLots();
if(baylot>=1 && baylot<99.0)
{
bSL1= bSL1+(OrderStopLoss());
bTP1= bTP1+(OrderTakeProfit());
bOPN1= bOPN1+(OrderOpenPrice();
if(bSL1>0) bsumL1=bsumL1+1;
if(bTP1>0) bsumP1=bsumP1+1;
if(bOPN1>0) bsumO1=bsumO1+1;
}
if(baylot>=0.1 && baylot<0.99)
{
bSL01= bSL01+(OrderStopLoss());
bTP01= bTP01+(OrderTakeProfit());
bOPN01= bOPN01+(OrderOpenPrice();
if(bSL01>0) bsumL01=bsumL01+1;
if(bTP01>0) bsumP01=bsumP01+1;
if(bOPN01>0) bsumO01=bsumO01+1;
}
} //OP_BUY

++++++++++++++++++++++++++++++++++++++++++++++++++ Пропуск кода

Function

void TRENDS(string name, int PER, int n, int X, int Y, color Lab_Trend_Bull, color Lab_Trend_Bear, color Lab_Trend_Doj, int rsm)
{
int A,B,a,b,cod;
double Fup,Fdw;
double OPEN= iOpen(Symbol(),PER,1);
double CLOSE= iClose(Symbol(),PER,1);
double EMA21= iMA(Symbol(),PER,21,0,MODE_EMA,PRICE_CLOSE,1);
double EMA89= iMA(Symbol(),PER,89,0,MODE_EMA,PRICE_CLOSE,1);
string name2;
color_trend;
bool FLEAT=false;

while(A<1)
{
double FUPPER= iFractals(Symbol(),PER,MODE_UPPER,a);
if(FUPPER>0) { Fup=FUPPER; A++; }
a++;
}
while(B<1)
{
double FLOWER= iFractals(Symbol(),PER,MODE_LOWER,b);
if(FLOWER>0) { Fdw=FLOWER; B++; }
b++;
}
if((CLOSE>=OPEN && CLOSE<Fup) || (CLOSE<=OPEN && CLOSE>Fdw))
FLEAT=true;

if(EMA21>EMA89 && FLEAT==true)
{ cod= 114; color_trend=Lab_Trend_Doj; name2="EMA21>eme89"; } // bull
else
if(EMA21<EMA89 && ((CLOSE>=OPEN && CLOSE>=Fup) || (CLOSE<=OPEN && CLOSE>=Fup))
{ cod=111; color_trend=Lab_Trend_Bull; name2="Fractal UPPER"; } // bull
else
if(EMA21>EMA89 && ((CLOSE>=OPEN && CLOSE>=Fup) || (CLOSE<=OPEN && CLOSE>=Fup))
{ cod=110; color_trend=Lab_Trend_Bull; name2="EMA21>ema89 + FRACTAL UPPER"; } // bull
else
if(EMA21<EMA89 && FLEAT==true)
{ cod= 113; color_trend=Lab_Trend_Doj; name2= "ema21<EMA89"; } // bear
else
if(EMA21>EMA89 && ((CLOSE<=OPEN && CLOSE<=Fdw) || (CLOSE>=OPEN && CLOSE<=Fdw))
{ cod=111; color_trend=Lab_Trend_Bear; name2="Fractal LOWER"; } // bear
else
if(EMA21<EMA89 && ((CLOSE<=OPEN && CLOSE<=Fdw) || (CLOSE>=OPEN && CLOSE<=Fdw))
{ cod= 110; color_trend=Lab_Trend_Bear; name2="ema21<EMA89 + FRACTAL LOWER"; } // bear
else
if(EMA21==EMA89 || FLEAT==true)
{ cod= 110; color_trend=Lab_Trend_Doj; name2= "ema21==ema89 || Fractal"; } // doj

name=name+""+name2;
if(PER==PERIOD_MN1) cod=111;
if(cod==110)
{ rsm=rsm+3; X=X-1; Y=Y-3; }

ObjectCreate(name,OBJ_LABEL,0,0;)
ObjectSet(name,OBJPROP_CORNER,n);
ObjectSet(name,OBJPROP_XDISTANCE,X);
ObjectSet(name, OBJPROP_YDISTANCE,Y);
ObjectSetText(name,CharToStr(cod), rsm, "Wingdings",color_trend);
}
void Commen(string name, string txt, int n, int X, int Y, string shrift, color clr, int rsm)
{
ObjectCreate(name,OBJ_LABEL,0,0,0);
ObjectSet(name,OBJPROP_CORNER,n);
ObjectSet(name,OBJPROP_XDISTANCE,X);
ObjectSet(name, OBJPROP_YDISTANCE,Y);
ObjectSetText(name,txt, rsm,shrift,clr);
}

+++++++++++++++++++++++++++++++++++++++++++ and display

 
nlp2311:

...

+++++++++++++++++++++++++++++++++++++++++++ and output


"+++++++++++++++++++++++++++++++++++++++++++ and output on screen"

And learn how to insert the code correctly. Your sheet is of no interest to anyone...

Read the whole thing here.