Please can someone help with error 130. - page 2

 

The plan is to have it open close trades like this.


Chart EURUSD, M5, 2014.05.08 14:45 UTC, Forex Capital Markets, LLC, MetaTrader 4, Demo


Any ideas how to get this to work in this code? I really appreciate your help, i finally feel like im getting somewhere


//+------------------------------------------------------------------+
//|                                            Tester.mq4            |
//|                                                                  |
//+------------------------------------------------------------------+

#include <stdlib.mqh>

extern int dist2=6;
extern int SignalBar=2;
input double lots=3; 
input double sl=500;
input double tp=2300;
extern int MagicNumber=45645;
int total = OrdersTotal(); 

//  bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,0)!=EMPTY_VALUE;
//  bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,0)!=EMPTY_VALUE;



int start()

        {
Alert(MarketInfo(Symbol(), MODE_STOPLEVEL));
      
   bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,0)&& 
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,0)!=EMPTY_VALUE;
   

      
      Comment(uptrend,"    ",downtrend);
      
      if(uptrend)
      
        {
         int ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, Ask + tp * Point,NULL, MagicNumber,1, Red); 
         Sleep(20000);
        }
        
      
      if(downtrend) 
      
        {
         ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Bid + tp * Point,NULL, MagicNumber, 0, Blue); 
         Sleep(20000);
        }
        return(0);
       
        }
        
 
This indicator might have problems with sideways as it may generates many signals when that happens.
 
The indicator repaints, it paints a green/red marker and then signals an alert when confirmed by the next bar. Even in sideways markets its not that bad, however I will hopefully have set time frames or filter with another indicator. Well, thats if i can get the bloody code slightly right with assistance from you fine people :-)
 

don't forget to cover all the possibilities as described in the picture



 

As you have indicated, if a buy position is already open, another buy signal is ignored. i.e only one position per direction. Same for the short.


The code I have does not enter positions as i want it to, it enters them as follows...


Chart EURUSD, M5, 2014.05.08 17:37 UTC, Forex Capital Markets, LLC, MetaTrader 4, Demo


here is the code i have : can anyone assist


#include <stdlib.mqh>

extern int dist2=6;
extern int SignalBar=2;
input double lots=3; 
input double sl=1900;
input double tp=2300;
extern int MagicNumber=45645;
extern int MagicNumbera=45675;
int total = OrdersTotal(); 

//  bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,0)!=EMPTY_VALUE;
//  bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,0)!=EMPTY_VALUE;



int start()

        {
Alert(MarketInfo(Symbol(), MODE_STOPLEVEL));
      
   bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,2);
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,2);
   

      
      Comment(uptrend,"    ",downtrend);
      
      if(uptrend)
      
        {
         int ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, Ask + tp * Point,NULL, MagicNumber,1, Red); 
         Sleep(20000);
        }
 
      
      if(downtrend) 
      
        {
         ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Bid + tp * Point,NULL, MagicNumbera, 0, Blue); 
         Sleep(20000);
        }
        return(0);
       
        }
 

you have to add a condition

 if(uptrend && another_order_is_not_open)

in this case you have to loop all the orders to find out if another order is open

same for downtrend

if(downtrend && another_order_is_not_open)
 

already told you once you have to fix you code like before

   bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,1)!=EMPTY_VALUE;
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,1)!=EMPTY_VALUE;
 

I did, same problem. Ive been moving the code around trying different things with no joy.


#include <stdlib.mqh>

extern int dist2=6;
extern int SignalBar=2;
input double lots=3; 
input double sl=600;
input double tp=1200;
extern int MagicNumber=45645;



int start()

        {
Alert(MarketInfo(Symbol(), MODE_STOPLEVEL));
      
   bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,2);
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,2);
   

      
      Comment(uptrend,"    ",downtrend);
      
      if(uptrend)
      
        {
         int ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, Ask + tp * Point,NULL, MagicNumber,1, Red); 
         Sleep(20000);
        }
 
      
      if(downtrend) 
      
        {
         ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Bid + tp * Point,NULL, MagicNumber, 0, Blue); 
         Sleep(20000);
        }
        return(0);
       
        }
 
ryangillSL:

I did, same problem.


no you didn't and you don't listen

i wrote:

qjol:

you have to add a condition

 if(uptrend && another_order_is_not_open)

in this case you have to loop all the orders to find out if another order is open

same for downtrend

if(downtrend && another_order_is_not_open)

and i don't see it in your code

i wrote:

qjol:

already told you once you have to fix you code like before

   bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,1)!=EMPTY_VALUE;
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,1)!=EMPTY_VALUE;

and i don't see it either

so here we go:

B.T.W. it seems to me that you are acting against the trend (IMHO it's supposed to be upside)

#property strict

// #include <stdlib.mqh> why do you need this file included

extern int dist2=6;
extern int SignalBar=2;
input double lots=3; 
input double sl=600;
input double tp=1200;
extern int MagicNumber=45645;
int Buy_Pos = 0, Sell_Pos = 0;
int ticket;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
//---
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
// Alert(MarketInfo(Symbol(), MODE_STOPLEVEL)); what the heck you need this line
   
   for(int i = OrdersTotal() -1; i >= 0; i--)
      {
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
         {
         if (OrderType() == OP_BUY)
            {
            Buy_Pos++;
            }
         if (OrderType() == OP_SELL)
            {
            Sell_Pos++;
            }
         }
      }
      
   bool uptrend=iCustom(NULL,0,"super_signals_v2_alert",1,1)!=EMPTY_VALUE;
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",0,1)!=EMPTY_VALUE;
   
   Comment(uptrend,"    ",downtrend); //for what reason you need this line
                                      //especially when it's gonna write you
                                      //"false    true", or "true    true" or "false    false"
      
   if(uptrend && Sell_Pos == 0)
      {
      ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, Ask - tp * Point,NULL, MagicNumber,0, Red);
      if (ticket < 0)
         Alert("Can't open Sell Order, Error code ", GetLastError());
      //Sleep(20000); // why in the world you need this line
      }
   
   if(downtrend && Buy_Pos == 0) 
      {
      ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Bid + tp * Point,NULL, MagicNumber, 0, Blue); 
      if (ticket < 0)
         Alert("Can't open Buy Order, Error code ", GetLastError());
      //Sleep(20000); // why in the world you need this line
      }
   
//---
  }
 
if(uptrend && Sell_Pos == 0)
      {
      ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Ask + sl * Point, Ask + tp * Point,NULL, MagicNumber,1, Red);
      if (ticket < 0)
         Alert("Can't open Sell Order, Error code ", GetLastError());
For a sell order, you cannot set the TP at a higher price than the entry price
Reason: