Mdp plus 2.1

1,242 views

Published on

Published in: Investor Relations
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,242
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mdp plus 2.1

  1. 1. // -------------------------------------------------------------------------------------------------// MDP-Plus v. 2.1.2//// Based on MillionDollarPips - (ANY PAIR + NO DLL) - ver 1.1.0//// Someone at a russian forum fixed a Stack Overflow problem, added NDD-mode (ECN-mode)// and moved the DLL-functions in the mql4-code.//// Sept-2011 by Capella by at http://www.worldwide-invest.org// - Cleaned code from unused code, proper variable names and sub-names.//// Ver. 1.0 - 2011-09-24 by Capella at http://www.worldwide-invest.org// - Added Print lines for STOPLEVEL when errors (for debugging purposes)// - Removed unused externals and variables// - Moved dynamic TP/SL and trading signals constants to externals,// as VolatilityLimit and Scalpfactor.// - Forced TrailingStop//// Ver. 2.0 - 2011-10-19 by Capella at http://www.worldwide-invest.org// - Fixing bugs, and removed unused code.// - Forced Trailing, as no-trailing cannot generate profit// - Forced HighSpeed, as false mode cannot give good result// - Added additional settings for scalping - UseMovingAverage,// UseBollingerBands, and OrderExpireSeconds// - Automatic adjusted to broker STOPLEVEL, to avoid OrderSend error 130// Ver 2.1 - 2011-11-91 by Capella at http://www.worldwide-invest.org// - Added Indicatorperiod as external// - Modified calculation of variable that triggers trade (local_pricedirection)// - Removed Distance as an external, and automatically adjust Distance to be the same as stoplevel// - Removed call for sub_moveandfillarrays as it doesnt make any difference// Ver 2.1.1 - 2011-11-05 by Capella at http://www.worldwide-invest.org// - Fixed a bug in the calculation of local_highest and local_lowest that caused wrong call for// OrderModify.// - Changed the calculation of STOPLEVEL to also consider FREEZELEVEL// Ver 2.1.2 - 2011-11-06 by Capella// - Changed default settings according to optimized backtests// - Added external parameter Deviation for iBands, default 0// -------------------------------------------------------------------------------------------------#property show_inputs#include <stdlib.mqh>//----------------------- Externals ----------------------------------------------------------------// All externals here have their name starting with a CAPITAL characterextern string Configuration = "==== Configuration ====";extern int Magic = 0;extern string OrderCmt = "";extern bool NDDmode = FALSE;extern bool Show_Debug = FALSE;extern bool Verbose = FALSE;extern string ScalpingSettings = "==== Scalping settings ====";extern double TakeProfit = 10.0; // TakeProfit from as many points. Default 10 (= 1 pip)extern double StopLoss = 60.0; // StopLoss from as many points. Default 60 (= 6 pips)extern double Trailing_Start = 0; // Start trailing profit from as so many pips. Default 0extern double VolatilityLimit = 180; // Default 180. Can normally be between 100 and 300extern double Scalpfactor = 66; // 60 to 77 - only used if larger than broker StopLevelextern bool UseMovingAverage = TRUE; // User two iMA as channellextern bool UseBollingerBands = TRUE; // Use iBands as channelextern int IndicatorPeriod = 30; // Period for iMA and iBandsextern double Deviation = 2.00; // Deviation for iBandsextern int OrderExpireSeconds = 3600; // Orders are deted after so many secondsextern string Money_Management = "==== Money Management ====";extern double Min_Lots = 0.01;extern double Max_Lots = 100.0;extern double Risk = 100.0;//--------------------------- Globals --------------------------------------------------------------// All globals have their name written in lower case characters//bool condition1;bool condition2 = FALSE;bool trailingstop = TRUE;int distance = 0;int brokerdigits = 0;int slippage = 3;int array_tickcounts[30];int globalerror = 0;int lasttime = 0;int tickcounter = 0;int upto30counter = 0;int AccNum;double zero = 0.0;double zeropointfour = 0.4;double one = 1.0;double five = 5.0;double ten = 10.0;double twenty = 20.0; Page 1/8
  2. 2. double forty = 40.0;double multiplier;double commission = 0.0;double minmaxlot = 0.1;double maxamount = 0.0;double pipette = 0.0;double upper;double lower;double array_bid[30];double array_ask[30];double array_spread[30];//======================= Program initialization ===========================================================int init(){ int stoplevel; ArrayInitialize(array_spread, 0); VolatilityLimit = VolatilityLimit * Point; Scalpfactor = Scalpfactor * 10 * Point / 3; brokerdigits = Digits; pipette = Point; stoplevel = MathMax(MarketInfo(Symbol(), MODE_FREEZELEVEL), MarketInfo(Symbol(), MODE_STOPLEVEL)); if (TakeProfit < stoplevel) TakeProfit = stoplevel; if (StopLoss < stoplevel) StopLoss = stoplevel; if (distance < stoplevel) distance = stoplevel; if (MathMod(Digits, 2) == 0) slippage = 0; else globalerror = -1; start(); return (0);}//====================== Program start ===================================int start(){ if (brokerdigits == 0) { init(); return; } sub_trade(); return (0);}//===================== Subroutines starts here =========================================// All subs have their names starting with sub_// Exception are the standard routines init() and start()//// Notation:// All parameters in subs have their names starting with par_// All local variables in subs have thewir names starting with local_//void sub_trade(){ string local_textstring; bool local_wasordermodified; bool local_highspeed; bool local_ordersenderror; bool local_isbidgreaterthanima; bool local_isbidgreaterthanibands; bool local_isbidgreaterthanindy; int local_orderticket; int local_lotstep; int local_orderexpiretime; int local_bidpart; int local_askpart; int local_loopcount2; int local_loopcount1; int local_pricedirection; int local_counter1; int local_counter2; double local_askplusdistance; double local_bidminusdistance; double local_a; double local_b; double local_c; double local_scalpsize; Page 2/8
  3. 3. double local_d; double local_orderstoploss; double local_ordertakeprofit; double local_tpadjust; double local_ihigh; double local_ilow; double local_imalow; double local_imahigh; double local_imadiff; double local_ibandsupper; double local_ibandslower; double local_ibandsdiff; double local_highest; double local_lowest; double local_stoplevel; double local_spread; double local_adjuststoplevel; double local_e; double local_avgspread; double local_f; double local_g; double local_h; double local_ihighilowdiff; double local_i; if (lasttime < Time[0]) { lasttime = Time[0]; tickcounter = 0; } else tickcounter++; // Calculate a channel based on some indicators local_ihigh = iHigh(Symbol(), PERIOD_M1, 0); local_ilow = iLow(Symbol(), PERIOD_M1, 0); local_ihighilowdiff = local_ihigh - local_ilow; local_imalow = iMA(NULL, PERIOD_M1, IndicatorPeriod, 0, MODE_LWMA, PRICE_LOW, 0); local_imahigh = iMA(NULL, PERIOD_M1, IndicatorPeriod, 0, MODE_LWMA, PRICE_HIGH, 0); local_imadiff = local_imahigh - local_imalow; local_isbidgreaterthanima = Bid >= local_imalow + local_imadiff / 2; local_ibandsupper = iCustom(NULL, PERIOD_M1, "Bands", IndicatorPeriod, 0, Deviation, MODE_UPPER, 0); local_ibandslower = iCustom(NULL, PERIOD_M1, "Bands", IndicatorPeriod, 0, Deviation, MODE_LOWER, 0); local_ibandsdiff = local_ibandsupper - local_ibandslower; local_isbidgreaterthanibands = Bid >= local_ibandslower + local_ibandsdiff / 2; // local_isbidgreaterthanindy is only used for OrderModify on previous BUY_STOP and SELL_STOP local_isbidgreaterthanindy = FALSE; if (UseMovingAverage == FALSE && UseBollingerBands == TRUE) { local_isbidgreaterthanindy = TRUE; local_highest = local_ibandsupper; local_lowest = local_ibandslower; } else if (UseMovingAverage == TRUE && UseBollingerBands == FALSE) { local_isbidgreaterthanindy = TRUE; local_highest = local_imahigh; local_lowest = local_imalow; } else if (UseMovingAverage == TRUE && UseBollingerBands == TRUE) if (local_isbidgreaterthanima == TRUE && local_isbidgreaterthanibands == TRUE) { local_isbidgreaterthanindy = TRUE; local_highest = MathMax(local_ibandsupper, local_imahigh); local_lowest = MathMin(local_ibandslower, local_imalow); } if (!condition2) { for (local_loopcount2 = OrdersTotal() - 1; local_loopcount2 >= 0; local_loopcount2--) { OrderSelect(local_loopcount2, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderCloseTime() != 0 && OrderClosePrice() != OrderOpenPrice() &&OrderProfit() != 0.0 && OrderComment() != "partial close" && StringFind(OrderComment(), "[sl]from #") == -1 && StringFind(OrderComment(), "[tp]from #") == -1) { condition2 = TRUE; local_a = MathAbs(OrderProfit() / (OrderClosePrice() - OrderOpenPrice())); commission = (-OrderCommission()) / local_a; Print("Commission_Rate : " + sub_dbl2strbrokerdigits(commission)); break; } } } if (!condition2) { for (local_loopcount2 = OrdersHistoryTotal() - 1; local_loopcount2 >= 0; local_loopcount2--) { Page 3/8
  4. 4. OrderSelect(local_loopcount2, SELECT_BY_POS, MODE_HISTORY); if (OrderSymbol() == Symbol() && OrderCloseTime() != 0 && OrderClosePrice() != OrderOpenPrice() &&OrderProfit() != 0.0 && OrderComment() != "partial close" && StringFind(OrderComment(), "[sl]from #") == -1 && StringFind(OrderComment(), "[tp]from #") == -1) { condition2 = TRUE; local_a = MathAbs(OrderProfit() / (OrderClosePrice() - OrderOpenPrice())); commission = (-OrderCommission()) / local_a; Print("Commission_Rate : " + sub_dbl2strbrokerdigits(commission)); break; } } } local_stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point; local_spread = Ask - Bid; local_adjuststoplevel = 0.5; if (local_adjuststoplevel < local_stoplevel - 5.0 * pipette) { local_highspeed = FALSE; local_b = forty * pipette; local_adjuststoplevel = ten * pipette; local_c = five * pipette; } else { local_highspeed = TRUE; local_b = twenty * pipette; local_adjuststoplevel = zero * pipette; local_c = Trailing_Start * pipette; } local_b = MathMax(local_b, local_stoplevel); if (local_highspeed) local_adjuststoplevel = MathMax(local_adjuststoplevel, local_stoplevel); ArrayCopy(array_spread, array_spread, 0, 1, 29); array_spread[29] = local_spread; if (upto30counter < 30) upto30counter++; local_e = 0; local_loopcount2 = 29; for (local_loopcount1 = 0; local_loopcount1 < upto30counter; local_loopcount1++) { local_e += array_spread[local_loopcount2]; local_loopcount2--; } local_avgspread = local_e / upto30counter; if (!condition2 && local_avgspread < 15.0 * pipette) commission = 15.0 * pipette - local_avgspread; local_f = sub_normalizebrokerdigits(Ask + commission); local_g = sub_normalizebrokerdigits(Bid - commission); local_h = local_avgspread + commission; if(local_ihighilowdiff > VolatilityLimit) { if (Bid < local_lowest) local_pricedirection = -1; else if (Bid > local_highest) local_pricedirection = 1; } local_scalpsize = MathMax(local_stoplevel, Scalpfactor); if (Bid == 0.0 || MarketInfo(Symbol(), MODE_LOTSIZE) == 0.0) local_scalpsize = 0; local_i = local_scalpsize + local_avgspread + commission; local_orderexpiretime = TimeCurrent() + OrderExpireSeconds; if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.0) local_lotstep = 5; else local_lotstep = sub_logarithm(0.1, MarketInfo(Symbol(), MODE_LOTSTEP)); if (Risk < 0.001 || Risk > 1000.0) { Comment("ERROR -- Invalid Risk Value."); return; } if (AccountBalance() <= 0.0) { Comment("ERROR -- Account Balance is " + DoubleToStr(MathRound(AccountBalance()), 0)); return; } if (local_scalpsize != 0.0) { maxamount = MathMax(AccountBalance(), maxamount); Page 4/8
  5. 5. local_d = MathMin(AccountFreeMargin() * AccountLeverage() / 2.0, maxamount * Risk / 100.0 * Bid /local_i); minmaxlot = local_d / MarketInfo(Symbol(), MODE_LOTSIZE); minmaxlot = NormalizeDouble(minmaxlot, local_lotstep); minmaxlot = MathMax(Min_Lots, minmaxlot); minmaxlot = MathMax(MarketInfo(Symbol(), MODE_MINLOT), minmaxlot); minmaxlot = MathMin(Max_Lots, minmaxlot); minmaxlot = MathMin(MarketInfo(Symbol(), MODE_MAXLOT), minmaxlot); } // Run through already open orders and modify if necessary local_counter1 = 0; local_counter2 = 0; for (local_loopcount2 = 0; local_loopcount2 < OrdersTotal(); local_loopcount2++) { OrderSelect(local_loopcount2, SELECT_BY_POS, MODE_TRADES); if (OrderMagicNumber() == Magic && OrderCloseTime() == 0) { if (OrderSymbol() != Symbol()) { local_counter2++; continue; } switch (OrderType()) { case OP_BUY: while (trailingstop) { local_orderstoploss = OrderStopLoss(); local_ordertakeprofit = OrderTakeProfit(); if (!(local_ordertakeprofit < sub_normalizebrokerdigits(local_f + local_b) && local_f + local_b -local_ordertakeprofit > local_c)) break; local_orderstoploss = sub_normalizebrokerdigits(Bid - local_b); local_ordertakeprofit = sub_normalizebrokerdigits(local_f + local_b); local_wasordermodified = OrderModify(OrderTicket(), 0, local_orderstoploss,local_ordertakeprofit, local_orderexpiretime, Lime); break; } local_counter1++; break; case OP_SELL: while (trailingstop) { local_orderstoploss = OrderStopLoss(); local_ordertakeprofit = OrderTakeProfit(); if (!(local_ordertakeprofit > sub_normalizebrokerdigits(local_g - local_b) &&local_ordertakeprofit - local_g + local_b > local_c)) break; local_orderstoploss = sub_normalizebrokerdigits(Ask + local_b); local_ordertakeprofit = sub_normalizebrokerdigits(local_g - local_b); local_wasordermodified = OrderModify(OrderTicket(), 0, local_orderstoploss,local_ordertakeprofit, local_orderexpiretime, Orange); break; } local_counter1++; break; case OP_BUYSTOP: if (!local_isbidgreaterthanindy) { local_tpadjust = OrderTakeProfit() - OrderOpenPrice() - commission; while (true) { if (!(sub_normalizebrokerdigits(Ask + local_adjuststoplevel) < OrderOpenPrice() &&OrderOpenPrice() - Ask - local_adjuststoplevel > local_c)) break; local_wasordermodified = OrderModify(OrderTicket(), sub_normalizebrokerdigits(Ask +local_adjuststoplevel), sub_normalizebrokerdigits(Bid + local_adjuststoplevel - local_tpadjust),sub_normalizebrokerdigits(local_f + local_adjuststoplevel + local_tpadjust), 0, Lime); break; } local_counter1++; } else OrderDelete(OrderTicket()); break; case OP_SELLSTOP: if (local_isbidgreaterthanindy) { local_tpadjust = OrderOpenPrice() - OrderTakeProfit() - commission; while (true) { if (!(sub_normalizebrokerdigits(Bid - local_adjuststoplevel) > OrderOpenPrice() && Bid -local_adjuststoplevel - OrderOpenPrice() > local_c)) break; local_wasordermodified = OrderModify(OrderTicket(), sub_normalizebrokerdigits(Bid -local_adjuststoplevel), sub_normalizebrokerdigits(Ask - local_adjuststoplevel + local_tpadjust),sub_normalizebrokerdigits(local_g - local_adjuststoplevel - local_tpadjust), 0, Orange); break; } local_counter1++; } Page 5/8
  6. 6. else OrderDelete(OrderTicket()); } } } local_ordersenderror = FALSE; if (globalerror >= 0 || globalerror == -2) { local_bidpart = NormalizeDouble(Bid / pipette, 0); local_askpart = NormalizeDouble(Ask / pipette, 0); if (local_bidpart % 10 != 0 || local_askpart % 10 != 0) globalerror = -1; else { if (globalerror >= 0 && globalerror < 10) globalerror++; else globalerror = -2; } } // Open new BUY- or SELL-orders, or BUYSTOP or SELLSTOP orders if (local_scalpsize != 0.0 && local_counter1 == 0 && local_pricedirection != 0 &&sub_normalizebrokerdigits(local_h) <= sub_normalizebrokerdigits(forty * pipette) && globalerror == -1) { if (local_pricedirection < 0) { if (local_highspeed) { local_askplusdistance = Ask + distance * Point; if (NDDmode) { local_orderticket = OrderSend(Symbol(), OP_BUYSTOP, minmaxlot, local_askplusdistance, slippage,0, 0, OrderCmt, Magic, 0, Lime); if (OrderSelect(local_orderticket, SELECT_BY_TICKET)) OrderModify(OrderTicket(), OrderOpenPrice(), local_askplusdistance - StopLoss * Point,local_askplusdistance + TakeProfit * Point, local_orderexpiretime, Lime); } else local_orderticket = OrderSend(Symbol(), OP_BUYSTOP, minmaxlot, local_askplusdistance, slippage,local_askplusdistance - StopLoss * Point, local_askplusdistance + TakeProfit * Point, OrderCmt, Magic,local_orderexpiretime, Lime); if (local_orderticket < 0) { local_ordersenderror = TRUE; Print("ERROR BUYSTOP : " + sub_dbl2strbrokerdigits(Ask + local_adjuststoplevel) + " SL:" +sub_dbl2strbrokerdigits(Bid + local_adjuststoplevel - local_scalpsize) + " TP:" +sub_dbl2strbrokerdigits(local_f + local_adjuststoplevel + local_scalpsize)); } else { PlaySound("news.wav"); Print("BUYSTOP : " + sub_dbl2strbrokerdigits(Ask + local_adjuststoplevel) + " SL:" +sub_dbl2strbrokerdigits(Bid + local_adjuststoplevel - local_scalpsize) + " TP:" +sub_dbl2strbrokerdigits(local_f + local_adjuststoplevel + local_scalpsize)); } } else // local_highspeed == FALSE { if (Bid - local_ilow > 0.0) { local_orderticket = OrderSend(Symbol(), OP_BUY, minmaxlot, Ask, slippage, 0, 0, OrderCmt, Magic,local_orderexpiretime, Lime); if (local_orderticket < 0) { local_ordersenderror = TRUE; Print("ERROR BUY Ask:" + sub_dbl2strbrokerdigits(Ask) + " SL:" + sub_dbl2strbrokerdigits(Bid -local_scalpsize) + " TP:" + sub_dbl2strbrokerdigits(local_f + local_scalpsize)); } else { while (true) { local_wasordermodified = OrderModify(local_orderticket, 0, sub_normalizebrokerdigits(Bid -local_scalpsize), sub_normalizebrokerdigits(local_f + local_scalpsize), local_orderexpiretime, Lime); break; } PlaySound("news.wav"); Print("BUY Ask:" + sub_dbl2strbrokerdigits(Ask) + " SL:" + sub_dbl2strbrokerdigits(Bid -local_scalpsize) + " TP:" + sub_dbl2strbrokerdigits(local_f + local_scalpsize)); } } } } else { if (local_pricedirection > 0) { if (local_highspeed) { Page 6/8
  7. 7. local_bidminusdistance = Bid - distance * Point; if (NDDmode) { local_orderticket = OrderSend(Symbol(), OP_SELLSTOP, minmaxlot, local_bidminusdistance,slippage, 0, 0, OrderCmt, Magic, 0, Orange); if (OrderSelect(local_orderticket, SELECT_BY_TICKET)) OrderModify(OrderTicket(), OrderOpenPrice(), local_bidminusdistance + StopLoss * Point,local_bidminusdistance - TakeProfit * Point, local_orderexpiretime, Orange); } else local_orderticket = OrderSend(Symbol(), OP_SELLSTOP, minmaxlot, local_bidminusdistance,slippage, local_bidminusdistance + StopLoss * Point, local_bidminusdistance - TakeProfit * Point, OrderCmt,Magic, local_orderexpiretime, Orange); if (local_orderticket < 0) { local_ordersenderror = TRUE; Print("ERROR SELLSTOP : " + sub_dbl2strbrokerdigits(Bid - local_adjuststoplevel) + " SL:" +sub_dbl2strbrokerdigits(Ask - local_adjuststoplevel + local_scalpsize) + " TP:" +sub_dbl2strbrokerdigits(local_g - local_adjuststoplevel - local_scalpsize)); } else { PlaySound("news.wav"); Print("SELLSTOP : " + sub_dbl2strbrokerdigits(Bid - local_adjuststoplevel) + " SL:" +sub_dbl2strbrokerdigits(Ask - local_adjuststoplevel + local_scalpsize) + " TP:" +sub_dbl2strbrokerdigits(local_g - local_adjuststoplevel - local_scalpsize)); } } else // local_highspeed == FALSE { if (local_ihigh - Bid < 0.0) { local_orderticket = OrderSend(Symbol(), OP_SELL, minmaxlot, Bid, slippage, 0, 0, OrderCmt,Magic, local_orderexpiretime, Orange); if (local_orderticket < 0) { local_ordersenderror = TRUE; Print("ERROR SELL Bid:" + sub_dbl2strbrokerdigits(Bid) + " SL:" +sub_dbl2strbrokerdigits(Ask + local_scalpsize) + " TP:" + sub_dbl2strbrokerdigits(local_g - local_scalpsize)); } else { while (true) { local_wasordermodified = OrderModify(local_orderticket, 0, sub_normalizebrokerdigits(Ask+ local_scalpsize), sub_normalizebrokerdigits(local_g - local_scalpsize), local_orderexpiretime, Orange); break; } PlaySound("news.wav"); Print("SELL Bid:" + sub_dbl2strbrokerdigits(Bid) + " SL:" + sub_dbl2strbrokerdigits(Ask +local_scalpsize) + " TP:" + sub_dbl2strbrokerdigits(local_g - local_scalpsize)); } } } } } } if (globalerror >= 0) Comment("Robot is initializing..."); else { if (globalerror == -2) Comment("ERROR -- Instrument " + Symbol() + " prices should have " + brokerdigits + " fraction digitson broker account"); else { local_textstring = TimeToStr(TimeCurrent()) + " tick:" + sub_adjust00instring(tickcounter); if (Show_Debug || Verbose) { local_textstring = local_textstring + "n" + sub_dbl2strbrokerdigits(Scalpfactor) + " " +sub_dbl2strbrokerdigits(local_scalpsize) + " digits:" + brokerdigits + " " + globalerror + " stopLevel:" +sub_dbl2strbrokerdigits(local_stoplevel); local_textstring = local_textstring + "n" + local_pricedirection + " " +sub_dbl2strbrokerdigits(local_imahigh) + " " + sub_dbl2strbrokerdigits(local_imalow) + " " +sub_dbl2strbrokerdigits(zeropointfour) + " exp:" + TimeToStr(local_orderexpiretime, TIME_MINUTES) + "numOrders:" + local_counter1 + " shouldRepeat:" + local_ordersenderror; local_textstring = local_textstring + "ntrailingLimit:" +sub_dbl2strbrokerdigits(local_adjuststoplevel) + " trailingDist:" + sub_dbl2strbrokerdigits(local_b) + "trailingResolution:" + sub_dbl2strbrokerdigits(local_c) + " useStopOrders:" + local_highspeed; } local_textstring = local_textstring + "nBid:" + sub_dbl2strbrokerdigits(Bid) + " Ask:" +sub_dbl2strbrokerdigits(Ask) + " avgSpread:" + sub_dbl2strbrokerdigits(local_avgspread) + " Commission rate:" +sub_dbl2strbrokerdigits(commission) + " Real avg. spread:" + sub_dbl2strbrokerdigits(local_h) + " Lots:" +sub_dbl2strparb(minmaxlot, local_lotstep); if (sub_normalizebrokerdigits(local_h) > sub_normalizebrokerdigits(forty * pipette)) { local_textstring = local_textstring + "n" + "Robot is OFF :: Real avg. spread is too high for thisscalping strategy ( " + sub_dbl2strbrokerdigits(local_h) + " > " + sub_dbl2strbrokerdigits(forty * pipette) + ")"; } Comment(local_textstring); Page 7/8
  8. 8. if (local_counter1 != 0 || local_pricedirection != 0 || Verbose) sub_printformattedstring(local_textstring); } }}string sub_dbl2strbrokerdigits(double par_a){ return (DoubleToStr(par_a, brokerdigits));}string sub_dbl2strparb(double par_a, int par_b){ return (DoubleToStr(par_a, par_b));}double sub_normalizebrokerdigits(double par_a){ return (NormalizeDouble(par_a, brokerdigits));}string sub_adjust00instring(int par_a){ if (par_a < 10) return ("00" + par_a); if (par_a < 100) return ("0" + par_a); return ("" + par_a);}double sub_logarithm(double par_a, double par_b){ return (MathLog(par_b) / MathLog(par_a));}void sub_printformattedstring(string par_a){ int local_difference; int local_a = -1; while (local_a < StringLen(par_a)) { local_difference = local_a + 1; local_a = StringFind(par_a, "n", local_difference); if (local_a == -1) { Print(StringSubstr(par_a, local_difference)); return; } Print(StringSubstr(par_a, local_difference, local_a - local_difference)); }} Page 8/8

×