Please can someone help with error 130. - page 3

 
you right
 

Hi,


I appreciate your help. The additions to the code i.e


sleep 20000 and the tp+ where added based on advice from another forum member. Please remember I have just started to learn how to code an EA and therefor it is slightly alien for me. What may seem extreamly basic and easy to you is not to me, for now any way. ill learn how to do it but it will take time, and help.


Thank you for helping me.

 

Thank you for you help, it starting to take shape.


However, it does not open trades when the indicator signals, have you any idea why?


Also how would i open the trade on the open of the next bar from an indicator signal?


Thank you so much for your assistance.

 
if (newBar)
   {
   your code
   }

https://www.mql5.com/en/forum/137985

 

again, sorry for not understanding but would i need to declare a variable and then insert this with the order?


Thank you for being patient with me.

 
i.e to open the trade x bars after signal is triggered?
 

Would this be along the correct lines to open the trade on the open of the next bar after the signal bar/trigger using NewBar()?


//+------------------------------------------------------------------+
//|                                            Tester.mq4            |
//|                                                                  |
//+------------------------------------------------------------------+
#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;
bool NewBar();


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
//---
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+


void OnTick()
  {

   
   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",0,0)!=EMPTY_VALUE;
   bool downtrend=iCustom(NULL,0,"super_signals_v2_alert",1,0)!=EMPTY_VALUE;
   
      
   if(uptrend && Sell_Pos == 0)
      if(NewBar())
   
      {
      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());
  
      }
   
   if(downtrend && Buy_Pos == 0) 
      {
      ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Bid + sl,NULL, MagicNumber, 0, Blue); 
      if (ticket < 0)
         Alert("Can't open Buy Order, Error code ", GetLastError());
   
      }
   
//---
  }
Reason: