Discussion of article "MQL5 Cookbook: Multi-Currency Expert Advisor - Simple, Neat and Quick Approach" - page 3

 
//+------------------------------------------------------------------+
//|| Calculates the Trailing Stop level |
//+------------------------------------------------------------------+
double CalculateTrailingStop(int symbol_number,ENUM_POSITION_TYPE position_type)
  {
//--- Variables for calculations
   double    level       =0.0;
   double    buy_point   =low[symbol_number].value[1];  // Low value for Buy
   double    sell_point  =high[symbol_number].value[1]; // High value for Sell

It will not be correct to do so. If the position and the bar price opens with a gap, StopLoss will not be set correctly.

 
Jose:

The article is neat and easy to follow, and providing the settings in the .set files. I did have an issue with the symbol execution modes, specifically the condition checking whether it was instant or market, and only after that letting orders be opened, which I had to remove, but everything worked fine .

I do have a question. I have seen many different advanced approaches, such as this one, which are built from the ground neglecting the Expert, ExpertSignal, ExpertTrade…. structure provided, even though they spend a lot of code (and time, I suppose) replicating some of its features. Could anybody justify this to me, please?

Hi everyone!

I'm trying to test this EA but just got the following message in Strategy Tester: "Error opening the position: 4753 - 1 The position not found". I don't understand why. This happens when the "trade.PositionOpen" function is executed in the line 159 of file "TradeFunctions.mqh". Someone can give me a help please?

 

Could you tell me where the position reversal takes place as described by the author? Here is his code with description

//--- If there is a position
   else
     {
      //--- Get the position type
      GetPositionProperties(symbol_number,P_TYPE);
      //--- If the position is opposite to the signal and position reversal is enabled
      if(pos.type==opposite_position_type && Reverse[symbol_number])
        {
         //--- Get the position volume
         GetPositionProperties(symbol_number,P_VOLUME);
         //--- Adjust the volume
         lot=pos.volume+CalculateLot(symbol_number,Lot[symbol_number]);
         //--- Let's reverse the position
         OpenPosition(symbol_number,lot,order_type,position_open_price,sl,tp,comment);
         return;
        }

look at the OpenPosition(symbol_number,lot,order_type,position_open_price,sl,tp,comment) function ;

//+------------------------------------------------------------------+
//|| Opens a position|
//+------------------------------------------------------------------+
void OpenPosition(int symbol_number,
                  double lot,
                  ENUM_ORDER_TYPE order_type,
                  double price,
                  double sl,
                  double tp,
                  string comment)
  {
//--- Set the majic number in the trade structure
   trade.SetExpertMagicNumber(MagicNumber);
//--- Set the slippage size in points
   trade.SetDeviationInPoints(CorrectValueBySymbolDigits(Deviation));
//--- Instant Execution and Market Execution mode
// *** Starting from build 803, Stop Loss and Take Profit levels ***
// *** can be set when opening a position in SYMBOL_TRADE_EXECUTION_MARKET mode ***
   if(symb.execution_mode==SYMBOL_TRADE_EXECUTION_INSTANT ||
      symb.execution_mode==SYMBOL_TRADE_EXECUTION_MARKET)
     {
      //--- If the position is not opened, print a message about it
      if(!trade.PositionOpen(Symbols[symbol_number],order_type,lot,price,sl,tp,comment))
         Print("Error when opening a position: ",GetLastError()," - ",ErrorDescription(GetLastError()));
     }
  }
It's just a lock! There is no reversal... the same with lot increment! Can you explain, maybe I'm wrong?
 
Tango_X:

Could you tell me where the position reversal takes place as described by the author? Here is his code with description

look at the OpenPosition(symbol_number,lot,order_type,position_open_price,sl,tp,comment) function;

It's just a lock! There is no reversal... the same with lot increment! Can you explain, maybe I'm wrong?

There are two types of trading accounts: netting and hedge.

There wasActionIt was on Netting.It's up on Hedge.
Buy 1.0Sell 2.0Sell 1.0Buy 1.0 and Sell 2.0
 
Vladimir Karputov:

There are two types of trading accounts: netting and hedge.

There wasActionBecame on NettingBecame on Hedge
Buy 1.0Sell 2.0Sell 1.0Buy 1.0 and Sell 2.0

Got it! Thank you!

 
"TimeframeToString" does not exist and is not declared in the article, kindly rteplace by "EnumToString".