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

 
OK guys, thank you very much, very helpful, sorry for the "guts" ))
 
Parn25:

Help me out here, people!!!

I am trying to develop an Expert Advisor based on the morning channel strategy. The essence is this: at 6:01 on EURGBP pair determine the channel of price movement from 0 o'clock till 6 am. We set two pending orders and if the triggered pending order is closed by a stopper, we open an order in the opposite direction. It is the second part of the strategy that does not work. I.e., if a stop has triggered, we cannot open an order in the opposite direction.

You need to put a stop on the stop right away! It'll trigger it automatically.

I found this in the trash, maybe it'll come in handy.

void OrderCloseAll(){
   for (int i=0;i<OrdersTotal();i++)
     if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      if(OrderType()==OP_BUY)
       OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, CLR_NONE);
      else
      if(OrderType() == OP_SELL)
       OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, CLR_NONE);
}

void OrderDeleteAll(int lots){
     for (int i=0;i<OrdersTotal();i++)
         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if (OrderType()>1&&OrderType()<6)
         if(OrderLots()==lots){
          OrderDelete(OrderTicket());
          i=0;
         }
}
 //----------------------------------------------------
// покупка
void OpenBuyLIMIT(double lot, double price){
   double   SL = NormalizeDouble(price,Digits) - Loss*Point;
   double TP = NormalizeDouble(price,Digits) + Target*Point-MarketInfo(Symbol(),MODE_SPREAD)*Point;
    OrderSend(Symbol(), OP_BUYLIMIT, lot,  NormalizeDouble(price,Digits), Slippage, SL, TP, NULL, STUPID, 0, Blue);
}
 //----------------------------------------------------
// продажа
void OpenSellLIMIT(double lot, double price){
   double   SL = NormalizeDouble(price,Digits) + Loss*Point;
   double TP = NormalizeDouble(price,Digits) - Target*Point+MarketInfo(Symbol(),MODE_SPREAD)*Point;
   OrderSend(Symbol(), OP_SELLLIMIT, lot,  NormalizeDouble(price,Digits), Slippage,  SL, TP, NULL, STUPID, 0, Red);
}
 //----------------------------------------------------
// покупка
void OpenBuySTOP(double lot, double price){
   double   SL = NormalizeDouble(price,Digits) - Loss*Point;
   double TP = NormalizeDouble(price,Digits) + Target*Point-MarketInfo(Symbol(),MODE_SPREAD)*Point;
   OrderSend(Symbol(), OP_BUYSTOP, lot,  NormalizeDouble(price,Digits), Slippage, SL, TP, NULL, STUPID, 0, Blue);
}
 //----------------------------------------------------
// продажа
void OpenSellSTOP(double lot, double price){
  double   SL = NormalizeDouble(price,Digits) + Loss*Point;
  double TP = NormalizeDouble(price,Digits) - Target*Point+MarketInfo(Symbol(),MODE_SPREAD)*Point;
   OrderSend(Symbol(), OP_SELLSTOP, lot,  NormalizeDouble(price,Digits), Slippage,  SL, TP, NULL, STUPID, 0, Red);
}
Files:
 
Parn25:

Folks, help me out a little!!!

I am trying to write an EA using the morning channel strategy. The essence is this: at 6:01 on EURGBP pair we determine the channel of price movement from 0 o'clock till 6 am. We set two pending orders and if the triggered pending order is closed by a stopper, we open an order in the opposite direction. It is the second part of the strategy that does not work. I.e., if a stop has triggered, we cannot open an order in the opposite direction.
The example with a pending order is approximately as follows.
Files:
 
costy_:
The example with the pendulum is something like this.
OK thanks, I'll give it a try!!!
 

Hello.

Today is the weekend, so I have only the visual tester working :) I start in the Strategy Tester the script to unload indicator values to a file but it unloads from the current real date (October 28 23:55).

How do I transfer the value (time) of the last bar of the visual tester to the script?

int start =iBarShift(NULL,0,Time[2200+EndB-1]);
int end   =iBarShift(NULL,0,Time[EndB]);

How to pass and calculate in the script EndB - value of the last bar in the tester?

P.S. As a last resort, I'll put all the script code in the Expert Advisor, etc.

 

Good afternoon!

I'm studying the textbook, if I may ask a question about the study material. If there is a separate topic for these questions, I would be grateful for a link.

I am trying to figure out ROC indicator (the code is in the attached file).

If I understand it correctly, the indicator logic is as follows:

in the current graph the reference MA is taken, from it the line of change in velocity V is drawn,

further the MA of the next (larger TF) is calculated, but not displayed; the next line V is calculated from it.

The same for the next timeframe.

Question: I do not understand the given record

extern int Bars_V =13; // Number of bars for speed calculation
The explanations of the indicator code says that the speed is calculated as a difference of 2 bars.

And more .....

I have downloaded the code of this indicator to MT4, on H4 it 's not on the current bar but about 9-10 days ago according to the history.

On other timeframes it's ok. Why is it so?

Thank you in advance for your help, Regards Olga

Files:
my_roc.mq4  8 kb
 

Good day!

All open positions must be closed after the specified time interval, i.e. the lifetime of the open position must correspond to the selected interval.

Question. Are there any other solutions except for OrderOpenTime()?

 
Zar:

Hello.

Today is the weekend, it means that only the visual tester works :) I start the script in the tester to unload indicator values to a file and it unloads from the current real date (October 28 23:55).

How do I transfer the value (time) of the last bar of the visual tester to the script?

How to pass and calculate in the script EndB - value of the last bar in the tester?

P.S. As a last resort, I'll put all the script code in the Expert Advisor, etc.

The script will not find the tester time so easily (the indicator will, though), you can attach it to the start of the test.EA

int start()
{
GlobalVariableSet( "Time_test", Time[0]) ;
.....................

and in the script

datetime time_start=GlobalVariableGet( "Time_test");

quickly and reliably ...

 
Operr:

Good day!

All open positions must be closed after the specified time interval, i.e. the lifetime of the open position must correspond to the selected interval.

Question. Are there any other solutions, except for OrderOpenTime()?

There are a lot of options, e.g. we can write the open time into the file, but it would be easier to scroll through the open orders and compare the remaining time.

In general, rephrase ... "All open positions must be closed after the specified time interval" for each individual position (that's how I understood the question).

 
LOA:

Good afternoon!

I'm studying the textbook, if I may ask a question about the study material. If there is a separate topic for these questions, I would be grateful for a link.

I am studying the ROC indicator (the code is in the attached file).

If I understand it correctly, the indicator logic is as follows:

in the current graph the reference MA is taken, from it the line of change in velocity V is drawn,

further the MA of the next (larger TF) is calculated, but not displayed; the next line V is calculated from it.

The same for the next timeframe.

Question: I do not understand this record

extern int Bars_V =13; // Number of bars for vel ocity calculation
The explanations of the indicator code states that the velocity is calculated as a difference between the values of 2 bars.

And more.....

I have loaded this indicator code in MT4, on H4 it's not on the current bar but about 9-10 days ago according to the history.

On other timeframes everything is OK. Why is it so?

I am very thankful for your help in advance.

"larger TF" - no, the same MA but the data is taken with an offset Sh_1 re Sh_1=Bars_V; // The period of measured speed (bars)

"Similar for the next timeframe" - no, there is a switch at the beginning (for each timeframe coefficients are different K2, K3)

    switch(Period())                 // Расчёт коэффициентов для..
     {                             // .. различных ТФ
      case     1: K2=5;K3=15; break;// Таймфрейм М1
      case     5: K2=3;K3= 6; break;// Таймфрейм М5
      case    15: K2=2;K3= 4; break;// Таймфрейм М15
      case    30: K2=2;K3= 8; break;// Таймфрейм М30
....
Period_MA_2 =K2*Period_MA_1;   // Расчётн.период МА для ближ. ТФ
Period_MA_3 =K3*Period_MA_1;   // Расчётн.период МА для след. ТФ

The definition "Calculated MA period for the next TF" is not true, mistakes are always present in the textbooks (especially the "stories" are very like)

"Question: I do not understand the following entry

extern int Bars_V =13; // Number of bars for speed calculation" search further by the code Bars_V ...

   Sh_1=Bars_V;                   // Период измерен скорости (баров)

then what is Sh_1, this value is the offset MA 1 speed line, etc.

// Предназначен для использования в качестве примера в учебнике MQL4.
not a good example, read something simpler from the standard indicators...