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 (2) Thread Tools Display Modes
  #1221 (permalink)  
Old 07-13-2008, 05:06 AM
Administrator
 
Join Date: Sep 2005
Posts: 16,815
Blog Entries: 145
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
Moving average is standard indicator in Metatrader.
So, find this indicator here

movingaverages.jpg

and attach to the chart.

Read this thread also How to start with MetaTrader and forex
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1222 (permalink)  
Old 07-13-2008, 07:54 AM
Member
 
Join Date: Dec 2005
Posts: 44
jwhite1319 is on a distinguished road
Quote:
Originally Posted by newdigital View Post
Moving average is standard indicator in Metatrader.
So, find this indicator here

Read this thread also How to start with MetaTrader and forex
Nope, you misunderstood my question. I know how to attach an indicator, no problems there. I need the code to call the indicator from within an EA so that when I load my ea, it will automatically draw the indicator on my screen.

Hope I am clear this time around?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1223 (permalink)  
Old 07-13-2008, 11:19 AM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by jwhite1319 View Post
Nope, you misunderstood my question. I know how to attach an indicator, no problems there. I need the code to call the indicator from within an EA so that when I load my ea, it will automatically draw the indicator on my screen.

Hope I am clear this time around?
An example of a code which plot 2 MAs on chart:

Quote:
ExtCountedBars=IndicatorCounted();
if (ExtCountedBars<0) return(-1);
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{

ExtMapBuffer1[pos] = iMA(Symbol(),0,MAslow_period,MAslow_shift,MAslow_t ype,MAslow_price,pos);
ExtMapBuffer2[pos] = iMA(Symbol(),0,MAfast_period,MAfast_shift,MAfast_t ype,MAfast_price,pos);

pos--;
}
Hope that helps.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1224 (permalink)  
Old 07-13-2008, 01:11 PM
Junior Member
 
Join Date: Feb 2008
Posts: 2
mrpro is on a distinguished road
I was wondering if anyone could help me make this EA increase lots as the account grew.. So it would use a percentage instead of fixed lots. Or just double up everytime the account would double.. Thanks in advance

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

#property copyright "Expert Advisor Builder"
#property link      "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 1.0;
extern int Slippage = 3;
extern bool UseStopLoss = True;
extern int StopLoss = 200;
extern bool UseTakeProfit = False;
extern int TakeProfit = 60;
extern bool UseTrailingStop = True;
extern int TrailingStop = 200;

int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
   BarCount = Bars;

   if (EachTickMode) Current = 0; else Current = 1;

   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   int Order = SIGNAL_NONE;
   int Total, Ticket;
   double StopLossLevel, TakeProfitLevel;



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

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


double Buy1_1 = iClose(NULL, 0, Current + 0);
double Buy1_2 = iOpen(NULL, 0, Current + 3);

double Sell1_1 = iClose(NULL, 0, Current + 0);
double Sell1_2 = iOpen(NULL, 0, Current + 0);



   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
   bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_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(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = 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 * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
                  }
               }
            }
         } else {
            //Close

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

           

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

            if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
               if (!EachTickMode) BarCount = 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 * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
                  }
               }
            }
         }
      }
   }

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

   if (Buy1_1 > Buy1_2) Order = SIGNAL_BUY;

   if (Sell1_1 < Sell1_2) Order = 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 (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
            Print("BUY order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
         } else {
            Print("Error opening BUY order : ", GetLastError());
         }
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = 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 (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
            Print("SELL order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
         } else {
            Print("Error opening SELL order : ", GetLastError());
         }
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }

   if (!EachTickMode) BarCount = Bars;

   return(0);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1225 (permalink)  
Old 07-13-2008, 02:14 PM
Member
 
Join Date: Dec 2005
Posts: 44
jwhite1319 is on a distinguished road
help with code

[quote=FerruFx;220602]An example of a code which plot 2 MAs on chart:



Hope that helps.

Perfect. Exactly what I needed. Thank you, FerruFx!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1226 (permalink)  
Old 07-13-2008, 02:18 PM
Member
 
Join Date: Dec 2005
Posts: 44
jwhite1319 is on a distinguished road
toolbars disappearing.

Does anyone know why my toolbars disappear every time I shutdown MT4? I have to go through and reload the toolbars when I turn MT back on....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1227 (permalink)  
Old 07-13-2008, 04:07 PM
TheRumpledOne's Avatar
Banned
 
Join Date: Nov 2006
Posts: 802
TheRumpledOne is an unknown quantity at this point
compile problem

Perhaps you can help me.

Sometimes when I compile a new indicator, MT4 decides to compile most of my indicators but not all of them. Some of my indicators do NOT appear in the Navigator window when this happens so I can't drag them onto a chart. Do you have any idea why this may happen?

I have to move some indicators into a different folder to get all of my indicators that start with "_TRO_" to compile and appear in the Navigator window. Could the "_" in front of the name be causing the problem?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1228 (permalink)  
Old 07-13-2008, 04:39 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 569
Blog Entries: 1
IN10TION is on a distinguished road
.:: How many indicators do you have in your indicator folder?
Quote:
Originally Posted by TheRumpledOne View Post
Perhaps you can help me.

Sometimes when I compile a new indicator, MT4 decides to compile most of my indicators but not all of them. Some of my indicators do NOT appear in the Navigator window when this happens so I can't drag them onto a chart. Do you have any idea why this may happen?

I have to move some indicators into a different folder to get all of my indicators that start with "_TRO_" to compile and appear in the Navigator window. Could the "_" in front of the name be causing the problem?
__________________
..4.Nov.08.. IN10TION newsReader v09.85 Lite - the best news reader on your chart
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1229 (permalink)  
Old 07-14-2008, 03:25 AM
DeadEye96's Avatar
Member
 
Join Date: Jan 2006
Location: Michigan, USA
Posts: 47
DeadEye96 is on a distinguished road
Talking Evaluating EA settings with the Tester

There is a disagreement between my friend and I about what the most important criteria are for choosing settings for a functional EA that I would like some input on from anyone. While we both are working with very high modeling quality and agree that we need at least 30 trades to have some degree of statistical significance; he is stuck on maximizing net profit while I say percentage of all winning trades is the most important along with a near equality of win rate between longs and shorts. The argument is that a higher win rate will deteriorate less going forward as he is satisfied with a winning trade percentage of maybe 65% while I shoot for at least 80% regardless of the pips won. We both update settings weekly.

Since we are both running different EA's that are meeting with various levels of success so, we cannot compare them equally. Anyone have some experience on this?

Thanks
DeadEye96
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1230 (permalink)  
Old 07-14-2008, 04:25 AM
basza's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 146
basza is on a distinguished road
[quote=mrpro;220609]I was wondering if anyone could help me make this EA increase lots as the account grew.. So it would use a percentage instead of fixed lots. Or just double up everytime the account would double.. Thanks in advance



Hi mrpro

I have added a little bit of code for you which will give you 4 ways of controling your lot size.
I have named it abc.mq4
Information on how to use it is in the code.

Hope this helps
Attached Files
File Type: mq4 abc.mq4 (11.3 KB, 18 views)
__________________
http://westauckfx.oxyrack.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex, ZUP_v1.mq4

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
Posted By For Type Date
OzFx System:) - Page 639 This thread Refback 06-21-2008 10:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 12:46 PM


All times are GMT. The time now is 03:19 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.