Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 313

 


I like to criticise, but there's a lot of - just a little bit on the first paragraph

The archive isn't fastening properly (( I'll upload it to a file-sharing site now.

 
VladislavVG:

If this always the nearest then it can be quite simple and magicians are of course not needed. But we have not heard anything about that from PGM5, and in the general case it may be not the nearest order but an order any farther from the current price and in between orders may be placed due to other reasons: we do not know anything about the decision making algorithm. We were only speaking about related orders.
For some reason I have it in my mind that the nearest one should be removed. The rest of them are all further away and open under different conditions. And since the nearest pending order is opposite to the market one, we have all the data to find it correctly.
 
PGM5:
Thank you for your support. Can you tell me where to look for the answer to this question. Yes, one more thing: orders should be set when an order is triggered and when takeprofit is triggered and the closest one should be deleted before that. Thanks in advance.

You are already starting to write the TOR. Have you even started to do something? Or are you waiting for the fish? In this thread they help those who want to learn how to program in mql4 for free, not those who want to get a free ready-made solution.
 
43
alexey1979621 29.11.2013 11:52 #

Greetings all! I am asking for help in solving an interesting problem. There is an EA, the feature of which is that after getting a profit the next trades from 1 to 4 are closed at stop loss, then profit again. The Expert Advisor opens trades based on the indicator signal. To exclude profitable trades following after the profit, one should skip the signals generated by the indicator, i.e. not close deals (1,2,3,4) after getting a profit. The Sig function is available for this purpose. However, I think I wrote this function wrong since the EA does not open orders with it at all and everything is working very clear without it. Maybe there is also an error in the condition. In general, .... I don't know what the hell it is, I have not been able to fix this blockage for two weeks. Could you advise me, smart people, where is the error?

Yes, signal is the number of signals after a profit and pynkt is the size of the profit in pips.

I would be grateful for any help.

void CheckForOpen()
{
   int ticket, STOPLEVEL;
   double Price, SL, TP; 
   STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL);


   double MA1Low = NormalizeDouble (iMA(NULL,0,MA_Period_2,MA_Shift_2,MA_Method_2,0,1), Digits); 
   double MA2High = NormalizeDouble (iMA(NULL,0,MA_Period_2,MA_Shift_2,MA_Method_2,1,1), Digits);
   
 
  
   if(Volume[0]>1) return;

    // продажа
   if (Open[1]>Close[1] && Open[1] > MA1Low && Close[1] < MA1Low)
   
{
      if(Pro(1,100))

   {
       ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,"Pattern_1",1000,0,Red);
      return;
    }
   
  }  
//---- buy conditions
   // покупка
  if (Open[1]<Close[1] && Open[1] < MA2High && Close[1] > MA2High)
 
 { 
   if(Pro(1,100))
   {
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,"Pattern_1",1000,0,Blue);
      return;
   }       
   }
}
 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool Sig(int signal,int pynkt)
 {
  static int cnt = 0;
  static datetime tm;
  if(Time[0] == tm) return(false);
  tm = Time[0];
  if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) == true)
   {
    cnt = cnt + 1;
    if(OrderType() == OP_BUY && OrderClosePrice() - OrderOpenPrice() < pynkt*Point) cnt = 0;
    if(OrderType() == OP_SELL && OrderOpenPrice() - OrderClosePrice() < pynkt*Point) cnt = 0;
    if(cnt >= signal) return(true);
   }
  return(false);
 }
//+------------------------------------------------------------------+
 
artmedia70:
You're starting to write the ToR. Have you even started to do anything yourself? Or are you waiting for the fish? In this thread they help those who want to learn how to program in mql4 for free, not those who want to get a free ready-made solution.



Hello. I am a beginner in programming. I have only used the forum and a tutorial for learning. At first I understood everything, but when I got to the general functions, I started to misunderstand something, by the way, during the correspondence, I had learned something... I took the script from there, the script from there and underlined some things from the forum. I tried it on the demo-it shows profit but scripts are simple: orders are not always placed and one missed order causes system failure. I tried it on the real account: all orders are placed (but this time there were no gaps), it brings profit, but many unnecessary positions are opened. I realized that simple scripts and functions cannot solve this problem and asked for help. The Expert Advisor is profitable, but it needs some "help" with its hands. I am thinking to automate this "help" in time.
 
alexey1979621:
43
alexey1979621 29.11.2013 11:52 #

Greetings all! I am asking for help in solving an interesting problem. There is an EA, the feature of which is that after getting a profit the next trades from 1 to 4 are closed at stop loss, then profit again. The Expert Advisor opens trades based on the indicator signal. To exclude profitable trades following after the profit, one should skip the signals generated by the indicator, i.e. not close deals (1,2,3,4) after getting a profit. The Sig function is available for this purpose. However, I think I wrote this function wrong since the EA does not open orders with it at all and everything is working very clear without it. Maybe there is also an error in the condition. In general, .... I don't know what the hell it is, I have not been able to get off this "deadlock" for the second week. Could you advise me, smart people, where is the error?

Yes, signal is the number of signals after a profit and pynkt is the size of the profit in pips.

I would be grateful for any help.


Function Sig() prohibits opening trades if there is no order history (returns false)
 
Vinin:

Function Sig() prohibits opening trades if there is no order history (returns false)
I assumed that the history in the tester is simulated (so I was wrong). It appears that we should perform a search function of the last order by a simul, a slider and discard pending orders. My brain understands it (if I'm thinking in the right direction), but I cannot use my own hands to execute the code. Can you give me a hint? Thanks for the help.
 
alexey1979621:
I assumed the history in the tester is simulated (so I was wrong). It turns out that it is necessary to do a function to search for the last order, by simul, medj, and discard pending ones. My brain understands it (if I'm thinking in the right direction), but I cannot use my own hands to execute the code. Can you give me a hint? Thank you for your help.
All your tips!
Documentation Tutorial

And functions:

GetIndexLastPos - Returns the index of the last opened position or -1
GetLotLastPos - Returns the lot size of the last opened position or -1

And many others very useful!

 
borilunad:
All the tips are yours!
Documentation Tutorial
That's great, I didn't think of it myself!!!! Only from theory to practice, there is a bridge from the Earth to the Moon. If I had gone through it, I would be now an expert on the site (the task as a maximum the second Bill Gates, at worst I would sit in a hug with a grail and like Koschey over the gold chah). In the meantime, I am asking questions here.
Reason: