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

 
mersi:
Download the history and the question goes away

How do you download it?
 
kolyango:

I understand correctly:

The specific implementation is very closely tied to your conditions.

A flag is simply a variable in which the state is stored. Roughly speaking, it can be raised or lowered. Build on that and implement your logic.

 
w_ersoc:

Can you advise how to write a correct condition for the Expert Advisor to trigger 1 time with the opening of a new bar at a specified timeframe? :(

You can come up with different variants, it often uses this kind of condition:

int start()
static datetime dtBar;
//.................
if(Time[0]==dtBar) return(0);//…проверим открытие новой свечи
dtBar=Time[0]; //(тот же Бар-возврат)(новый-продолжение...)
// 
 
splxgf:

The specific implementation is very closely tied to your conditions.

A flag is simply a variable in which the condition is stored. Roughly speaking, it can be raised or lowered. Build on that and implement your logic.


Well, did I get the point right?

I understand correctly:

1. if condition1 is fulfilled, then Flag_SSSR1 is assigned a true value and we immediately start checking condition2

2. if the condition2 is fulfilled, then the true value is assigned to the flag Flag_CCP2; if not, then it is a false flag, and on the next tick

we don't check condition1 any more, and proceed directly to condition2 and so on, until condition2 is fulfilled and it takes a true value

3. then we check condition3 and Flag_USSR2 (and what exactly in USSR2 is checked if it is true or false, or what?)

Is this correct? There is not a single transaction in the tester... Although there should be if it's right. What is wrong...?

static bool Val_max, Cl_dn, Val_min; //static or global
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   int
   i, j, total,
   cnt,
   OrderBuy,
   OrderSell,
   Magic,
   Ticket,                                      // Номер ордера
   Total=0,                                     // Количество ордеров в окне
   Tip=-1;                                      // Тип выбран. ордера (B=0,S=1)      
   double
   Open_0,
   ask,
   bid,
   Price,                                       // Цена выбранного ордера
   SL,                                          // SL выбранного ордера
   TP,                                          // TP выбранного ордера
   Lot;                                         // Колич. лотов в выбран.ордере
   Open_0=Open[0];                             // Цена откр. формирующегося бара
   ask=Ask;                                    // Текущая цена покупки
   bid=Bid;                                    // Текущая цена продажи
   string
   Symb;                                        // Название финанс. инструмента
   Symb=Symbol();                               // Название фин.инстр.
double Value_max=1.0000;
double Value_min=0.9980;
double Open_1= Open[1];
double Close_1= Close[1];
//----

//--------------------------------------------------------------- 4 --

double Val=iCustom(NULL, 0, "HMR MULTI Indicator",0,0);   
if (Val >= Value_max) Val_max=true;                  // 
if (Open_1 > Close_1) Cl_dn=true;
if (Val <= Value_min && Cl_dn==true) Val_min=true;
if (Val_max==true && Cl_dn==true && Val_min==true)
  {
   for (j = 0; j < OrdersTotal(); j++)
    {
     OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
     if (OrderSymbol() == Symbol())
      {
      if (OrderType() == OP_SELL) return(0);
      }
    }

   OrderSend(Symbol(),OP_SELL,0.1,NormalizeDouble(Bid,Digits),2,Bid+400*Point,Bid-400*Point,"",3,Red);  // Открытие SELL
   Val_max=false; Cl_dn=false; Val_min=false;
  }

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

Hi!

I set a goal of limiting simultaneous open positions to 1.

With the variable Open/Close level = 3/2 multiplied by Point, placed in the open/close position conditions I tried to solve this task, but did not succeed.

Please help me figure it out :)

 
kolyango:


Is this the right thing to do? There's not a single transaction in the tester... Although there should be if it's right. What's wrong...?

Now, write out the conditions in full again in normal language and you can correct the code... The good thing about signals is that they should have an expiry date and cancellation.
 
skyjet:

Hi!

I have set a goal of limiting simultaneously open positions to 1.

if(OrdersTotal()> 0) return;

Or a variation with the symbol and throwing out pending orders.

 

i.e. in my version

if(OrdersTotal()> 1)return;

?

 
splxgf:
Now, write out the conditions in full again in normal language and you can correct the code... The good thing about signals is that they should have an expiry and cancellation period.

All these conditions may not follow each other at once (may be after an hour or two or three), so we need to make it so as soon as the indicator reaches 1.0000, this condition is not checked at every tick, and wait until one bar closes with fall, and after that these 2 conditions are not checked at every tick, and wait until the indicator reaches 0.9980 or less. As soon as all conditions are fulfilled we open a market order to sell 0.1 lot with a stop loss of 400p and take profit of 400p.
 
skyjet:

i.e. in my version

if(OrdersTotal()>1)return;

?

Better still the first option, place before attempting to open an order(OrderSend)
Reason: