[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 947

 

Folks, please advise, I am having trouble implementing TrailingStop.... (trying to write an EA)

I am using an Alpari MT4 platform with Trailing Stop function (i.e. I can put a Trailing Stop 18 pips). Question for clarification, is it possible to use the platform functionality when opening an order (e.g. programmatically put a TrailingStop tick)?

 
001:

It seems to work, but for some reason it opens two opposite positions.


So you're confused about something - these are clippings from my "avalanche" code - for you with minor changes. Everything works fine for me. Look additionally at this (similar snippet) here - everything works fine, look for your error, it's fine... This is the basic version of Avalanche - it's all detailed here - for yourself (as you need it) I'm sure special

It wouldn't be difficult to redo, there's a similar fragment...

Files:
av02.mq4  17 kb
 
artmedia70:
The logic is as simple as 2x2:
1. First you determine that the previous pose is closed on the foot.
2. Then you check the absence of already open opposite position
And then, after you have determined it is not there yet - you open it (the opposite position that closed on stop).

There is a small omission here. When the opposite position opens, and then closes at stop or take, the conditions for opening will appear again. And I need ONE time.
 

Am I getting the data right? I'm asking because it's not working. There are no errors during compilation. That's why I think there is something wrong with the logic. Check it.

The picture shows only two bars although there are more.

FX Fish indicator. I need buy signals - on the first bar the histogram is higher than the buy level and the histogram on the first bar is higher than the second one.

on sell - on the first bar, the histogram is lower than the sell level and the histogram on the first bar is lower than the histogram on the second bar

I wrote the code like this

      double fx_fishUp1=iCustom(NULL,0,"FX Fish",FX_Period,FX_Price,ModeFast,Signals,0,1);
      double fx_fishUp2=iCustom(NULL,0,"FX Fish",FX_Period,FX_Price,ModeFast,Signals,0,2);
      double fx_fishDn1=iCustom(NULL,0,"FX Fish",FX_Period,FX_Price,ModeFast,Signals,1,1);
      double fx_fishDn2=iCustom(NULL,0,"FX Fish",FX_Period,FX_Price,ModeFast,Signals,1,2);
      
      if(fx_fishUp1-UpLevel>0 && fx_fishUp1-fx_fishUp2>0){fx_fUp=true; fx_fDown=false;}
      if(DnLevel-fx_fishDn1<0 && fx_fishDn2-fx_fishDn1<0){fx_fDown=true; fx_fDown=false;}


      if(fx_fUp) res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue);    
        
      if(fx_fDown) res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
                 
Files:
fxdfish.mq4  5 kb
 
One more question. I attached the file FX Fish. it has the same name in the indicators folder, but after I attached it, the new name FXdFish.mq4 appeared.
 
Roman.:


So you're confused about something - these are clippings from my "avalanche" code - to you with minor modifications. It all works fine for me. Look additionally at this (similar snippet) here - everything works fine, look for your error, everything is fine... This is the basic version of Avalanche - here everything is detailed - for yourself (as you need) I'm sure, a special

difficult to remake, such a fragment is present...


Here's what I got. I removed:

1.lots = NormalizeLots(lots); put a fixed 0.1

2.I fixed if (lastType == OP_SELL) OrderSend(Symbol(), OP_BUY, lots,...); since I'm testing longs first.

That's all.

Files:
2.mq4  3 kb
 
001:

There is a slight omission here. When the opposite pose opens and then closes at stop or take, the conditions for opening will arise again. And I need ONE time.


Write down the normal opening conditions, what ONE time means - per day, per second, in general in trades...

Formulate NORMAL opening conditions and write, for example - enter a time limit, let's say if one order has already been opened within a day, then subsequent orders will not open - this is trading once a day - the time limit for the EA - already posted in this thread, use the search, for example formulate the code below in the opening condition, i.e. if in this time range was already trading, then subsequent orders will not open, etc... Formulate specifically what you need, not incomprehensible as "ONE time", which once is once in a lifetime? Formulate normal trading terms, not fuck your brains out. Not to mention the website - this thread already has it all...

2. Подскажите, пожалуйста, как сделать, чтобы советник прекращал торговать в 21 ч00 мин и потом начинал только в 01 ч00 мин следующего дня. 

int start()
  { 

   if (Hour()>20 && Hour<2) return(0);

.....

  }
 
Roman.:


Write down the normal opening conditions, what ONE time means - per day, per second, in general in trades...

Formulate NORMAL opening conditions and write, for example - enter a time limit, let's say if one order has already been opened within a day, then subsequent orders will not open - this is trading once a day - the time limit for the EA - already posted in this thread, use the search, for example formulate the code below in the opening condition, i.e. if in this time range was already trading, then subsequent orders will not open, etc... Formulate specifically what you need, not incomprehensible as "ONE time", which once is one time in a lifetime? Formulate normal trading terms, not fuck your brains out. Not to mention the website - this thread already has it all...

001:

Trying to implement a simple flip. When a stop position is reached --> open the opposite position. I can't get it to open opposite position once and not open anything else. Please advise.

When a position reaches a stop . There is a position, it has a stop. When the price reaches the stop, open the opposite position. Do not open anything else on the first position.
 
001:
When a position reaches a stop . There is a position, it has a stop. When the price reaches the stop, open the opposite position. Do not open anything else on the first position.

The website https://www.mql5.com/go?link=http://www.kimiv.ru// has a function which defines exactly how an order is to be closed by a stop loss. I.e., when you connect this function, you should prescribe the condition if the position is closed after reaching the stop loss, if it is, you should open the opposite position and add the condition of its single opening into the condition of your basic position...
 
Is there any additional documentation on the names of all the elements used in the program? For example: case, switch, os, bool, ++, ==, Having some knowledge you start inventing a wheel, and then it turns out that there is a special function that solves this problem. As I understood in the tutorial not everything, and how to look for something that you can't even guess?
Reason: