[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 187

 
NayTmeR:

For example, when line val1[c] crosses 0.45 upwards, the time value is assigned to variable TimeBegin

what is the question? how to store the time when crossing? first check if there is an intersection, then store
 

How do you assign this time to a variable ?

 
eddy:
Well, the arrows are on the opening bar.

I'm not quite sure I understand. there are arrows on the opening bar, but drawn by the corresponding function - OrderSend(). These arrows are not related to the arrows drawn by OrderModify(), are they? I understood that using OrderModify(), I not only colour arrows, but also change the level of stop loss, by changing the value of variable SL? It is written in the help:

bool OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE)

Changes parameters of previously opened positions or pending orders.

It means that it changes not only the arrow colour but also "changes parameters of previously opened" orders. It suggests that it should change stops and draw arrows. But it doesn't do it for some reason.

 

The word "only" was about the arrow, not about what the function does.

стрелки на баре открытия есть, но нарисованные соответствующей функцией - OrderSend(). Эти стрелки же не относятся к стрелкам, рисуемым OrderModify()?

What I'm talking about, you set a stop and/or a take, and that's how the arrows change.

 
NayTmeR:

How do you assign this time to a variable ?

there is a function for this in kim's book
 
todem:
there is such a feature in Kim's collection

Can you be more specific? Where do I find it? Where can I find the Kim's collection?
 
eddy:

The word "only" was about the arrow, not about what the function does.

You can use the function to set a stop and/or a take, so its arrows will change.

The OrderModify() manual says:

arrow_color - Colour of StopLoss and/or TakeProfit modification arrows on the chart. If this parameter is missing or its value is CLR_NONE, the arrows will not appear on the chart.

That is, as far as I understood it, OrderModify() draws sticks because it says "MODIFICATION arrows", which means that there are not only open/close arrows created by OrderSend, but also modification arrows created by OrderModify. And these MODIFICATION arrows can be missing only if parameter is absent or equal to CLR_NONE. But my parameter is present and equal to "Green". I understood that there is no special parameter responsible for presence or absence of modification arrows, it is controlled by absence or equality of its CLR_NONE. I judge by analogy with OrderSend in the same helper:

arrow_color - colour of opening arrow on the chart. If the parameter is missing or its value is CLR_NONE, the opening arrow is not displayed in the graph.

 

Please help with isCloseLastPosByStop function ().

I insert into MetaEditor function isCloseLastPosByStop () (but only what is written on https://www.mql5.com/ru/forum/107476/page21).

After an unsuccessful compilation I get errors:

'(' - function definition unexpected

't' - variable not defined

't' - variable not defined

'}' - unbalanced parentheses

It's this function, as I've commented on the rest of the code.

 

Hi all! Please help combine the following things. The result should be: two lines following the price, one 20 pips below Ask,

the other one is higher. Besides, I get a beep if price changes by 20 points per 1 tick.

All works fine separately. Thanks in advance!

1) The line is 20 pips below Ask.

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int start()
{
ObjectCreate("MyPriceLine", OBJ_HLINE, 0, 0, Ask-20*Point) ;
ObjectSet("MyPriceLine", OBJPROP_PRICE1, Ask-20*Point);
return(0);
}

//+------------------------------------------------------------------+

2) Line above Ask by 20p.

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int start()
{
ObjectCreate("MyPriceLine", OBJ_HLINE, 0, 0, Ask+20*Point) ;
ObjectSet("MyPriceLine", OBJPROP_PRICE1, Ask+20*Point);
return(0);
}

//+------------------------------------------------------------------+

3) Rate of price change over time.

#property show_inputs

extern int int pips=2; //change Ask
extern double Time_=0.1; //c. ~ tick
extern bool all_from_view=true; //only current symbol - false

int i, l, p, number_of_characters;
string val[], on_screen;
int Ask_save[];

//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
void start(){
number_of_characters=SymbolsList(val, true);//write tools and their number in the val array call SymbolsList function
ArrayResize(Ask_save,number of_characters);
if(number of_characters == -1){ Alert("SymbolsList(string &Symbols[], bool Selected) failed"); return;}
if(!all_from_selected){
number_of_characters=1;
ArrayResize(Ask_save,number_of_characters);
ArrayResize(val,number of_characters);
val[0]=Symbol();
}

while(true&&!IsStopped()){ //if allowed and not stopped the script will continue

Alert("recalculate in "+Time_+" sec;)

for(i=0;i<number of_characters;i++){ //calculate spread value for symbols from market watch
if((Ask_save[i]-MarketInfo(val[i],MODE_ASK)/MarketInfo(val[i],MODE_POINT))>=pips){
Alert(val[i]+", "+Period()+" changed downwards by "+DoubleToStr((Ask_save[i]-MarketInfo(val[i],MODE_ASK)/MarketInfo(val[i],MODE_POINT)),0)+" pips");
PlaySound("timeout.wav");
}
if((MarketInfo(val[i],MODE_ASK)/MarketInfo(val[i],MODE_POINT)-Ask_save[i])>=pips){
Alert(val[i]+", "+Period()+" changed upwards by "+DoubleToStr((MarketInfo(val[i],MODE_ASK)/MarketInfo(val[i],MODE_POINT)-Ask_save[i]),0)+" pips");
PlaySound("email.wav");
}
Ask_save[i]=MarketInfo(val[i],MODE_ASK)/MarketInfo(val[i],MODE_POINT);
}
Sleep(Time_*1000);//pause for sec.
}

/*
number_of_characters=SymbolsList(val, true);//write tools and their number in val array SymbolsList function call
if(number of_characters == -1){ Alert("Error opening file in SymbolsList(string &Symbols[], bool Selected)"); return;}

while(true&&!IsStopped()){ //if allowed and not stopped the script will continue
on_screen="\r\n"; // indent
for(i=0;i<number of_characters;i++)//calculate spread value for symbols from the market review
on_screen=on_screen+val[i]+" spread cost = " + DoubleToStr(MarketInfo(val[i],MODE_SPREAD)*MarketInfo(val[i],MODE_TICKVALUE),0)+"\r\n";
Comment(to_screen);//display
Alert("recalculate");//signal
Sleep(3000);//pause for 3 seconds.
}
*/
}
void deinit(){Comment("");}
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//the function reads all financial instruments from the Market Watch.
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
int SymbolsList(string &Symbols[], bool Selected){
int Offset, SymbolsNumber; string SymbolsFileName;
if(Selected) SymbolsFileName = "symbols.sel"; else SymbolsFileName = "symbols.raw";
int hFile = FileOpenHistory(SymbolsFileName, FILE_BIN|FILE_READ);
if(hFile < 0) return(-1); if(Selected) { SymbolsNumber = (FileSize(hFile) - 4) / 128; Offset = 116; }
else { SymbolsNumber = FileSize(hFile) / 1936; Offset = 1924; }
ArrayResize(Symbols, SymbolsNumber);
if(Selected) FileSeek(hFile, 4, SEEK_SET);
for(int i = 0; i < SymbolsNumber; i++){Symbols[i] = FileReadString(hFile, 12); FileSeek(hFile, Offset, SEEK_CUR);}
FileClose(hFile);
return(SymbolsNumber);
}

 
globad:

Hello all! Please help combine the following things. The end result should be: two lines following the price one below Ask by 20 pips,....

This is disrespectful to those you are asking. Learn how to properly post code -> SRC