I am new to MQL I am trying to calculate average low for a given timeframe, I know how to do it in TradeScript but not sure about MQL.
TradeScript: (Ref(Low,14)) - would give the 14 day average low
I tried it but the result I was getting vs the TradeScript on the other platform was night and day different.
On a side note when I run my expert in MT4 (back testing) I get good results except at the end date which I take a huge negative is that normal?
22 trades of $120+ each over a year span then -$4747 at close of dates
I tried it but the result I was getting vs the TradeScript on the other platform was night and day different.
That may make sense to you, it makes no sense to me.
On a side note when I run my expert in MT4 (back testing) I get good results except at the end date which I take a huge negative is that normal?
22 trades of $120+ each over a year span then -$4747 at close of dates
Trades are being closed with profit which looks good.
You have a lot of losing open floating trades that are only closed at the end of the test which reveals the truth.
Tony Chavez: I tried it but
|
|
{
//---
HighV = iMA(NULL,0,PERIOD_W1,0,MODE_EMA,5,0)+0.0015;
MqlTick LastTick;if(SymbolInfoTick(Symbol(),LastTick))
{
double BuyPrice = LastTick.bid + 0.005;
double SellPrice = LastTick.ask + 0.005;
}
if(LastTick.ask > HighV) {
if(OrdersTotal() < 5)
OrderSend(Symbol(),OP_SELL,2,Bid,3,0,Bid-0.090,NULL,756,0,Green); }
}
//------------------------- Above MT4 & Below TradeScript
( LAST < REF(LOW, 14) ) //-------------Buy Command
( LAST > REF(LOW, 5)+.0015) //------------- Sell Command
MT4 Results
Symbol | USDJPYpro (US Dollar vs Japanese Yen) | ||||
Period | Daily (D1) 2016.12.01 00:00 - 2017.01.05 00:00 (2016.12.01 - 2017.01.06) | ||||
Model | Every tick (the most precise method based on all available least timeframes) | ||||
Bars in test | 1032 | Ticks modelled | 1507510 | Modelling quality | 90.00% |
Mismatched charts errors | 0 | ||||
Initial deposit | 10000.00 | Spread | Current (81) | ||
Total net profit | -2002.96 | Gross profit | 1420.34 | Gross loss | -3423.29 |
Profit factor | 0.41 | Expected payoff | -200.30 | ||
Absolute drawdown | 2002.96 | Maximal drawdown | 3570.27 (30.87%) | Relative drawdown | 30.87% (3570.27) |
Total trades | 10 | Short positions (won %) | 10 (90.00%) | Long positions (won %) | 0 (0.00%) |
Profit trades (% of total) | 9 (90.00%) | Loss trades (% of total) | 1 (10.00%) | ||
Largest | profit trade | 159.15 | loss trade | -3423.29 | |
Average | profit trade | 157.82 | loss trade | -3423.29 | |
Maximum | consecutive wins (profit in money) | 9 (1420.34) | consecutive losses (loss in money) | 1 (-3423.29) | |
Maximal | consecutive profit (count of wins) | 1420.34 (9) | consecutive loss (count of losses) | -3423.29 (1) | |
Average | consecutive wins | 9 | consecutive losses | 1 |
TradeScript Results
-
Play videoPlease edit your post.
For large amounts of code, attach it - Perhaps you should read the manual.
"TradeScript: (Ref(Low,14))" Doesn't use a 10080 for the period, it uses 14.Your code Documentation HighV = iMA(
NULL,
0,
PERIOD_W1,
0,
MODE_EMA,
5,
0
)double iMA(
string symbol, // symbol
int timeframe, // timeframe
int ma_period, // MA averaging period
int ma_shift, // MA shift
int ma_method, // averaging method
int applied_price, // applied price
int shift // shift
);
Don't know EMA vs SMA.
"TradeScript: (Ref(Low,14))" uses the Low of each bar, not Typical price, (high + low + close)/3
Correct, but "PERIOD_W1" is One Week expressed in Minutes, namely 10080. So how is 10080 the same as 14?
Even if I try to follow your "logic" how could "One Week" be the same as 14 days?
If TradeScript is new to you, then stop comparing them. Learn MQL from scratch and and learn it as if you had never heard of TradeScript before.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am new to MQL I am trying to calculate average low for a given timeframe, I know how to do it in TradeScript but not sure about MQL.
TradeScript: (Ref(Low,14)) - would give the 14 day average low