Quantcast
Channel: MQL5: MetaTrader 5 trading, automated systems and strategy testing forum
Viewing all 75046 articles
Browse latest View live

Run an script without attach it to a chart?

$
0
0

I would want to run a script from a script.

No problem is it is not needed input paramethers - need just use API function.


Experts: KNUX Martingale

$
0
0
sinecure:

Good question Pedro. Is the other version much easier to opimize?

Meanwhile, I cannot make Tickstory run on my computer. I asked a friend to try and it won't start on his computer either. Must be a bug? Is there another simple way to get tick data? I looked at Birt's tools and so far have not been able to make them work.

Thanks,

Tickstory Lite is the easiest way.

Otherwise u can use SQ Tick Data downloader, and conver the data with Tick Data Suite. The advantage of Tick Data Suite is the ability to use variable spread (real). Which make backtests much more trustworthy!

But it takes more time and learning. Anyway, i strongly recommend. 

Angle indicator keeps returning 0.000

$
0
0

Hi guys,

 Sorry to disturbed you guys again but I wrote this code and it keeps return 0.0000. All the values in CiMA signal are the same and I'm not sure why. I have a refresh function in the code I am hoping someone can help. Sorry to be annoying and thank you for help. This is one of my first every indicators and I'm trying to get the hang of it.

 

//+------------------------------------------------------------------+
//|                                                MA_angle_CiMA.mq5 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_minimum -90
#property indicator_maximum 90
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Angle
#property indicator_label1  "Angle"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

#include <Indicators\Trend.mqh>
//--- input parameters
input int      MA_period = 100;
input ENUM_MA_METHOD     MA_type = MODE_SMA;
input int      AngleBars = 2;
//--- indicator buffers
double         AngleBuffer[];

CiMA *_ma;

double pi = 3.14159265358979323846;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

         SetIndexBuffer(0,AngleBuffer,INDICATOR_DATA);
         
   _ma = new CiMA;
   
     if (AngleBars < 2)
   {
      Print("Error anglebars less than 2, ending program");
      return(INIT_FAILED);
   }
  
   
   if (AngleBars > MA_period)
   {
      Print("Error anglebars must be less than moving average period");
      return(INIT_FAILED);
   }
   
   if (_ma == NULL)
      {
         Print("Indicator null value, exiting program");
         return(INIT_FAILED);
      }
      
    if (!_ma.Create(_Symbol,_Period, MA_period, 0, MA_type, PRICE_CLOSE))
      {
         Print("Error creating indicator, exiting program");
         return(INIT_FAILED);
      }
      


//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

void OnDeinit(const int reason)
{
   delete(_ma);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
      int i, start;
      
      if (rates_total < MA_period) return(0);
      
      _ma.Refresh(_Period);
      
      if (_ma.BarsCalculated() < rates_total) return(0);
      
       if (prev_calculated == 0)
      {
         for (i = 0; i < (AngleBars - 1); i++)
         {
            AngleBuffer[i] = 0.0;
         }
      }
      
      if (prev_calculated == 0)
      {
         start = AngleBars - 1;
      }
    else
      {
      //rates_total for the previous tick = prev_calculated
       start = prev_calculated - 1;
      }
      
       
    for (i = start; i < rates_total; i++)
      {
         
         double diff = _ma.Main(i) - _ma.Main(i - (AngleBars - 1));
         
         double roc = (diff * 10000)/AngleBars;
         
         AngleBuffer[i] = MathArctan(roc) * (180/pi);
         
      }
      
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

The code I am not sure where the problem is tbh. 

Traders Joking

what is good forum for general discussion about trading,

$
0
0

this forum seems to be fairly script, bot and EA orientated.

 

can someone recommend one for general trading discussion , a forum i mean?

 

im beginner.

 

cheers 

50pips per day on Gold using EMA 50

$
0
0

@Toby   

 

I dont  really use stop loss, which is a big weakness on my side.


Your chart shows the strategy works but must be finetuned.  

I am still doing some research with my Matlab software and I will come out with more details on how  to combine the

EMA 50 and EMA 110   to ensure more successful Gold trades.

 

all comments are welcomed, in fact the criticisms to the strategy will be appreciated

Why my optimization settings are hidden?

Experts: RoNz Auto SL-TS-TP v.2

$
0
0

Hi Ron


Have you tried your ea on a renko chart? Will it work there?


Low Signal Volume MT4

$
0
0
peterdanek:
I can see finally Subscribers' funds:
1.3K USD . But it was like 6h delay after setup it in MT4. So we will see tomorrow if the volume will be OK.
I can understand seeing a delay in the subscribers funds, but that should have no relation to the lot sizing. Please report back when you have tested further.

Cheers

Traders Joking

_Digits reports a 3 but is not accepting 3 digit prices when attempting to order (XAUSD on mql demo server)

$
0
0
angevoyageur:
Exactly something like that.

//.................................
               double priceinticks=NormalizeDouble(tick.ask/SymTicSize,0);
               request.price  = priceinticks*SymTicSize;
//................................

This worked for normalizing tp and sl and entries but when I try and instant buy or instant sell to force close a position I get this:

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:31   take profit triggered sell 0.51 XAUUSD 1639.150 sl: 1631.480 tp: 1625.630 [#46 buy 0.51 XAUUSD at 1625.630]

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:31   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:31   price corrected from 1625.650 to 1625.654, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.854 / 1625.654 / 1624.854)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:30   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:30   price corrected from 1625.650 to 1625.652, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.852 / 1625.652 / 1624.852)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:30   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:30   price corrected from 1625.650 to 1625.653, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.853 / 1625.653 / 1624.853)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:29   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:29   price corrected from 1625.650 to 1625.652, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.852 / 1625.652 / 1624.852)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:28   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:28   price corrected from 1625.650 to 1625.653, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.853 / 1625.653 / 1624.853)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:28   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:28   price corrected from 1625.650 to 1625.652, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.852 / 1625.652 / 1624.852)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:27   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:27   price corrected from 1625.650 to 1625.653, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.853 / 1625.653 / 1624.853)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:26   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:26   price corrected from 1625.650 to 1625.652, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.852 / 1625.652 / 1624.852)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:26   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:26   price corrected from 1625.650 to 1625.653, deviation: 99 (instant buy 0.51 XAUUSD at 1625.650)(1624.853 / 1625.653 / 1624.853)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:25   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:25   price corrected from 1625.720 to 1625.719, deviation: 99 (instant buy 0.51 XAUUSD at 1625.720)(1624.919 / 1625.719 / 1624.919)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:24   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:24   price corrected from 1625.790 to 1625.785, deviation: 99 (instant buy 0.51 XAUUSD at 1625.790)(1624.985 / 1625.785 / 1624.985)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:24   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:24   price corrected from 1625.850 to 1625.851, deviation: 99 (instant buy 0.51 XAUUSD at 1625.850)(1625.051 / 1625.851 / 1625.051)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:23   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:23   price corrected from 1625.920 to 1625.917, deviation: 99 (instant buy 0.51 XAUUSD at 1625.920)(1625.117 / 1625.917 / 1625.117)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:22   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:22   price corrected from 1625.980 to 1625.983, deviation: 99 (instant buy 0.51 XAUUSD at 1625.980)(1625.183 / 1625.983 / 1625.183)

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:22   [Sell] ERROR closing #4756

2015.02.25 18:46:05 Core 1 2012.04.23 15:20:22   price corrected from 1626.050 to 1626.049, deviation: 99 (instant buy 0.51 XAUUSD at 1626.050)(1625.249 / 1626.049 / 1625.249)


 

And if I try this instead:

//...............
               request.price= tick.ask
