Experts: TP SL Trailing

 

TP SL Trailing:

Stop loss and take profit initial setting. Trailing.

Author: Vladimir Karputov

 
Automated-Trading:

TP SL Trailing:

Author: Vladimir Karputov

Hello. Please explain what "uncomment the lines" means
 
Андрей:
Hello. Please explain what "uncomment the lines" means

It means: lines in the code are commented out - that is, the code is temporarily commented out: now a few lines of code is a simple text comment. Was code - became a comment in the code (just text).

Uncomment, means:

was

   ExtStopLoss    = InpStopLoss     * m_adjusted_point;
   ExtTakeProfit  = InpTakeProfit   * m_adjusted_point;
   ExtTrailingStop= InpTrailingStop * m_adjusted_point;
   ExtTrailingStep= InpTrailingStep * m_adjusted_point;

//m_trade.Buy(2.0);
//m_trade.Sell(1.0);
//---
   return(INIT_SUCCEEDED);
  }

must become:

   ExtStopLoss    = InpStopLoss     * m_adjusted_point;
   ExtTakeProfit  = InpTakeProfit   * m_adjusted_point;
   ExtTrailingStop= InpTrailingStop * m_adjusted_point;
   ExtTrailingStep= InpTrailingStep * m_adjusted_point;

   m_trade.Buy(2.0);
   m_trade.Sell(1.0);
//---
   return(INIT_SUCCEEDED);
  }


Thus, if you uncomment the lines, you can see in the strategy tester how the Expert Advisor works visually.

 
Vladimir Karputov:

That means...



Okay, thanks. Except it's not working for me in real time. I installed it as usual and there is no action. The only entry in the log is that the EA is loaded and that's it.

 
Андрей:

Okay, thanks. Except it's not working for me in real time. I installed it as usual and there is no action. The only entry in the log is that the EA is loaded and that's all.

More details, please.

  1. What exactly and where does not work?
  2. Are the lines commented out or commented in?
  3. What do you do BEFORE starting the EA: are there any other positions open?
All three questions need answers. If there is no answer to at least one question, I will withdraw from the discussion.

 
Vladimir Karputov:

More details, please.

  1. What exactly and where is not working?
  2. Are the lines commented or uncommented?
  3. What do you do BEFORE starting the Expert Advisor: are there any other positions open?
All three questions need answers. If there is no answer to at least one question, I will withdraw from the discussion.

The Expert Advisor does not set the SL,TP specified in the parameters. I have not changed the lines in the Expert Advisor. At the moment there are open positions on two pairs and all with zero SL,TP. Before launching, I set the desired SL,TP, trailing 0 in the parameters.
 
Андрей:
The Expert Advisor does not set the SL,TP set in the parameters. I did not change the lines in the Expert Advisor. At the moment there are open positions on two pairs and all with zero SL,TP. Before launching I set the desired SL,TP, trailing 0 in the parameters.

First read the description:

The Expert Advisor works for all positions on the current symbol - the unique identifier (magic) is not taken into account.

 
Vladimir Karputov:

First, read the description:

The Expert Advisor works for all positions by the current symbol - the unique identifier (magic) is not taken into account.

Explain please, what does "by current symbol" mean? It seems that I have tried everything and no way, although I have been using similar Expert Advisors on 4 for a long time and without problems.
 
Андрей:
Could you please explain what "by current symbol" means? It seems that I have tried everything and nothing, although I have been using similar Expert Advisors on 4 for a long time and without problems.

The current symbol for this EA is the symbol on which the EA is running.

 
Vladimir Karputov:

The current symbol for this EA is the symbol on which the EA is running.

That's what I figured. Okay, thank you for your help, have a nice day.
[Deleted]  
there is a small bug that i have found, while you SELL a position, it shows reduced TP as in TP - (minus) SPREADS, and SL+ SPREADS while the same does not happen with BUY position as it shows exact values of TP and SL. kindly check and please fix the bug. (also the trailing step is taken by default at 20 points which is good but if you add that as an option for users it would be interesting)!