[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 494

 
Please advise, how can you use a muving value from a few bars ago for the calculation, i.e. from the history? If it is just a moving average
AlligatorJawsBuffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);
What if it is -5 bars ago?
 
hoz:

Of course I understand. Except that I've never seen the presence of an order analysed in this way before:

usually just without ==true... I liked that point. Although, it is interesting, I have not seen this method in other EAs. I understand the logic, but still.


Try and experiment with different variants, it will be easier to understand everything! Good luck!
 
hoz:

Of course I understand. Except that I've never seen the presence of an order analysed in this way before:

usually just without ==true... I liked that point. Although, it is interesting, I have not seen this method in other EAs. I understand the logic, but still.

One and the same action in the code may be written in different ways and all will be executed correctly. The difference can be seen either in the simplicity of writing the code or its speed, or both of them together and you can say that the code was written by a pro.
 
Can you tell me how to stop the expert? A search did not yield anything meaningful :((
 
fmillion:
Can you tell me the function to stop an EA? The search did not give anything clear :(((

No problem:

bool ОстановкаСоветника (bool Причина)
{if (Причина) return (true) else return (false);}

int start()
{
    if (ОстановкаСоветника (Причина)) return (0);
    //---- Код советника

}

and you can also use the "Advisors" button in the terminal to disable an EA.

 

Hello

Could you please tell me

When I go through the OrderSelect function, the orders are sorted by the order number, not by ticket

What parameter are these orders sorted by?

I noticed that they are sorted by opening time of the order, i.e. the last order is the latest in terms of opening time, either market or pending

is it always like this in this function or is it different?

i.e. is it always possible to get a ticket of the last opened/placed order in this way ?

 
while(!IsTradeAllowed()) Sleep(500);
RefreshRates();
if(Cmd == 0) PR = Bid; else PR = Ask;
int tic=OrderSend(Symbol(),Cmd,Lot,PR,Slippage,0,",Magic,0,CLR_NONE);
if(tic<0){
Print("Order open error: ",GetLastError());
Print("Pair=",Symbol(),"...Command=",Cmd,"...Lot=",Lot,"...Price=",DoubleToStr(PR,Digits));

}

Slippage = 5 points

Error 129 )) ..... where the hell is it ? what's wrong ?

 
fmillion:
while(!IsTradeAllowed()) Sleep(500);
RefreshRates();
if(Cmd == 0) PR = Bid; else PR = Ask;
int tic=OrderSend(Symbol(),Cmd,Lot,PR,Slippage,0,",Magic,0,CLR_NONE);
if(tic<0){
Print("Order open error: ",GetLastError());
Print("Pair=",Symbol(),"...Command=",Cmd,"...Lot=",Lot,"...Price=",DoubleToStr(PR,Digits));

}

Slippage = 5 points

Error 129 )) ..... where the hell is it ? what's wrong ?

Try it like this:

if(Cmd == 0) PR =Ask; else PR =Bid;

I think this will help.

 

Here's the script:

//+------------------------------------------------------------------+
//|                                Brooky_FibIt_Extension_Script.mq4 |
//|                        Copyright 2012, www.Brooky_Indicators.com |
//|                                        www.Brooky_Indicators.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, www.Brooky_Indicators.com"
#property link      "www.Brooky_Indicators.com"
#property show_confirm  
#property show_inputs
//+---------------------
//| script program start function                                    |
//+------------------------------------------------------------------+

extern int       FibOnChartNum =1;

extern color     Fib_Cbar_Color = Red;
extern int       Fib_Cbar_Size=1;
extern int       Fib_Cbar_Style=2;

extern color     Fib_Level_Color = Gray;
extern int       Fib_Level_Size=1;
extern int       Fib_Level_Style=2;

extern double     Fib_Level_1 = -0.117;
extern double     Fib_Level_2 = 0;
extern double     Fib_Level_3 = 1;
extern double     Fib_Level_4 = 1.618;
extern double     Fib_Level_5 = 2;
extern double     Fib_Level_6 = 2.382;
extern double     Fib_Level_7 = 3;

string Xtra_txtFib_Level_1  = "(SL) ";
string Xtra_txtFib_Level_2  = "";
string Xtra_txtFib_Level_3  = "";
string Xtra_txtFib_Level_4  = "(TP1)";
string Xtra_txtFib_Level_5  = "(TP2)";
string Xtra_txtFib_Level_6  = "Re Entry Break ";
string Xtra_txtFib_Level_7  = "";


string txtFib_Level_1  = "";
string txtFib_Level_2  = "";
string txtFib_Level_3  = "";
string txtFib_Level_4  = "";
string txtFib_Level_5  = "";
string txtFib_Level_6  = "";
string txtFib_Level_7  = "";


string FibPrice = " @ %$";
string FibName = "";


int start()
  {
//----
      txtFib_Level_1 = StringConcatenate(Xtra_txtFib_Level_1,DoubleToStr(Fib_Level_1,3),FibPrice);
      txtFib_Level_2 = StringConcatenate(Xtra_txtFib_Level_2,DoubleToStr(Fib_Level_2,3),FibPrice);
      txtFib_Level_3 = StringConcatenate(Xtra_txtFib_Level_3,DoubleToStr(Fib_Level_3,3),FibPrice);
      txtFib_Level_4 = StringConcatenate(Xtra_txtFib_Level_4,DoubleToStr(Fib_Level_4,3),FibPrice);
      txtFib_Level_5 = StringConcatenate(Xtra_txtFib_Level_5,DoubleToStr(Fib_Level_5,3),FibPrice);
      txtFib_Level_6 = StringConcatenate(Xtra_txtFib_Level_6,DoubleToStr(Fib_Level_6,3),FibPrice);
      txtFib_Level_7 = StringConcatenate(Xtra_txtFib_Level_7,DoubleToStr(Fib_Level_7,3),FibPrice);
      
      
      
      FibName = "Brooky_Fib_"+FibOnChartNum;
      ObjectDelete(FibName);
      
      ObjectCreate(FibName,OBJ_FIBO,0,Time[9],High[24],Time[1],Low[1]);
      
      ObjectSet(FibName, OBJPROP_COLOR,Fib_Cbar_Color);
      ObjectSet(FibName, OBJPROP_WIDTH ,Fib_Cbar_Size);
      ObjectSet(FibName, OBJPROP_STYLE ,Fib_Cbar_Style);
      
      ObjectSet(FibName, OBJPROP_RAY,True);
       
      ObjectSet(FibName, OBJPROP_LEVELSTYLE,Fib_Level_Style);
      ObjectSet(FibName, OBJPROP_LEVELCOLOR,Fib_Level_Color);      
      ObjectSet(FibName, OBJPROP_LEVELWIDTH,Fib_Level_Size);  
       
          
      ObjectSet(FibName, OBJPROP_FIBOLEVELS,7);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+0,Fib_Level_1);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+1,Fib_Level_2);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+2,Fib_Level_3);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+3,Fib_Level_4);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+4,Fib_Level_5);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+5,Fib_Level_6);
      ObjectSet(FibName, OBJPROP_FIRSTLEVEL+6,Fib_Level_7);
      

     
      ObjectSetFiboDescription(FibName,0,txtFib_Level_1);
      ObjectSetFiboDescription(FibName,1,txtFib_Level_2);
      ObjectSetFiboDescription(FibName,2,txtFib_Level_3);
      ObjectSetFiboDescription(FibName,3,txtFib_Level_4);
      ObjectSetFiboDescription(FibName,4,txtFib_Level_5);
      ObjectSetFiboDescription(FibName,5,txtFib_Level_6);      
      ObjectSetFiboDescription(FibName,6,txtFib_Level_7);
//----
   return(0);
  }
//+------------------------------------------------------------------+

There's a gimmick like this:

string FibPrice = " @ %$"

The question arises, what does this even mean?

Is it just a set of characters or does it make sense?

 
RaYDeR.tr:

Hello

Could you please tell me

When I go through the OrderSelect function, the orders are sorted by the order number, not by ticket

What parameter are these orders sorted by?

I noticed that they are sorted by opening time of the order, i.e. the last order is the latest in terms of opening time, either market or pending

is it always like this in this function or is it different?

i.e. is it always possible to get a ticket of the last opened/placed order in this way ?

Unfortunately, the other way also happens. I have already tried it. So it's better to search the list for the last order by the maximum opening time.
Reason: