Experts: EA SmartAssTrade. - page 14

 

Hello,

I'm backtesting your EA and found something I don't understand about TP and SL levels.

First of all: 

If make a run with all default params i can't see no SL nor TP set during order placement, nor I see ordermodify operations.

I've forced the mt4ecn to false even if I'm on a 5 digits and now the SL is regullary set during order placement but not the TP.

Second (and what puzzles me more):

There is no way to see TP and SL dinamically move when AutomaticTakeProfit=true and AutomaticStopLoss=true.

Taking a look to the modif() function I can't see how it could change them!! There is no if(opttp && autsl)  that does the trailing.

The only chance you have is that the ordermodify goes wrong and it has to reiterate entering the last if.

Am I wrong? 

int modif() //--function: OrderModify for MT4 ECN to put Order SL and TP
   {
      //----
      int merr;
      bool mrest;
      total=OrdersTotal();
      //----
      for (it=0; it<total; it++)
          {
             if (OrderSelect(it, SELECT_BY_POS, MODE_TRADES) == True)
                {
                   if (OrderSymbol() == symbol)
                      {
                         if (OrderType() == OP_BUY)
                            {
                               OptSL();
                               CalcProvit();
                               if (!opttp) {tpA=OrderOpenPrice()+tp;}
                               else {tpA = 0;}
                               if (!autsl) {slA = OrderOpenPrice()-sl;}
                               else {slA = iLow(symbol,1440,0)-sl;}
                               if ((!autsl && !opttp) && (OrderStopLoss()==0 && OrderTakeProfit()==0))  
                                  {mrest=OrderModify(OrderTicket(),OrderOpenPrice(),slA,tpA,0);}
                               else if ((!autsl && opttp) && (OrderStopLoss()==0))
                                  {mrest=OrderModify(OrderTicket(),OrderOpenPrice(),slA,OrderTakeProfit(),0);}
                               else if ((!opttp && autsl) && (OrderTakeProfit()==0))
                                  {mrest=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tpA,0);}
                               else {break; return(0);}
                               if(mrest!=true) {merr=GetLastError();}
                               if (merr>0)
                                  {
                                    ResetLastError();
                                    Sleep(2000);
                                    RefreshRates();
                                    mrest=OrderModify(OrderTicket(),OrderOpenPrice(),slA,tpA,0);
                                    merr=GetLastError();
                                    if (merr>0) 
                                     {
                                       Print("Failed to Modify BUY ORDER ",symbol,"! Error code = ",
                                       GetLastError(), ", ",ErrorDescription(merr));
                                       ResetLastError();
                                       return(0);
                                     }                                    
                                  }
                            }
                         //----
 
lord_hiro:

Hello,

I'm backtesting your EA and found something I don't understand about TP and SL levels.

First of all: 

If make a run with all default params i can't see no SL nor TP set during order placement, nor I see ordermodify operations.

I've forced the mt4ecn to false even if I'm on a 5 digits and now the SL is regullary set during order placement but not the TP.

Second (and what puzzles me more):

There is no way to see TP and SL dinamically move when AutomaticTakeProfit=true and AutomaticStopLoss=true.

Taking a look to the modif() function I can't see how it could change them!! There is no if(opttp && autsl)  that does the trailing.

The only chance you have is that the ordermodify goes wrong and it has to reiterate entering the last if.

Am I wrong? 

Hello lord_hiro,

Since MT4 Build 625, ordermodify is no need anymore to MT4ECN.
In other words, order proccess to MT4ECN is the same as MT4 Standard (4 digits).

Now I'm still making an updates to EA SmartAssTrade, so you do not need to hard thinking about how to make modifications to the EA.

Actually, EA on free download Code Base, just as a sample ideas for traders or programmers to create or develop their own EA.
Therefore, with my code on EA SmartAssTrade maybe you can make or create a better EA.

Thanks and regards.

 
Please add the buying strategy.. It will be great. 
 
Dear Friend Roy, I am beginner and his work is far beyond what I can understand, at the time. Congratulations. I put the "EA" in a bullish move it to "buy", but he made no purchase. All settings were default. See here: 

USDCAD 15 

https://www.mql5.com/en/charts/2245779/usdcad-m15-ava-financial-ltd 

Can you help me understand. 

Thank you very much :) 

Peace be with you.
Chart USDCAD, M15, 2014.08.15 17:30 UTC, Ava Financial Ltd., MetaTrader 4, Real
Chart USDCAD, M15, 2014.08.15 17:30 UTC, Ava Financial Ltd., MetaTrader 4, Real
  • www.mql5.com
Symbol: USDCAD. Periodicity: M15. Broker: Ava Financial Ltd.. Trading Platform: MetaTrader 4. Trading Mode: Real. Date: 2014.08.15 17:30 UTC.
 
dphukan007:
Please add the buying strategy.. It will be great. 
Thank you for your suggestion.
The EA code is not relevant since MT4 Build 625.
Now I am still trying to update the code and will soon share in the Code Base with the name SmartAssTrade-V2.

Regards.
 
maciel7000:
Dear Friend Roy, I am beginner and his work is far beyond what I can understand, at the time. Congratulations. I put the "EA" in a bullish move it to "buy", but he made no purchase. All settings were default. See here: 

USDCAD 15 

https://www.mql5.com/en/charts/2245779/usdcad-m15-ava-financial-ltd 

Can you help me understand. 

Thank you very much :) 

Peace be with you.
Dear my friend maciel7000.
I sorry, I do not understand your point.
This EA's code, it is not relevant since MT4 Build 625.
Now I am still trying to update the code and formula,  I will soon share in the code base with the name SmartAssTrade-V2.

Regards.
 

------------------------------------------------------------------

Dear

my friend maciel7000. 
I sorry, I do not understand your point. 
This EA's code, it is not relevant since MT4 Build 625. 
Now I am still trying to update the code and formula,  I will soon share in the code base with the name SmartAssTrade-V2. 

Regards.

3rjfx 

------------------------------------------------------------------------------- 

Thank you friend for the answer. 
I feel you're already a winner. 
I'll wait for the version of SmartAssTrade-V2. 
Greetings from Brazil and come here on vacation. 
Thank you. Maciel7000
 
3rjfx:

Hi willgart,

It's up to you, if you like to make modification or optimization and improve that EA for your purpose only.
But, Are you don't know that magicnumber, deviation, color,
or something like it, will not be accepted by MT4 ECN server?


If you don't know that in MT4 ECN, OrderSend function () should not be put TP and SL,
MagicNumber, Deviation and Color? But TP and SL should be done through OrderModify function ()?

Hence, why on the EA SmartAssTrade I make lot of command OrderModify ().

If you try the script that you modified on MT4 ECN, I am sure that EA will not make a trade at all.

For your information, when I trading on my broker server (2 and 4 digits or 3 and 5 digits after the decimal points) is not an error at all as you say.

In deinit function (), I made ​​an command for modification of the order,
because if it is not modified, when the computer is turned off
(on the set TP=true or SL=true), then the orders are still open
(floating loss) that currently do not have TP or SL.

Hope you can understand.

Regards.

 

1. Magic Number has nothing about ECN

2. ECN is not determined by Digits

3. Only one value can be returned for a  function. 

 

 //

 

//+------------------------------------------------------------------+
//|                                                SmartAssTrade.mq4 |
//|                 Copyright 2014,  Roy Philips Jacobs ~ 25/01/2014 |
//|                            http://www.gol2you.com ~ Forex Videos |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014,  Roy Philips Jacobs ~  ~ Last Update 03/03/2014"
#property link      "http://www.gol2you.com ~ Forex Videos"
//---
#include <stderror.mqh>
#include <stdlib.mqh>
//--- User Input
extern string      SmartAssTrade = "Copyright © 2014 3RJ ~ Roy Philips-Jacobs";
extern bool              Hedging = False; // If True, EA will open order BUY and SELL according to the trend change.
extern string   OptimizationLots = "Set LotsOptimization=True, Lots=0.0"; 
extern bool     LotsOptimization = False; // If True, Lots wil calculation by EA
extern double               Lots = 1.0; // If LotsOptimization=False, Lots adjusted by user
extern string  AutomaticSystemTP = "Set AutomaticTakeProfit=True or False";
extern bool  AutomaticTakeProfit = True; // TP will calculation by EA and Automatic TP by EA
extern bool  NoMinimumTakeProfit = False; // True or False -> If Set True, 100% TP by EA not use minimum TP.
extern string    MinimumSystemTP = "If Set NoMinimumTakeProfit=False"; // TP by EA on minimum TP values
extern double          MinimumTP = 15; // Minimum TP by EA on the AutomaticTakeProfit=True function.
extern string     ManualSystemTP = "If Set AutomaticTakeProfit=False"; // TP by System MT4 (same as manual trading)
extern double         TakeProfit = 25; // TP by System, values can adjust by user
extern string  AutomaticSystemSL = "Set AutomaticStopLoss=True";
extern bool    AutomaticStopLoss = True; // SL will calculation by EA
extern string     ManualSystemSL = "If Set AutomaticStopLoss=False"; // SL values can adjusted by user
extern double           StopLoss = 350; // SL adjusted by user
//----
//---- Global scope
double lot,pp,digit;
double sbb,BBlt0,BBlb0;
double lastAsk,lastBid;
double mrg,ask,bid,sl,tp;
double slA,slB,tpA,tpB,tpAS,tpBS;
double difB,difS,pBo,pSo,pdifB,pdifS;
//---
bool mt4ecn,ohdg;
bool NoOrder,nomintp;
bool lotopt,opttp,autsl;
bool mdHC,mdLC,mdUp,mdDn;
bool SignalBuy,SignalSell;
//---
int TFX[]={5,15,30}; // Timeframes OsMA && MA
//---
int spg=0;
int tfm=60;
int totfr,Mnt;
int total,totalord,totalpft,totalhst;
int dev,hb,hs,ob,os,i,ip,is,it,nx,ox;
//---
string symbol;
string CopyR;
//----    
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {      
//----  
   symbol = Symbol(); 
   CopyR = "Copyright © 2014 3RJ ~ Roy Philips-Jacobs";
//---- 
   // Checking the Digits Point
   digit=Digits;
   if (digit==3 || digit==5)
      {pp=Point*10; dev=pp*spg*10; mt4ecn=true;}
   else {pp=Point; dev=pp*spg; mt4ecn=false;}
//----
   difB=0.8;
   difS=0.8;
   nx=0;
   ox=1;
   totfr=1;
   hb=0;
   hs=0;
//---- 
   lotopt=LotsOptimization;
   opttp=AutomaticTakeProfit;
   autsl=AutomaticStopLoss;
   nomintp=NoMinimumTakeProfit;
   ohdg=Hedging;
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| expert proccess working function                                 |
//+------------------------------------------------------------------+
//----
int LotOpt() //--function: calculation Optimization Lots
   {
      if (lotopt) 
         {
           //----
           mrg = AccountBalance();
           if (mrg < 1000) {lot = 0.1;} 
           if ((mrg > 1000) && (mrg < 5000)) {lot = 0.1;}
           if ((mrg > 5000) && (mrg < 9000)) {lot = 0.2;}
           if ((mrg > 9000) && (mrg < 13000)) {lot = 0.3;}
           if ((mrg > 13000) && (mrg < 17000)) {lot = 0.4;}
           if ((mrg > 17000) && (mrg < 21000)) {lot = 0.5;}
           if ((mrg > 21000) && (mrg < 25000)) {lot = 0.6;}
           if ((mrg > 25000) && (mrg < 29000)) {lot = 0.7;}
           if ((mrg > 29000) && (mrg < 33000)) {lot = 0.8;}
           if ((mrg > 33000) && (mrg < 37000)) {lot = 0.9;}
           if ((mrg > 41000) && (mrg < 45000)) {lot = 1.0;}
           if (mrg > 45000) {lot = 1.5;}
         }
      else lot = Lots;
      return(lot);
      //----
   } //-end LotOpt()
//---------//

int OptSL() //--function: calculation Stop Loss 
   {   
      if (!autsl) {sl=StopLoss*pp;}
      else {sl=180*pp;}
      return(sl);
      //----
   } //-end OptSL()
//---------//

int CkOpen() //--function: CheckOpenTrade.
   {
      //----
      totalord = OrdersTotal();
      ob=0; os=0;
      //----
      for (i=0; i<totalord; i++)   
          {
             if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == True)
                {
                   if (OrderSymbol() == symbol)
                      {
                         if (OrderType() == OP_BUY) {ob++; hb++;}
                         if (OrderType() == OP_SELL) {os++; hs++;}
                      }
                }
          }
     //----     
     return(ob);
     return(os);
     return(hb);
     return(hs);
     //----
   } //-end CkOpen()
//---------//

.........
//+------------------------------------------------------------------+

// 

 

Hello there

 

Im using the Smartasstrade update 2 version is this ok?.... i mean this is the latest updated version yes? :)

 

Btw great EA im using it on Demo and its good, i do close some trade manually when its in profit. I will be going live soon and see.

 
fxmeter:

 

1. Magic Number has nothing about ECN

2. ECN is not determined by Digits

3. Only one value can be returned for a  function. 

 

 //

 

// 

Dear fxmeter,

You are correct, and the code of this EA is already irrelevant since MT4 Build 625.

Therefore, I am now still doing updates for this EA code.

Regards,

Reason: