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

 

Remind me of the situation

Please advise in the following:

1.there is a function "if (timecur == "08:00:00") OrderSend (Symbol(), OP_BUY, Loot, Ask, 50, SL, TP,NULL,0,0,L);"

2.Testing it from 23.08.2010-23.10.2010.

3.Until 12.10.2010 trades were opened normally by 1 pc.

4.But now the 12.10.2010 function opens as much transactions as the deposit allows (about 7 pc).

I can not understand the reason, may be that for a second has time to pass at least 5 ticks and therefore has time to open so much? or there is another matter? if all the same first option, please advise how to prescribe the deal opened only once?

I would be very grateful, thank you.

 
The easiest way to do this is to check that a given number of orders are in the market before opening a new order.
 
Boneshapper:

Remind me of the situation

Please advise in the following:

1.there is a function "if (timecur == "08:00:00") OrderSend (Symbol(), OP_BUY, Loot, Ask, 50, SL, TP,NULL,0,0,L);"

2.Testing it from 23.08.2010-23.10.2010.

3.Until 12.10.2010 trades were opened normally by 1 pc.

4.But now the 12.10.2010 function opens as much transactions as the deposit allows (about 7 pc).

I can not understand the reason, may be that for a second has time to pass at least 5 ticks and therefore has time to open so much? or there is another matter? if all the same first option, please advise how to prescribe the deal opened only once?

I would be very grateful, thank you

Here is a simple function that checks the number of open orders:

 int Opened(){
     int Orders=0;
     for (int cnt=OrdersTotal()-1; cnt>=0; cnt--){
       if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()==Symbol()){
           if(OrderMagicNumber()==Magic){
               if(OrderType()<2)Orders++;
      } } } }       
  return(Orders);
} 

Function Opened() should be located outside of function start(). It can be at the very end of the code.

Insert it in your condition:

if (timecur == "08:00:00" && Opened()==0) OrderSend (Symbol(), OP_BUY, Loot, Ask, 50, SL, TP,NULL,0,0,L);
 
DhP:

Here is a simple function to check the number of open orders:

Insert in your condition:


Yes, it really helped, but it's just that I will be opening several orders, and they shouldn't be related to each other. I would like to limit opening of a deal with a certain flag, and that's it.

I wrote it like this

int Control;

if ((timecur == "08:00:00") && (Control == 0)) OrderSend (Symbol(), OP_BUY, Loot,Ask, 50, SL, TP,NULL,0,0,L);
Alert(GetLastError());
Control = 1;

And zero was returned only when I closed the order

OrderClose(Ticket,Loot,Bid,50,R);
Alert (GetLastError());
Control = 0;

But why this entry didn't help, maybe I made a mistake somewhere? Please help me

 
Boneshapper:


Yes, it really helped, but it's just that I will be opening several orders, and they shouldn't be related to each other. I would like to limit the opening of a deal with a certain flag and that's it.

I wrote it like this

int Control;

if ((timecur == "08:00:00") && (Control == 0)) OrderSend (Symbol(), OP_BUY, Loot,Ask, 50, SL, TP,NULL,0,0,L);
Alert (GetLastError());
Control = 1;

And zero was returned only when I closed the order

OrderClose(Ticket,Loot,Bid,50,R);
Alert (GetLastError());
Control = 0;

But why this entry didn't help. am i wrong somewhere? please help

You can "shred" the function any way you want. It can fulfill all your wishes.

For example, you can specify what type of operations you are interested in or what Magics, or enter a position open time condition and many more.

Here is an example of separation into Buy and Sell:

 int Opened(int OP){
     int Orders=0;
     for (int cnt=OrdersTotal()-1; cnt>=0; cnt--){
       if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()==Symbol()){
           if(OrderMagicNumber()==Magic){
               if(OP==OP_BUY)Orders++;
               if(OP==OP_SELL)Orders++;
      } } } }       
  return(Orders);
 } 

Our possibilities are limited only by our imagination. You will surely succeed.

 
DhP:

You can 'shred' the function as you like. It can fulfil all your wishes.

For example, you can specify what type of operations you are interested in, or which MAGICs, or enter a position open time condition and more.

Here is an example of separation into Buy and Sell:

Our possibilities are limited only by our imagination. Be daring and it will work.


I will try it, thank you very much!
 

By the way, about Flags.

You can use the various Flags as a relay system to toggle the actions of different operations. They are quite capable of fulfilling any of your desires.

But it is important to have a clear picture of what and how you want it to work.

Just like in a railway junction, you need to have a clear picture of how the switches work.

 

