Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #51 (permalink)  
Old 04-13-2008, 08:46 PM
Junior Member
 
Join Date: Apr 2008
Posts: 1
Forexwindo is on a distinguished road
Beginner's Question: Does Start() run after each tick ?

Is Start() called after each tick?

I am using the strategy tester to cycle through a few days worth of data with a 1M scale and I have the following line in my Start() routine:

Print(Ask);

I expected to see a Journal entry for each and every tick. When I start the strategy tester with a slow playback setting, I see the chart updating but I do not see the Ask price being printed to the Journal very often. The Ask price is only sent to the Journal about once every 15-30 minutes.

Why is this?

Is it possible to create another tab in MT4 or a debug window in the editor to which text can be sent?

Thanks,

Forexwindo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #52 (permalink)  
Old 06-02-2008, 10:11 AM
Junior Member
 
Join Date: Jun 2008
Posts: 1
Sanzabri2 is on a distinguished road
Exclamation More than One Order

Hi,

i´ve got a question: how to allow the expert to place more than one order independently?

Using the command (or another command if anybody know)

total=OrdersTotal();
if(total<1)

we got the control of the number of trades being executed simultaneously (if < 1, one at a tima, if >2, two at a time and so on)

But in real world, that command ends up with the expert placing two or more orders using the same entering conditions (same as using several lots).

I want to allow the expert to place another orders even if there is one or more orders opened, but not place them at thge same moment;

HOW TO ALLOW THE EXPERT TO PLACE MORE THAN ONE ORDER, WITHOUT PLACING THEM AT ONE TIMA?

thank you, waiting for help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #53 (permalink)  
Old 06-03-2008, 03:22 AM
Senior Member
 
Join Date: Jan 2006
Posts: 139
faifarni is on a distinguished road
MTF RWI Trigger??

How would I program a buy trigger for all green and sell trigger for all red for these indicators?? Please help...

Nick,
Attached Files
File Type: mq4 Rads MTFRWI Bar A.mq4 (8.8 KB, 4 views)
File Type: mq4 RWI.mq4 (3.6 KB, 4 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #54 (permalink)  
Old 06-07-2008, 03:44 PM
Junior Member
 
Join Date: Jul 2006
Posts: 29
AirforceMook is on a distinguished road
Red face EA for only once per tick

Hey guys,

I don't know if this has been posted before (I lack the patience to search through threads, sorry!) but I know it's been asked for a lot.

This code will ONLY run once per tick. It will run as soon as a new tick is introduced, and only then, and not function afterwards until another occurs.

Please keep in mind that can actually be a problem, at times. If your orders don't go through, for whatever reason, it will not initiate again. If you want to modify the code to do so, go ahead. I would suggest something like:

Code:
if order fails, fileseek to front of f, write Open[2] to f
This will make the next tick believe it's a new one.
Attached Files
File Type: mq4 NewTick.mq4 (2.1 KB, 7 views)
__________________
//AirforceMook//
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #55 (permalink)  
Old 06-11-2008, 12:40 PM
Senior Member
 
Join Date: Nov 2006
Posts: 122
Yoda_Glenn is on a distinguished road
Are there any books, online tutorials or videos on writing MQL4?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #56 (permalink)  
Old 06-11-2008, 12:48 PM
Administrator
 
Join Date: Sep 2005
Posts: 16,268
Blog Entries: 106
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
The First Book on MQL4
Sergey Kovalyov’s Book Is Now Downloadable!
http://www.forex-tsd.com/general-dis...der-forex.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #57 (permalink)  
Old 06-11-2008, 03:40 PM
Junior Member
 
Join Date: Oct 2006
Posts: 12
forexcel is on a distinguished road
Hello All,

I need help coding this:

Based on a daily chart:

a) Let's say my conditions are met on closing on day#1 and let's assume day# is June 9.
b) Now i want to place a BUY-Stop and a sell-stop at the High and Low on closing on day #2 or june 10
c) Finally, i want the trade to be triggered on day#3.

Additionally, if the LONG is triggered first, i want the sell-stop to be closed and vice-versa.

Thanks in advance for your help.

regards,

forexcel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #58 (permalink)  
Old 06-23-2008, 12:38 AM
Junior Member
 
Join Date: Feb 2008
Posts: 5
kawase is on a distinguished road
EA for appointing day of a week ,and time

Do not you know EA which you choose the day,(For example, only Wednesday and Thursday) and appoint time for opening and closing?

In many cases,
A rate rises on Wednesday and Thursday since many people to get the SWAP.
I buy it at this time and take a position.
And the rate falls as soon as an SWAP occurred.
I am sold at this time and take a position.

I am looking for EA to use for like this trade.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #59 (permalink)  
Old 06-27-2008, 03:51 PM
Member
 
Join Date: Mar 2008
Posts: 44
mauro269 is on a distinguished road
I need help!

Hi guys,
I need help. I have this EA that I've created

PHP Code:
#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

#property copyright "FxAttack"
#property link      "http://www.ioinvesto.com"

extern int MagicNumber 0;
extern bool SignalMail False;
extern bool EachTickMode True;
extern double Lots 0.1;
extern int Slippage 3;
extern bool UseStopLoss True;
extern int StopLoss 25;
extern bool UseTakeProfit True;
extern int TakeProfit 25;
extern bool UseTrailingStop False;
extern int TrailingStop 30;
extern bool Use.Time.Filter true;
extern string Server.Time.To.Start "00:00";
extern string Server.Time.To.Stop "17:00";
extern bool Not.Trade.Fri.Sun True;



int BarCount;
int Current;
bool TickCheck False;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
   
