<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — Help needed! Position sizing relative to SL code]]></title>
		<link>https://forexsb.com/forum/topic/7772/help-needed-position-sizing-relative-to-sl-code/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/7772/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Help needed! Position sizing relative to SL code.]]></description>
		<lastBuildDate>Mon, 08 Apr 2019 14:22:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/55026/#p55026</link>
			<description><![CDATA[<p>No Problem. ;-)</p>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Mon, 08 Apr 2019 14:22:13 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/55026/#p55026</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/55021/#p55021</link>
			<description><![CDATA[<p>Roughey your a legend I had a lay around with that code and got it work.</p><p>Thank you very much!!!</p>]]></description>
			<author><![CDATA[null@example.com (Michael1)]]></author>
			<pubDate>Mon, 08 Apr 2019 10:45:15 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/55021/#p55021</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54994/#p54994</link>
			<description><![CDATA[<p>Try this.</p><p>make Entry_Amount as global variable.</p><div class="codebox"><pre><code>datetime barTime;
int      digits;
double   pip;
double   stopLevel;
bool     isTrailingStop=false;
bool     setProtectionSeparately=false;
[b]double   Entry_Amount;[/b]</code></pre></div><br /><p>Than put your code in OnTick.</p><div class="codebox"><pre><code>void OnTick()
  {
      int margin=(int) MarketInfo(_Symbol,MODE_MARGINREQUIRED);
      Entry_Amount=(AccountBalance()*MaxRiskPerTrade/100)/(Stop_Loss*pip);
      Entry_Amount = NormalizeEntrySize(Entry_Amount);</code></pre></div><p>ADD THIS FUNCTION OUTSIDE ONTICK</p><div class="codebox"><pre><code>//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double NormalizeEntrySize(double size) {
   double minlot  = MarketInfo(_Symbol, MODE_MINLOT);
   double maxlot  = MarketInfo(_Symbol, MODE_MAXLOT);
   double lotstep = MarketInfo(_Symbol, MODE_LOTSTEP);

   if (size &lt;= minlot)
       return (minlot);

   int steps = (int) MathRound((size - minlot) / lotstep);
   size = minlot + steps * lotstep;

   if (size &gt;= maxlot)
       size = maxlot;
   if (size &gt;=Maximum_Lots)
       size = Maximum_Lots;
       
   size = NormalizeDouble(size, digits);   

   return (size);
}  </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Fri, 05 Apr 2019 16:33:09 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54994/#p54994</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54981/#p54981</link>
			<description><![CDATA[<p>Are you using the same parameters as in your pasted code? If so, raise max lot value.</p><p>And check this line:</p><div class="codebox"><pre><code>double Entry_Amount=(AccountBalance()*MaxRiskPerTrade/100)/(Stop_Loss*pip);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (footon)]]></author>
			<pubDate>Thu, 04 Apr 2019 14:20:46 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54981/#p54981</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54980/#p54980</link>
			<description><![CDATA[<p>I&#039;m illiterate in mql, but I can pitch some ideas as a by-stander.</p><p>Firstly, what are your modifications? It would especially great to see them side by side, I mean the original code and your mod.</p><p>/// edited out</p>]]></description>
			<author><![CDATA[null@example.com (footon)]]></author>
			<pubDate>Thu, 04 Apr 2019 14:14:01 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54980/#p54980</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54979/#p54979</link>
			<description><![CDATA[<p>Ive just being trying again tonight after 3hours I still cannot get it to work.</p><p>Can I please get some assistance from someone please? Im desperate haha</p>]]></description>
			<author><![CDATA[null@example.com (Michael1)]]></author>
			<pubDate>Thu, 04 Apr 2019 12:23:25 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54979/#p54979</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54968/#p54968</link>
			<description><![CDATA[<p>Thanks traderaw, <br />Ive been trying and trying all night to get it to work however cannot seem to get it working\</p><p>Popov! can i please get hand with this im desperate!</p><p>Attached is a file I have modified however I cannot get it to work. The EA constantly opens trades at the maximum_Lots value not the MaxRiskPerTrade and I cannot work out why.</p><div class="codebox"><pre><code>//
// EA Studio Expert Advisor
//
// Created with: Expert Advisor Studio
// Website: https://forexsb.com/expert-advisor-studio-app
//
// Copyright 2019, Forex Software Ltd.
//

#property copyright &quot;Forex Software Ltd.&quot;
#property version   &quot;2.10&quot;
#property strict

static input string StrategyProperties__ = &quot;------------&quot;; // ------ Expert Properties ------
extern double MaxRiskPerTrade=1; //% of balance to risk in one trade
static input double Maximum_Lots = 0.01; // Maximum entry lots
input int Stop_Loss   = 10; // Stop Loss (pips)
input int Take_Profit = 0; // Take Profit (pips)
static input string Ind1 = &quot;------------&quot;;// ----- Entry Time -----
input int Ind1Param0 = 0; // From hour
input int Ind1Param1 = 0; // From minute
input int Ind1Param2 = 0; // Until hour
input int Ind1Param3 = 59; // Until minute
static input string Ind2 = &quot;------------&quot;;// ----- Money Flow Index -----
input int Ind2Param0 = 11; // Period
input int Ind2Param1 = 20; // Level

static input string ExpertSettings__ = &quot;------------&quot;; // ------ Expert Settings ------
static input int Magic_Number = 98261191; // Magic Number

#define TRADE_RETRY_COUNT 4
#define TRADE_RETRY_WAIT  100
#define OP_FLAT           -1

// Session time is set in seconds from 00:00
int sessionSundayOpen           = 0;     // 00:00
int sessionSundayClose          = 86400; // 24:00
int sessionMondayThursdayOpen   = 0;     // 00:00
int sessionMondayThursdayClose  = 86400; // 24:00
int sessionFridayOpen           = 0;     // 00:00
int sessionFridayClose          = 60;    // 00:01
bool sessionIgnoreSunday        = true;
bool sessionCloseAtSessionClose = false;
bool sessionCloseAtFridayClose  = true;

const double sigma   = 0.000001;

double posType       = OP_FLAT;
int    posTicket     = 0;
double posLots       = 0;
double posStopLoss   = 0;
double posTakeProfit = 0;

datetime barTime;
int      digits;
double   pip;
double   stopLevel;
bool     isTrailingStop=false;
bool     setProtectionSeparately=false;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   barTime        = Time[0];
   digits         = (int) MarketInfo(_Symbol, MODE_DIGITS);
   pip            = GetPipValue(digits);
   stopLevel      = MarketInfo(_Symbol, MODE_STOPLEVEL);
   isTrailingStop = isTrailingStop &amp;&amp; Stop_Loss &gt; 0;

   const ENUM_INIT_RETCODE initRetcode = ValidateInit();

   return (initRetcode);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(Time[0]&gt;barTime)
     {
      barTime=Time[0];
      OnBar();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnBar()
  {
   UpdatePosition();

   if(posType!=OP_FLAT &amp;&amp; IsForceSessionClose())
     {
      ClosePosition();
      return;
     }

   if(IsOutOfSession())
      return;

   if(posType!=OP_FLAT)
     {
      ManageClose();
      UpdatePosition();
     }

   if(posType!=OP_FLAT &amp;&amp; isTrailingStop)
     {
      double trailingStop=GetTrailingStop();
      ManageTrailingStop(trailingStop);
      UpdatePosition();
     }

   if(posType==OP_FLAT)
     {
      ManageOpen();
      UpdatePosition();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void UpdatePosition()
  {
   posType   = OP_FLAT;
   posTicket = 0;
   posLots   = 0;
   int total = OrdersTotal();

   for(int pos=total-1; pos&gt;=0; pos--)
     {
      if(OrderSelect(pos,SELECT_BY_POS) &amp;&amp;
         OrderSymbol()==_Symbol &amp;&amp;
         OrderMagicNumber()==Magic_Number)
        {
         posType       = OrderType();
         posLots       = OrderLots();
         posTicket     = OrderTicket();
         posStopLoss   = OrderStopLoss();
         posTakeProfit = OrderTakeProfit();
         break;
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ManageOpen()
  {
   bool ind0long  = true;
   bool ind0short = false;


   int fromTime1  = Ind1Param0*3600 + Ind1Param1*60;
   int untilTime1 = Ind1Param2*3600 + Ind1Param3*60;

   MqlDateTime mqlTime1; TimeToStruct(Time(0), mqlTime1);
   int barMinutes1 = mqlTime1.hour*3600 + mqlTime1.min*60;

   bool isOnTime1 = fromTime1 &lt; untilTime1
      ? barMinutes1 &gt;= fromTime1 &amp;&amp; barMinutes1 &lt;= untilTime1
      : barMinutes1 &gt;= fromTime1 || barMinutes1 &lt;= untilTime1;

   bool ind1long  = isOnTime1;
   bool ind1short = isOnTime1;

   const bool canOpenLong  = ind0long &amp;&amp; ind1long;
   const bool canOpenShort = ind0short &amp;&amp; ind1short;

   if(canOpenLong &amp;&amp; canOpenShort)
      return;

   if(canOpenLong)
      OpenPosition(OP_BUY);
   else if(canOpenShort)
      OpenPosition(OP_SELL);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ManageClose()
  {
   double ind2val1 = iMFI(NULL,0,Ind2Param0,1);
   double ind2val2 = iMFI(NULL,0,Ind2Param0,2);
   double ind2val3 = iMFI(NULL,0,Ind2Param0,3);
   bool ind2long  = ind2val1 &gt; ind2val2 + sigma &amp;&amp; ind2val2 &lt; ind2val3 - sigma;
   bool ind2short = ind2val1 &lt; ind2val2 - sigma &amp;&amp; ind2val2 &gt; ind2val3 + sigma;

   if(posType==OP_BUY &amp;&amp; ind2long)
      ClosePosition();
   else if(posType==OP_SELL &amp;&amp; ind2short)
      ClosePosition();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenPosition(int command)
  {
  int margin=(int) MarketInfo(_Symbol,MODE_MARGINREQUIRED);
   double Entry_Amount=(AccountBalance()*MaxRiskPerTrade/100)/(Stop_Loss*pip);
   Entry_Amount=MathMin(Entry_Amount,Maximum_Lots);
   Entry_Amount=MathMax(Entry_Amount,0.01);
   Entry_Amount=NormalizeDouble(Entry_Amount,2);
   for(int attempt=0; attempt&lt;TRADE_RETRY_COUNT; attempt++)
     {
      int    ticket     = 0;
      int    lastError  = 0;
      bool   modified   = false;
      double stopLoss   = GetStopLoss(command);
      double takeProfit = GetTakeProfit(command);
      string comment    = IntegerToString(Magic_Number);
      color  arrowColor = command==OP_BUY ? clrGreen : clrRed;

      if(IsTradeContextFree())
        {
         double price=MarketInfo(_Symbol,command==OP_BUY ? MODE_ASK : MODE_BID);
         if(setProtectionSeparately)
           {
            ticket=OrderSend(_Symbol,command,Entry_Amount,price,10,0,0,comment,Magic_Number,0,arrowColor);
            if(ticket&gt;0 &amp;&amp; (Stop_Loss&gt;0 || Take_Profit&gt;0))
              {
               modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
              }
           }
         else
           {
            ticket=OrderSend(_Symbol,command,Entry_Amount,price,10,stopLoss,takeProfit,comment,Magic_Number,0,arrowColor);
            lastError=GetLastError();
            if(ticket&lt;=0 &amp;&amp; lastError==130)
              {
               ticket=OrderSend(_Symbol,command,Entry_Amount,price,10,0,0,comment,Magic_Number,0,arrowColor);
               if(ticket&gt;0 &amp;&amp; (Stop_Loss&gt;0 || Take_Profit&gt;0))
                 {
                  modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
                 }
               if(ticket&gt;0 &amp;&amp; modified)
                 {
                  setProtectionSeparately=true;
                  Print(&quot;Detected ECN type position protection.&quot;);
                 }
              }
           }
        }

      if(ticket&gt;0)
         break;

      lastError=GetLastError();
      if(lastError!=135 &amp;&amp; lastError!=136 &amp;&amp; lastError!=137 &amp;&amp; lastError!=138)
         break;

      Sleep(TRADE_RETRY_WAIT);
      Print(&quot;Open Position retry no: &quot;+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ClosePosition()
  {
   for(int attempt=0; attempt&lt;TRADE_RETRY_COUNT; attempt++)
     {
      bool closed;
      int lastError=0;

      if(IsTradeContextFree())
        {
         double price=MarketInfo(_Symbol,posType==OP_BUY ? MODE_BID : MODE_ASK);
         closed=OrderClose(posTicket,posLots,price,10,clrYellow);
         lastError=GetLastError();
        }

      if(closed)
         break;

      if(lastError==4108)
         break;

      Sleep(TRADE_RETRY_WAIT);
      Print(&quot;Close Position retry no: &quot;+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModifyPosition()
  {
   for(int attempt=0; attempt&lt;TRADE_RETRY_COUNT; attempt++)
     {
      bool modified;
      int lastError=0;

      if(IsTradeContextFree())
        {
         modified=OrderModify(posTicket,0,posStopLoss,posTakeProfit,0,clrBlue);
         lastError=GetLastError();
        }

      if(modified)
         break;

      if(lastError==4108)
         break;

      Sleep(TRADE_RETRY_WAIT);
      Print(&quot;Modify Position retry no: &quot;+IntegerToString(attempt+2));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetStopLoss(int command)
  {
   if(Stop_Loss==0)
      return (0);

   double delta    = MathMax(pip*Stop_Loss, _Point*stopLevel);
   double price    = MarketInfo(_Symbol, command==OP_BUY ? MODE_BID : MODE_ASK);
   double stopLoss = command==OP_BUY ? price-delta : price+delta;
   return (NormalizeDouble(stopLoss, digits));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetTakeProfit(int command)
  {
   if(Take_Profit==0)
      return (0);

   double delta      = MathMax(pip*Take_Profit, _Point*stopLevel);
   double price      = MarketInfo(_Symbol, command==OP_BUY ? MODE_BID : MODE_ASK);
   double takeProfit = command==OP_BUY ? price+delta : price-delta;
   return (NormalizeDouble(takeProfit, digits));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetTrailingStop()
  {
   double bid=MarketInfo(_Symbol,MODE_BID);
   double ask=MarketInfo(_Symbol,MODE_ASK);
   double stopLevelPoints=_Point*stopLevel;
   double stopLossPoints=pip*Stop_Loss;

   if(posType==OP_BUY)
     {
      double stopLossPrice=High[1]-stopLossPoints;
      if(posStopLoss&lt;stopLossPrice-pip)
        {
         if(stopLossPrice&lt;bid)
           {
            if(stopLossPrice&gt;=bid-stopLevelPoints)
               return (bid - stopLevelPoints);
            else
               return (stopLossPrice);
           }
         else
           {
            return (bid);
           }
        }
     }

   else if(posType==OP_SELL)
     {
      double stopLossPrice=Low[1]+stopLossPoints;
      if(posStopLoss&gt;stopLossPrice+pip)
        {
         if(stopLossPrice&gt;ask)
           {
            if(stopLossPrice&lt;=ask+stopLevelPoints)
               return (ask + stopLevelPoints);
            else
               return (stopLossPrice);
           }
         else
           {
            return (ask);
           }
        }
     }

   return (posStopLoss);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ManageTrailingStop(double trailingStop)
  {
   double bid=MarketInfo(_Symbol,MODE_BID);
   double ask=MarketInfo(_Symbol,MODE_ASK);

   if(posType==OP_BUY &amp;&amp; MathAbs(trailingStop-bid)&lt;_Point)
     {
      ClosePosition();
     }

   else if(posType==OP_SELL &amp;&amp; MathAbs(trailingStop-ask)&lt;_Point)
     {
      ClosePosition();
     }

   else if(MathAbs(trailingStop-posStopLoss)&gt;_Point)
     {
      posStopLoss=NormalizeDouble(trailingStop,digits);
      ModifyPosition();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime Time(int bar)
  {
   return Time[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Open(int bar)
  {
   return Open[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double High(int bar)
  {
   return High[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Low(int bar)
  {
   return Low[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Close(int bar)
  {
   return Close[bar];
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetPipValue(int digit)
  {
   if(digit==4 || digit==5)
      return (0.0001);
   if(digit==2 || digit==3)
      return (0.01);
   if(digit==1)
      return (0.1);
   return (1);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsTradeContextFree()
  {
   if(IsTradeAllowed())
      return (true);

   uint startWait=GetTickCount();
   Print(&quot;Trade context is busy! Waiting...&quot;);

   while(true)
     {
      if(IsStopped())
         return (false);

      uint diff=GetTickCount()-startWait;
      if(diff&gt;30*1000)
        {
         Print(&quot;The waiting limit exceeded!&quot;);
         return (false);
        }

      if(IsTradeAllowed())
        {
         RefreshRates();
         return (true);
        }
      Sleep(TRADE_RETRY_WAIT);
     }
   return (true);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsOutOfSession()
  {
   MqlDateTime time0; TimeToStruct(Time[0],time0);
   int weekDay           = time0.day_of_week;
   long timeFromMidnight = Time[0]%86400;
   int periodLength      = PeriodSeconds(_Period);
   bool skipTrade        = false;

   if(weekDay==0)
     {
      if(sessionIgnoreSunday) return true;
      int lastBarFix=sessionCloseAtSessionClose ? periodLength : 0;
      skipTrade=timeFromMidnight&lt;sessionSundayOpen || timeFromMidnight+lastBarFix&gt;sessionSundayClose;
     }
   else if(weekDay&lt;5)
     {
      int lastBarFix=sessionCloseAtSessionClose ? periodLength : 0;
      skipTrade=timeFromMidnight&lt;sessionMondayThursdayOpen || timeFromMidnight+lastBarFix&gt;sessionMondayThursdayClose;
     }
   else
     {
      int lastBarFix=sessionCloseAtFridayClose || sessionCloseAtSessionClose ? periodLength : 0;
      skipTrade=timeFromMidnight&lt;sessionFridayOpen || timeFromMidnight+lastBarFix&gt;sessionFridayClose;
     }

   return (skipTrade);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsForceSessionClose()
  {
   if(!sessionCloseAtFridayClose &amp;&amp; !sessionCloseAtSessionClose)
      return (false);

   MqlDateTime time0; TimeToStruct(Time[0],time0);
   int weekDay           = time0.day_of_week;
   long timeFromMidnight = Time[0]%86400;
   int periodLength      = PeriodSeconds(_Period);
   int lastBarFix        = sessionCloseAtSessionClose ? periodLength : 0;

   bool forceExit=false;
   if(weekDay==0)
     {
      forceExit=timeFromMidnight+lastBarFix&gt;sessionSundayClose;
     }
   else if(weekDay&lt;5)
     {
      forceExit=timeFromMidnight+lastBarFix&gt;sessionMondayThursdayClose;
     }
   else
     {
      int fridayBarFix=sessionCloseAtFridayClose || sessionCloseAtSessionClose ? periodLength : 0;
      forceExit=timeFromMidnight+fridayBarFix&gt;sessionFridayClose;
     }

   return (forceExit);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
ENUM_INIT_RETCODE ValidateInit()
  {
   return (INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
/*STRATEGY MARKET Dukascopy-DEMO-1; EURNZD; H1 */
/*STRATEGY CODE {&quot;properties&quot;:{&quot;entryLots&quot;:0.05,&quot;stopLoss&quot;:54,&quot;takeProfit&quot;:33,&quot;useStopLoss&quot;:false,&quot;useTakeProfit&quot;:false,&quot;isTrailingStop&quot;:false},&quot;openFilters&quot;:[{&quot;name&quot;:&quot;Long or Short&quot;,&quot;listIndexes&quot;:[0,0,0,0,0],&quot;numValues&quot;:[0,0,0,0,0,0]},{&quot;name&quot;:&quot;Entry Time&quot;,&quot;listIndexes&quot;:[0,0,0,0,0],&quot;numValues&quot;:[0,0,0,59,0,0]}],&quot;closeFilters&quot;:[{&quot;name&quot;:&quot;Money Flow Index&quot;,&quot;listIndexes&quot;:[6,0,0,0,0],&quot;numValues&quot;:[11,20,0,0,0,0]}]} */</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Michael1)]]></author>
			<pubDate>Wed, 03 Apr 2019 12:20:22 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54968/#p54968</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54946/#p54946</link>
			<description><![CDATA[<p>Hi Michael1,</p><p>I haven&#039;t test this code, but it seems to be logically correct...</p><p>https://mql4tradingautomation.com/mql4-calculate-position-size/</p><p>Let me know how it goes!</p>]]></description>
			<author><![CDATA[null@example.com (traderaw)]]></author>
			<pubDate>Tue, 02 Apr 2019 03:52:12 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54946/#p54946</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54945/#p54945</link>
			<description><![CDATA[<p>Hi Popov if I could please get a hand with this it would be much appreciated I’ve spent 5 days trying to make it work with no success</p>]]></description>
			<author><![CDATA[null@example.com (Michael1)]]></author>
			<pubDate>Mon, 01 Apr 2019 20:27:48 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54945/#p54945</guid>
		</item>
		<item>
			<title><![CDATA[Help needed! Position sizing relative to SL code]]></title>
			<link>https://forexsb.com/forum/post/54900/#p54900</link>
			<description><![CDATA[<p>Hi Popov,</p><p>I have been reading all over the interent as well on the forum on how to code a particular function. I notice that you have provided a code to set the entry amount relative to the account size as a percentage. I have added this code into my EA&#039;s with much appreciation&nbsp; for providing us with it.</p><p>However I really want to be able to set my position size relative to the Stop Loss of the strategy. For example if I want to risk 2% of my available margin per trade with a strategy that has a SL of 50 pips:<br />So as an example:</p><p>Pip value X 50 = 2% of account margin </p><p>How can I add this function in the MQL code to automate this process?</p><p>All of my EA&#039;s run SL&#039;s and never TSL&#039;s.</p><p>Thanks!</p>]]></description>
			<author><![CDATA[null@example.com (Michael1)]]></author>
			<pubDate>Fri, 29 Mar 2019 08:40:15 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/54900/#p54900</guid>
		</item>
	</channel>
</rss>