Dear pros, can you tell me... I have a script to plot my calculations on a chart. In order to start drawing, I have to drag and drop it on the chart from the navigator. My question, is it possible to make the script get called from the panel "Graphic Tools" by pressing a key (my own, or assigned to one of the existing ones)?

 
kon12:

Dear pros, tell me... I have a script to plot my calculations on the chart. In order to start drawing, I have to drag and drop it on the chart from the navigator. Question - is it possible to make the script get called from the "Line Studies" panel by pressing a key (my own or the assigned one)?


Hot keys

Hot keys (accelerator keys) are keys and key combinations that allow you to quickly execute various commands without having to use menus or control panels.

  • " ï " - chart scrolling to the left;

  • " ð " - chart scrolling to the right;

  • " ñ " - fast chart scrolling to the left; in case of fixed scale - chart scrolling upwards;

  • ð " " - fast chart scroll to the right, and in case of fixed scale - chart scroll down;

  • Numpad 5 - restoring the automatic chart vertical scale after it has been changed. And in case of fixed scale - return the graph back to the view limits;

  • Page Up - fast chart scroll to the left;

  • Page Down - fast chart scrolling to the right;

  • Home - move graph to the beginning;

  • End - move graph to the end;

  • "-" - zoom out on the graph;

  • "+" - zoom in on the chart;

  • Delete - delete all selected graphical objects;

  • Backspace - delete the latest objects in the chart window;

  • Enter - open/close the quick navigation window;

  • Esc - close dialog windows;

  • F1 - open this "User's Guide" window;

  • F2 - open "Quotes archive" window;

  • F3 - open the "Global Variables" window;

  • F4 - load MetaEditor;

  • F6 - call "Tester" window for testing of Expert Advisor attached to a chart window;

  • F7 - call window with properties of the Expert Advisor attached to the chart window to change settings

  • F8 - call the " Chart Settings" window;

  • F9 - call the "New Order" window

  • F10 - open the "Quotes window";

  • F11 - switch on/off full screen mode;

  • F12 - shift chart one bar to the left;

  • Shift+F12 - shift the chart by one bar to the right;

  • Shift+F5 - switch to the previous profile;

  • Alt+1 - show chart as a sequence of bars (convert it to a bar chart);

  • Alt+2 - show chart as a sequence of Japanese candlesticks (transform it into a candlestick chart);

  • Alt+3 - show chart as a broken line (convert it to a line chart);

  • Alt+A - copy all testing or optimization results of the Expert Advisor to the clipboard;

  • Alt+W - call the chart management window;

  • Alt+F4 - close the client terminal;

  • Alt+Backspace or Ctrl+Z - cancel removal of object;

  • Ctrl+A - set default height for all indicator windows;

  • Ctrl+B - call the "Objects List" window;

  • Ctrl+C or Ctrl+Insert - copy to buffer;

  • Ctrl+E - enable/disable use of the Expert Advisor;

  • Ctrl+F - enable/disable "Crosshair";

  • Ctrl+G - show/hide grid;

  • Ctrl+H - show/hide OHLC line;

  • Ctrl+I - call the "Indicators List" window;

  • Ctrl+L - show/hide volumes;

  • Ctrl+P - print chart;

  • Ctrl+S - save chart to a file with "CSV", "PRN", "HTM" extensions;

  • Ctrl+W or Ctrl+F4 - close the chart window;

  • Ctrl+Y - show/hide period separators;

  • Ctrl+Z or Alt+Backspace - cancel deletion of an object;

  • Ctrl+D - open/close "Data window";

  • Ctrl+M - open/close "Market Watch" window;

  • Ctrl+N - open/close the " Navigator" window;

  • Ctrl+O - open/close the " Settings" window;

  • Ctrl+R - open/close the " Tester" window;

  • Ctrl+T - open/close the " Terminal" window;

  • Ctrl+F5 - switch to the next profile;

  • Ctrl+F6 - activate next chart window;

  • Ctrl+F9 - open the "Terminal - Trade" window and switch the control focus there. After that you can manage the trading activity using the keyboard.

It is possible to assign hotkeys to call any element of the "Navigator" window, except for elements of the "Accounts" group. In order to assign a shortcut to an element, one should execute the "Assign Hot Key" command of its context menu. Assigned hotkeys have higher priority than predefined ones. For example, initially Ctrl+O corresponds to calling the terminal settings window. If On Balance Volume indicator can be also assigned to this combination, pressing Ctrl+O will not open the terminal settings window.

 
Vinin:

Hot keys

Hot keys (accelerator keys) are keys and key combinations that allow you to execute various commands quickly without having to use menus or control panels.


I did not express myself precisely. Question - is it possible to make a script to be called from the "Graphic tools" panel by clicking an icon (e.g. Fibo icon)?
Reason: