[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 418

 
sss2019:


Thank you. So period M1 corresponds to value 1, and period M5 corresponds to value 5, so it turns out that period H1 corresponds to value 60, and period H4 corresponds to value 240 right?


Yes, that's right.

PERIOD_M1 1 1 минута
PERIOD_M5 5 5 минут
PERIOD_M15 15 15 минут
PERIOD_M30 30 30 минут
PERIOD_H1 60 1 час
PERIOD_H4 240 4 часа
PERIOD_D1 1440 1 день
PERIOD_W1 10080 1 неделя
PERIOD_MN1 43200 1 месяц
0 (ноль) 0 Период текущего графика

 

Hello!

Please help me to understand. I am trying to write a simple indicator, but it somehow gives out empty values.

It seems to me that the error lies somewhere in this place

ExtVolumesBuffer[i]=dVolume;


because the field of this operation in the ExtVolumesBuffer array does not change anything.

I understand that somewhere I made a mistake, but I do not understand where.

Thanks in advance!

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 1
#property indicator_color1 Black
//---- indicator buffers
double ExtVolumesBuffer[];
double emaExtVolumesBuffer[];

//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
SetIndexBuffer(0,emaExtVolumesBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
//---- sets default precision format for indicators visualization
IndicatorDigits(0);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("emaVolumes");
SetIndexLabel(0,"emaVolumes");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int i,nLimit,nCountedBars;
//---- bars count that does not changed after last indicator launch.
nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
if(nCountedBars>0) nCountedBars--;
nLimit=Bars-nCountedBars;
//----
for(i=0; i<nLimit; i++)
{
double dVolume=Volume[i];
ExtVolumesBuffer[i]=dVolume;
emaExtVolumesBuffer[i]=iMAOnArray(ExtVolumesBuffer,0,10,0,MODE_EMA,i);

Print(Volume[i],Volume[i+1],Volume[i+2],Volume[i+3]);
Print(ExtVolumesBuffer[i],ExtVolumesBuffer[i+1],ExtVolumesBuffer[i+2],ExtVolumesBuffer[i+3]);
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
 
sss2019:


Thank you. So period M1 corresponds to value 1, and period M5 corresponds to value 5, so it turns out that period H1 corresponds to 60, and period H4 to 240 right?

I need this construction to work: when period M1 is selected case 1 and when period M15 is selected case 15. Will it work, or is it necessary to do case 1 case 2 case 3 - in order?

int CurrentGrafPeriod ()
{
   
int Ba;
int GrafPeriod = Period();    
  switch(GrafPeriod)
    {
 
    case 1 :  Ba = 60; break;
    case 5 :  Ba = 12; break;
    case 15 : Ba = 4;  break;
    case 30 : Ba = 2;  break;
    case 60 : Ba = 1;  break;
    }
return(Ba);
}

if(CurrentGrafPeriod () == 1){ваше исполнение}
if(CurrentGrafPeriod () == 5){ваше исполнение}
и так далее...
but this is a theory - I don't know if it will work....
 
sss2019:


Thank you. So period M1 corresponds to value 1, and period M5 corresponds to value 5, so it means that period H1 corresponds to value 60, and period H4 corresponds to value 240 right?

I want this construction to work: when the period M1 is set to case 1 and when the period M15 is set to case 15. Will it work this way or is it necessary to make case 1 case 2 case 3 - in order?


First, you'd better use named constants instead of numbers 1, 5, etc. : PERIOD_M1, PERIOD_M5, etc.

Second, there is an error in your example. The Ba variable will always take value 1.

 
sss2019:


Thank you. So period M1 corresponds to value 1, and period M5 corresponds to value 5, so it means that period H1 corresponds to value 60, and period H4 corresponds to value 240 right?

I want this construction to work: when the period M1 is set to case 1 and when the period M15 is set to case 15. Will it work or is it necessary to make case 1 case 2 case 3 - in order?

1) It will work if you add a break in each line.

2) Instead of 1, 5, 15, it is better to use PERIOD_M1, PERIOD_M5, PERIOD_M15, etc.

 

Good afternoon, just came across the fact that the trading robot doesn't close the positions, about once in 50, when it reaches a profit. It then has to close everything, pendants and all, and set up again. Not closing creates order confusion and drawdown.

Can you imagine that sometimes it turns out that an order, which was definitely closed at takeprofit, has an ordercloseprice equal to zero !!!!!.

Here, look at the screenshot, here is the fifth line from the bottom; the order, conventionally called 49, closed on TakeProfit. And in the ninth line from the bottom Orderclosepriche equals zero!!!!!

 
PapaYozh:

Secondly, there is an error in your example. The variable Ba will always take the value 1.

And why? Is it missing a break?
 
dkfl.zrjdktdbx:

Good afternoon, just came across the fact that the trading robot doesn't close the positions, about once in 50, when it reaches a profit. It then has to close everything, pending orders and all, and set up again. Not closing creates order confusion and drawdown.

Can you imagine that sometimes it turns out that an order, which was definitely closed at takeprofit, has an ordercloseprice equal to zero !!!!!.

You can see in the screenshot below, here is the fifth line; the order nominally called 49 closed on TakeProfit. And in the ninth line from the bottom Orderclosepriche equals zero!!!!!


This is not orderclossepriche - it's Clowes Price - closing price of the order.

Your Expert Advisor's code needs to be corrected. It's the one that's fighting.

 

I see. It's not like there's anything in the code that's particularly complicated... I'll post it now.

When I place orders, I save the time in wremjapomnim. As soon as any order is closed at currentprofit, I delete all orders and again remember the time in the wremjapomnim pyrimen and set them.

for ( i=OrdersHistoryTotal();i>0;i--){ OrderSelect(i-1,SELECT_BY_POS,MODE_HISTORY  );
Alert( "wremjapomnim " ,wremjapomnim, "  OrderCloseTime(        )   ",  OrderCloseTime( ),  " ",i , " OrderTakeProfit( ) " ,OrderTakeProfit( ),
  " OrderClosePrice(    )  ",OrderClosePrice(   ) );
if ( OrderTakeProfit( )==OrderClosePrice(       )&&wremjapomnim<OrderCloseTime( )|| (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)<2*Point)
   &&wremjapomnim<OrderCloseTime(       )|| (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)>-2*Point)&&wremjapomnim<OrderCloseTime(       )){C=0;A=1 ;  Alert("C",C,"A",A);
   for ( int ii=OrdersTotal();ii>0;ii--){ OrderSelect(ii-1,SELECT_BY_POS );
   if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()|| OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()){ 
  OrderDelete(OrderTicket( )) ; Alert ("OrderDelete-vse",  GetLastError( ) ); stsBUY=0;stsSELL=0;
   OrderClose( OrderTicket( ), OrderLots( ), OrderClosePrice( ) , 0, CLR_NONE);Alert ("OrderClose-vse",  GetLastError( ) ); C=0; }     }              }
   
                                                      } 
 
 
melnikas:

Hello!

Please help me to understand this. I am trying to write a simple indicator, but it somehow gives out empty values.

It seems to me that the error lies somewhere in this place


because the field of this operation in the ExtVolumesBuffer array does not change anything.

I understand that I made a mistake somewhere, but I don't understand where.

Thanks in advance!


Is my case so complicated?