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

 
Ekburg:


You're not clear with your question... if you had inserted the code correctly, you could have explained the confusion you're having.)

but let's see what we can do


Sverlovsk resident, by the looks of it?
 
Vinin:

Sverlovenian, I presume?

Yes, I am.)
 
SpikeOne:

Please help me, do i understand how this code works correctly?

I put it in the EA in a certain place and it starts to close all orders after reaching 715,

I have only one problem, in some places because I have pasted this code starts a mess, maybe someone will tell me what's wrong:



I've just started parsing your code and I can already see that your code architecture is broken...

Not correctly exposed curly braces, correct them, and maybe the problem will be solved

P.S. I mean not a visual exhibiting where ever, and mixed up opening and closing brackets ... for example, in the first block of if at the end of the closing place, you Fig. bracket open another block, that's because of this confusion arises

 
SpikeOne:

Please help me, do i understand how this code works correctly?

I put it in the EA in a certain place and it starts to close all orders after reaching 715,

I still have one problem with it, in some places it gets messy because I put this code there, maybe somebody might tell me what's wrong:



Install the latest build in the terminal, it's easier to write code there, less likely to make mistakes, I advise!:)

Corrected that part which have sent at first, without last part of brackets which it is not clear why it is necessary...

if ( AccountProfit()+ AccountBalance()>=715)
   {
   for(int zx=OrdersTotal(); zx+1>=0; zx--)
      {
      if(OrderSelect(zx,SELECT_BY_POS,MODE_TRADES)==true)
      OrderDelete(OrderTicket());
      }
   }
while (OrdersTotal()>0)
   {
   if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
      {
      if(OrderType()==OP_BUY) result=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS)),3,CLR_NONE);
      if(OrderType()==OP_SELL) result=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS)),3,CLR_NONE);
      if (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLLIMIT || OrderType()==OP_SELLSTOP)
      OrderDelete(OrderTicket());
      if(result!=TRUE)
         {
         er=GetLastError();
         Print("LastError = ",er, " ",Symbol());
         }
      else er=0;
      }
   else Print( "Error when order select ", GetLastError());
   }
 

Dear comrades, friends! It's hard to express how grateful I am for your previous help in writing the EA (at the end of the 350th page of this thread). Now I need your help again, and I hope you will do it again.

So, I need to write the following in my EA:

The EA should work on EMA extremums. At EMA highs, it should place pending orders to open a short position at a price equal to the price of the low of the reversal muvinig candle minus a certain percentage of that price (e.g., the low of the reversal candle * 0.99) The pending order must also contain a stop loss and take profit as percentage of that very low of the reversal muvinig candle. But that is not all. Also if the EMA maximum is reached, the EA should place stop-losses in all open longs for this asset at the same level where the short is to be opened. Thus, when the estimated price is reached (see above), the existing longs should be closed (using the stop losses previously set by the EA) and the shorts should be opened.

At a low EMA, the opposite is true: There is a candle, where the muving has turned up. On the next candle, the EA should start to follow the price and when it exceeds the following level: the high of the reversal candle + a certain percentage (eg, the high of the reversal candle * 1.01), the existing open shorts should place stop losses at this price (the high of the reversal candle + a certain percentage) and a pending order to open a long at the same price (with a stop loss and take profit in % of the high of the reversal candle).

Thus, the adviser at a reversal of the muvning (we mean a completed reversal, ie, the reversal of the previous two candles, the current candle is not taken into account, the muvning can be reversed on the current bar, but it will not reverse on it, these reversals during the current muvning, if in the result of closing the bar reversal is not - do not count).

So, if the muving is at a maximum, the Expert Advisor should place a Stop Loss on existing longs at a certain level (see above) and open a pending order to open a short at the same level (with a Stop Loss and Take Profit).

If the muving is low, it is vice versa - the EA places a stop loss in the open shorts at a certain level (see above) and places a pending order to open a long position at the same level (with stop loss and take profit).

Thus, it will not be possible to go to cash, we will always be either in a long position, or in a short position. When closing a long position we simultaneously open a short, and vice versa.

I tried to play with my working EA (it works by crossing two EMAs) and to modify it in right way. However, my poor knowledge of C++ and my aversion to programming failed. Here is the link to the Expert Advisor I tried to modify to the desired one: https://www.mql5.com/ru/code/8463?source=terminal4_codebase

I understand that I need a lot of help, it is not an easy task, so as a bonus I will give my research results of BTC/USD (bitcoins/dollars) exchange btc-e to those who helped me. I determined the most appropriate moving average (to have less false signals and to trigger good moves), the best parameters for it (the same percentage of highs/lows of reversal candle), the most appropriate take-profits. I calculated it in Excel. This Excel file is from me, as a sign of gratitude. Maybe it will be useful to you.

I do not want to just trade using this Expert Advisor. I need it to monitor the market when I'm not following it (because I can't follow it 24 hours a day). When I'm at monitor, I trade by lines of support/resistance according to certain methodology, but the EMA system also helps me - to determine breakout points of levels, setting stops.

I'm waiting for help in writing an EA and I'm relying on it.

 
okidoki543:

Dear comrades, friends! It's hard to express how grateful I am for your previous help in writing the EA (at the end of the 350th page of this thread). Now I need your help again, I hope you will give it again.

Ohhhh!?:) Just an order to write it)
 
okidoki543:

So, I need to prescribe the following in the EA:

The task is quite feasible, in principle not even a lot of code to write... if only there was time to do it...:)
 
I don't know how to insert a normal quote, I put it in this way, manually: [quote]The task is quite doable, in principle you don't even have to write much code... it would be time for that... :)[/quote] I would be grateful if you could help.
 
okidoki543:
I don't know how to insert a normal quote, put it this way, manually: [quote]The task is quite doable, in principle not even a lot of code to write it would be time to do it...:)[/quote] I would be grateful if you help.


If I can, I will skip the code today... I'm not sure if it will be working since I'm at work and don't have time to write a debugged program... But it will be a starting point for sure)

But I can't promise... how the circumstances will work out today)

 
Ekburg, ok