Download MetaTrader 5

Can someone help me fix my code?

To add comments, please log in or register
Your conversation partner speaks foreign language? Automatic translation will help you!
LanceHardwood
36
LanceHardwood 2016.02.03 16:57 

the following is in MQL4!!!

so i have been programming my code and i have been constantly getting error code 129. i don't know how to fix it

also:

the Alert("Target Hit") comes WAY after my price target hit, way to delayed.:

if(Variable_1 < Variable_2 && MarketInfo(Symbol(), MODE_ASK) <= PriceTargetWhereIWantToSell)
      {
            Alert("Target Hit");
           
            PosSizeShort           = 5;
           
            OpenShorts             = OpenShorts + PosSizeShort;

            RefreshRates();
           
            int TICKET = OrderSend(Symbol(), OP_SELL, (double)PosSizeShort, Ask, 5, GoalLongs, GoalShorts);
            if(TICKET < 0)
             {Alert("order failed: error #", GetLastError());}
             else{Alert("Order placed succesfully");}      

      }

can someone please help its important

     

Biantoro Kunarto
14882
Biantoro Kunarto 2016.02.04 09:19  

Hi, Next time please use SRC button to put your code in this forum

In your code, you must use Bid instead Ask

if(   Variable_1 < Variable_2 && MarketInfo(Symbol(), MODE_ASK) <= PriceTargetWhereIWantToSell )
   {
      Alert("Target Hit");
      PosSizeShort   = 5;
      OpenShorts     = OpenShorts + PosSizeShort;
      RefreshRates();
      int TICKET = OrderSend(Symbol(), OP_SELL, (double)PosSizeShort, Bid, 5, GoalLongs, GoalShorts);
      if(TICKET < 0)
         Alert("order failed: error #", GetLastError());
      else
         Alert("Order placed succesfully");
   }
ffoorr
1016
ffoorr 2016.02.04 15:28  

Have a look there, maybe want you intent to do :

EES Hedger - Take the other side of the trade - buy when you are selling, sell when you are buying - expert for MetaTrader


https://www.mql5.com/en/code/8320

EES Hedger - Take the other side of the trade - buy when you are selling, sell when you are buying
EES Hedger - Take the other side of the trade - buy when you are selling, sell when you are buying
  • votes: 4
  • 2008.08.22
  • eesfx
  • www.mql5.com
Do you have the need to take the opposite side of a trade? Using manual trading or another EA, EES Hedger can immediately take the opposite position as specified in EA parameters. Instructions: For example, you are trading SAR EA on GBPUSD and SAR
Earl Forde
11
Earl Forde 2016.02.05 18:20  
Can someone tell me just what's going on with my GPS Robot I installed it more than (2) weeks ago everything seems in order but to this day it has not placed 1 trade is this the norm? or this thing is playing games with me?
To add comments, please log in or register