//...............

 

 I get this;:

 

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:31   take profit triggered sell 0.51 XAUUSD 1639.150 sl: 1631.480 tp: 1625.630 [#46 buy 0.51 XAUUSD at 1625.630]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:31   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:31   failed instant buy 0.51 XAUUSD at 1625.654 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:30   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:30   failed instant buy 0.51 XAUUSD at 1625.652 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:30   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:30   failed instant buy 0.51 XAUUSD at 1625.653 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:29   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:29   failed instant buy 0.51 XAUUSD at 1625.652 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:28   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:28   failed instant buy 0.51 XAUUSD at 1625.653 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:28   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:28   failed instant buy 0.51 XAUUSD at 1625.652 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:27   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:27   failed instant buy 0.51 XAUUSD at 1625.653 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:26   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:26   failed instant buy 0.51 XAUUSD at 1625.652 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:26   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:26   failed instant buy 0.51 XAUUSD at 1625.653 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:25   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:25   failed instant buy 0.51 XAUUSD at 1625.719 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:24   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:24   failed instant buy 0.51 XAUUSD at 1625.785 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:24   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:24   failed instant buy 0.51 XAUUSD at 1625.851 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:23   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:23   failed instant buy 0.51 XAUUSD at 1625.917 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:22   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:22   failed instant buy 0.51 XAUUSD at 1625.983 [Invalid price]

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:22   [Sell] ERROR closing #4756

2015.02.25 18:57:50 Core 1 2012.04.23 15:20:22   failed instant buy 0.51 XAUUSD at 1626.049 [Invalid price]


Market Condition Evaluation based on standard indicators in Metatrader 5

$
0
0

Forum on trading, automated trading systems and testing trading strategies

Press review

newdigital, 2015.02.26 05:23

2015-02-25 21:45 GMT (or 23:45 MQ MT5 time) | [NZD - Trade Balance]

if actual > forecast (or previous data) = good for currency (for NZD in our case)

[NZD - Trade Balance] =Difference in value between imported and exported goods during the reported month. Export demand and currency demand are directly linked because foreigners must buy the domestic currency to pay for the nation's exports. Export demand also impacts production and prices at domestic manufacturers

==========

New Zealand Has NZ$56 Million Trade Surplus

New Zealand had a merchandise trade surplus of NZ$56 million in January, Statistics New Zealand said on Thursday.

That topped expectations for a deficit of NZ$158 million following the downwardly revised NZ$195 million shortfall in December (originally -NZ$159 million).

Exports were worth NZ$3.70 billion - shy of expectations for NZ$3.73 billion and down from the downwardly revised NZ$4.40 billion in the previous month (originally NZ$4.42 billion).

Imports were at NZ$3.64 billion versus forecasts for NZ$3.94 billion following the upwardly revised NZ$4.60 billion a month earlier (originally NZ$4.58 billion).

MetaTrader Trading Platform Screenshots

NZDUSD, M5, 2015.02.26

MetaQuotes Software Corp., MetaTrader 5

NZDUSD M5: 19 pips price movement by NZD - Trade Balance news event

NZDUSD, M5, 2015.02.26, MetaQuotes Software Corp., MetaTrader 5, Demo



Press review

$
0
0

Gold trade coming back, if you can wait 2 years (based on cnbc article)

Gold will come under further pressure over the course of the year as the Federal Reserve moves closer to lifting rates, but prospects for the precious metal looks far more promising in the next few years, according to Bank of America Merrill Lynch.

"Right now, investors are not in the mood for holding gold because they see the Fed raising rates. So, I think in the next three months you'll see downside risk, $1,100 an ounce is likely," Francisco Blanch, commodities analyst at Bank of America Merrill Lynch told CNBC.

"But if you look out 2-3 years, things are a lot brighter for gold," he said.

Gold kicked off the year with a bang, rising around 8 percent in January. However, the yellow meal has since erased most of its gains as a stronger dollar – driven by rate hike expectations –and gains in equities dim its appeal. Spot gold last traded around the $1,210 level.

Blanch's positive longer-term outlook for gold is driven by two factors.

First, the growing phenomenon of negative-yielding bonds, which makes gold look attractive in comparison.

"There are a growing number of government bonds basically yielding zero or negative. As the number increases, I think a lot of investors are going to wonder why they are holding a liability as opposed to holding an outright asset like gold," he said.

GOLD Technical Analysis 2015, 22.02 - 01.03: Bullish Breakout or Bullish Ranging with 1306.82 Key Resistance

$
0
0

Forum on trading, automated trading systems and testing trading strategies

Press review

newdigital, 2015.02.26 05:37

Gold trade coming back, if you can wait 2 years (based on cnbc article)

Gold will come under further pressure over the course of the year as the Federal Reserve moves closer to lifting rates, but prospects for the precious metal looks far more promising in the next few years, according to Bank of America Merrill Lynch.

"Right now, investors are not in the mood for holding gold because they see the Fed raising rates. So, I think in the next three months you'll see downside risk, $1,100 an ounce is likely," Francisco Blanch, commodities analyst at Bank of America Merrill Lynch told CNBC.

"But if you look out 2-3 years, things are a lot brighter for gold," he said.

Gold kicked off the year with a bang, rising around 8 percent in January. However, the yellow meal has since erased most of its gains as a stronger dollar – driven by rate hike expectations –and gains in equities dim its appeal. Spot gold last traded around the $1,210 level.

Blanch's positive longer-term outlook for gold is driven by two factors.

First, the growing phenomenon of negative-yielding bonds, which makes gold look attractive in comparison.

"There are a growing number of government bonds basically yielding zero or negative. As the number increases, I think a lot of investors are going to wonder why they are holding a liability as opposed to holding an outright asset like gold," he said.


Experts: KNUX V1.0

$
0
0

I have just backtested the EA using 99% modeling quality and real variable spreads (using Tick Data Suite), and the results are not as good as your backtest with fix spread at 18 pips.

But I still have an impressive performance. From 1k to more than 500k.

 

I am forwarding a demo test and optimizing other pairs now. 

Great job and generous contribution, Ralf!

 

I wish you a very prosperous 2015! 


beginner needs help on MoneyFixedLot

$
0
0
diegocastilho:

Hi

I'm getting error during testing new strategy related to Moneyfixedlot.

Someone would be able to help me out ? I have look it up and unfortunately, I was not able to find how to fix that.

"CMoneyFixedLot :: ValidationSettings: 1.000000 to 1000000.000000"

I have tested many EA- some of them, I got this error.hence, I tried to increase the lots, remove and changed, nothing though.

Thanks in advance

sorry, I'm using MT5 .

Right time to buy EUR/USD

$
0
0
sulkani:

I am so sorry, your SL already hit.

I am waiting January low to make second order buy (averaging)

Yes, but do not worry, it is planned SL.

Problem with checking margin

$
0
0

I'm coding an EA and I have a margin check within my EA to make sure I have enough margin to enter a trade. But for some reason I always get an insufficient margin, and I have no idea what's wrong. Here is my code: 

 

//checks if we can send the order based on margin levels.
bool enoughmargin(double marginlevel, //Example: if you want at least 200% margin level enter 200. 
                  double lots,        //Lot size of the impending trade.
                  string symbol){     //symbol on which we are trading.
   if(lots==0){ return False;}               
   if(AccountEquity() *100  >= marginlevel * (MarketInfo(symbol,MODE_MARGINREQUIRED) * lots + AccountMargin())){
      return True;
   }
   return False;
}

double calculateLots(string symbol, double SL, int timeframe) {
   if (AutoLots == False) {
      return Lot;
   }
   double pipsAtRisk = MathAbs(iClose(symbol,timeframe,1)-SL) / (Point*multiplier);
   double currencyAtRiskForOneLot = pipsAtRisk * getValueOfTick(1.0) * multiplier;
   double maxAccountRisk = NormalizeDouble( (AccountEquity() * (risk / 100)), 2);
   double calculatedLots = NormalizeDouble(maxAccountRisk / currencyAtRiskForOneLot, 2);
   
   if(!enoughmargin(minlevel, calculatedLots, symbol) 
      && enoughmargin(minlevel, NormalizeDouble(calculatedLots/2,2),symbol)) {
      Print("Insufficient margin for full trade. Half position opened instead.");
      calculatedLots=NormalizeDouble(calculatedLots/2,2);
      return calculatedLots;
   }
   if(!enoughmargin(minlevel, NormalizeDouble(calculatedLots/2,2),symbol)){
      Print("Insufficient margin.");
      return -1.0;
   }
   return calculatedLots;
}

Refer to broker !

$
0
0

Dear Filter, Understand your points, but I am confused myself, so I think I should not make any complain against one member. Better, you just look over the link and decide what should you do, because you are more experienced better than me and your decision will be fair. Thanks a lot.

Link is: https://www.mql5.com/en/blogs/post/325700 

2 Moving Average Cross Alert !

$
0
0
angevoyageur:

Dear Angevoyageur, minimum 2 minutes continuing laughing to see your reply, you make a great joke and I like that. Thanks.

Anyway, very profitable indicator need to be programmed here mentioned for full programming and thats on his own logic maybe, So need to create 100% new indicator, on the other hand, my one is already working and I need to add a very simple coding to use MA shift options, that;s why submitted here to get feed back from here. Lot of traders have some basic coding knowledge and they can do it easily. And only for few words coding, why should I spend min. 10$? Let me try for free help first, if no one can, then have to knock freelance sections. Thanks a lot. 

Viewing all 75046 articles
Browse latest View live