BarCount Bars;

   if (
EachTickModeCurrent 0; else Current 1;

   return(
0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
   return(
0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   
int Order SIGNAL_NONE;
   
int TotalTicket;
   
double StopLossLevelTakeProfitLevel;



   if (
EachTickMode && Bars != BarCountTickCheck False;
   
Total OrdersTotal();
   
Order SIGNAL_NONE;

   
//+------------------------------------------------------------------+
   //| Variable Begin                                                   |
   //+------------------------------------------------------------------+

double OpenPrice iOpen(NULLPERIOD_D1Current 0);
double Buy_Sign = (OpenPrice + (30*Point));
double Sell_Sign = (OpenPrice - (30*Point));
double start_time StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " Server.Time.To.Start);
double end_time StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " Server.Time.To.Stop);




      
Comment("Open Price = ",OpenPrice);
   
   
//+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+


if(Use.Time.Filter && (TimeCurrent() < start_time || TimeCurrent() >= end_time)) return(0);

if(
Not.Trade.Fri.Sun && (DayOfWeek()==|| DayOfWeek()==)) return(0);


   
//Check position
   
bool IsTrade False;

   for (
int i 0Total++) {
      
OrderSelect(iSELECT_BY_POSMODE_TRADES);
      if(
OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         
IsTrade True;
         if(
OrderType() == OP_BUY) {
            
//Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+




            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+



            
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               
OrderClose(OrderTicket(), OrderLots(), BidSlippageMediumSeaGreen);
               if (
SignalMailSendMail("[Signal Alert]""[" Symbol() + "] " DoubleToStr(BidDigits) + " Close Buy");
               if (!
EachTickModeBarCount Bars;
               
IsTrade False;
               continue;
            }
            
//Trailing stop
            
if(UseTrailingStop && TrailingStop 0) {                 
               if(
Bid OrderOpenPrice() > Point TrailingStop) {
                  if(
OrderStopLoss() < Bid Point TrailingStop) {
                     
OrderModify(OrderTicket(), OrderOpenPrice(), Bid Point TrailingStopOrderTakeProfit(), 0MediumSeaGreen);
                     if (!
EachTickModeBarCount Bars;
                     continue;
                  }
               }
            }
         } else {
            
//Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Sell)                                          |
            //+------------------------------------------------------------------+



            //+------------------------------------------------------------------+
            //| Signal End(Exit Sell)                                            |
            //+------------------------------------------------------------------+

            
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               
OrderClose(OrderTicket(), OrderLots(), AskSlippageDarkOrange);
               if (
SignalMailSendMail("[Signal Alert]""[" Symbol() + "] " DoubleToStr(AskDigits) + " Close Sell");
               if (!
EachTickModeBarCount Bars;
               
IsTrade False;
               continue;
            }
            
//Trailing stop
            
if(UseTrailingStop && TrailingStop 0) {                 
               if((
OrderOpenPrice() - Ask) > (Point TrailingStop)) {
                  if((
OrderStopLoss() > (Ask Point TrailingStop)) || (OrderStopLoss() == 0)) {
                     
OrderModify(OrderTicket(), OrderOpenPrice(), Ask Point TrailingStopOrderTakeProfit(), 0DarkOrange);
                     if (!
EachTickModeBarCount Bars;
                     continue;
                  }
               }
            }
         }
      }
   }

   
//+------------------------------------------------------------------+
   //| Signal Begin(Entry)                                              |
   //+------------------------------------------------------------------+

   
if (Bid Buy_SignOrder SIGNAL_BUY;

   if (
Ask Sell_SignOrder SIGNAL_SELL;


   
//+------------------------------------------------------------------+
   //| Signal End                                                       |
   //+------------------------------------------------------------------+

   //Buy
        
   
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!
IsTrade) {
         
//Check free margin
         
if (AccountFreeMargin() < (1000 Lots)) {
            Print(
"We have no money. Free Margin = "AccountFreeMargin());
            return(
0);
         }



         if (
UseStopLossStopLossLevel Ask StopLoss Point; else StopLossLevel 0.0;
         if (
UseTakeProfitTakeProfitLevel Ask TakeProfit Point; else TakeProfitLevel 0.0;


         
Ticket OrderSend(Symbol(), OP_BUYLotsAskSlippageStopLossLevelTakeProfitLevel"MaxPower Buy Order"MagicNumber0DodgerBlue);
         
         
         if(
Ticket 0) {
            if (
OrderSelect(TicketSELECT_BY_TICKETMODE_TRADES)) {
                Print(
"BUY order opened : "OrderOpenPrice());
                if (
SignalMailSendMail("[Signal Alert]""[" Symbol() + "] " DoubleToStr(AskDigits) + " Open Buy");
            } else {
                Print(
"Error opening BUY order : "GetLastError());
            }
         }




         
         if (
EachTickModeTickCheck True;
         if (!
EachTickModeBarCount Bars;
         return(
0);
      }
   }


   
   
//Sell
   
     
        
   
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!
IsTrade) {
         
//Check free margin
         
if (AccountFreeMargin() < (1000 Lots)) {
            Print(
"We have no money. Free Margin = "AccountFreeMargin());
            return(
0);
         }


         if (
UseStopLossStopLossLevel Bid StopLoss Point; else StopLossLevel 0.0;
         if (
UseTakeProfitTakeProfitLevel Bid TakeProfit Point; else TakeProfitLevel 0.0;


         
Ticket OrderSend(Symbol(), OP_SELLLotsBidSlippageStopLossLevelTakeProfitLevel"MaxPower Sell Order"MagicNumber0DeepPink);
       
         
         if(
Ticket 0) {
            if (
OrderSelect(TicketSELECT_BY_TICKETMODE_TRADES)) {
                Print(
"SELL order opened : "OrderOpenPrice());
                if (
SignalMailSendMail("[Signal Alert]""[" Symbol() + "] " DoubleToStr(BidDigits) + " Open Sell");
            } else {
                Print(
"Error opening SELL order : "GetLastError());
            }
         }
         if (
EachTickModeTickCheck True;
         if (!
EachTickModeBarCount Bars;
         return(
0);
      }
   }


   if (!
EachTickModeBarCount Bars;

   return(
0);
}



//+------------------------------------------------------------------+ 



......but I don't understand how to put the code below inner it.

PHP Code:
...

 for (
int i=0i<OrdersTotal(); i++) {
    if (
OrderSelect(iSELECT_BY_POSMODE_TRADES)) {
      if (
OrderSymbol()==Symbol()  ) 

return(
0);


.... 
The last block of code that I've written is: "If one order on one SYMBOL has been already opened, do not open new orders on that SYMBOL".
Can someone help me to integrate it?
Thanks,

Mauro
__________________
I'm studing to become an MQL Programmer!
The best strategy to use ForexKiller. Try it: http://forex-killerallday.blogspot.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #60 (permalink)  
Old 07-21-2008, 08:38 AM
Junior Member
 
Join Date: Aug 2006
Posts: 9
scottymoll is on a distinguished road
EA only makes one trade...

Hey guys, I have a quick question for you. I recently created an EA. The parameters are correct and when I added it to the chart, it placed an appropriate Buy and then later a Sell. But, the next time a Buy signal came, it never placed a trade. Seems that the EA is only taking the first trade and then none thereafter. Any idea why this might be? I'd appreciate any help. Thanks!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks