d1_9_v1
I stop reading.
As soon as I see non descriptive variable names such as
I stop reading.
That's not the point the name of the variable :)
//+------------------------------------------------------------------+ //| time-frame01.mq4 | //| helmy gabriel | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "helmy gabriel" #property link "https://www.mql5.com" #property version "1.00" #property strict int i; int ticket; int closeticket; int select; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { /////////////////////////////////////////////////////////////////// MAS D1 double mads1 =iMA(NULL,PERIOD_D1,9,0,MODE_SMA,PRICE_CLOSE,1);//small double mads2 =iMA(NULL,PERIOD_D1,9,0,MODE_SMA,PRICE_CLOSE,2); double madm1 =iMA(NULL,PERIOD_D1,21,0,MODE_SMA,PRICE_CLOSE,1);//main double madm2 =iMA(NULL,PERIOD_D1,21,0,MODE_SMA,PRICE_CLOSE,2); /////////////////////////////////////////////////////////////////// MAS H4 double mahs1 =iMA(NULL,PERIOD_H4,9,0,MODE_SMA,PRICE_CLOSE,1);//Small double mahs2 =iMA(NULL,PERIOD_H4,9,0,MODE_SMA,PRICE_CLOSE,2); double mahm1 =iMA(NULL,PERIOD_H4,21,0,MODE_SMA,PRICE_CLOSE,1);//Main double mahm2 =iMA(NULL,PERIOD_H4,21,0,MODE_SMA,PRICE_CLOSE,2); ////////////////SELL if(mads2>madm2 && madm1>mads1 &&mahm1>mahs1) { ticket= OrderSend(Symbol(),OP_SELL,0,Bid,3,0,0,NULL,0,0,Red); } for(i=0;i<OrdersTotal();i++) { select= OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_SELL &&OrderSymbol()==Symbol()) if(madm2>mads2&&madm1<mads1) { closeticket=OrderClose(OrderTicket(),OrderLots(),Ask,3,Red); } } } //+------------------------------------------------------------------+
That's not the point the name of the variable :)
Ok, here's the thing, Moving Averages have different values on different time frames. Here's the picture that shows values from your EMA's indicators.
So, you can see how different they are. Now what you are doing is something like this:
if(1834.40 > 1842.93 && 1841.15 > 1841.36 && 1831.35 > 1835.06) { ticket= OrderSend(Symbol(),OP_SELL,0,Bid,3,0,0,NULL,0,0,Red); }
You can see that even first two prices are way different. how can 1834.40 be more than 1842.93? You are calculating it very wrong. And also I don't understand why you are selling when EMA's are going up?
Here's more example.
Above is D1 Time Frame - red line is SMA(9) and Orange line is SMA(21) and below picture shows H4 Time Frame. Now you can see that SMA(21) crossed SMA(9) on Daily chart while on H4 still continues down trend.
Ok, here's the thing, Moving Averages have different values on different time frames. Here's the picture that shows values from your EMA's indicators.
So, you can see how different they are. No what you are doing is something like this:
You can see that even first two prices way different. how can 1834.40 be more than 1842.93? And also I don't understand why you are selling when EMA's are going up?
hey, mr-roma that cleared some issues for me thank you.
so maybe I do functions of different timeframes to avoid this problem or you have a better idea ?
don't mind my EA it just a sample its not practical I wanted to calculate two different timeframes and use it later whatever reason.
so lets say I wanted to check if the two MA crossed in dally chart then sell or buy at the next cross in the 4H chart.
this is what I mean by using two different timeframes.
hey, mr-roma that cleared some issues for me thank you.
so maybe I do functions of different timeframes to avoid this problem or you have a better idea ?
don't mind my EA it just a sample its not practical I wanted to calculate two different timeframes and use it later whatever reason.
so lets say I wanted to check if the two MA crossed in dally chart then sell or buy at the next cross in the 4H chart.
this is what I mean by using two different timeframes.
Place this two SMA's on chart and you will see how really different they are on different time frames. when SMA(9) crossed SMA(21) on M15 time frame, it took almost 4 hours for them to cross on M30 time frame
Place this two SMA's on chart and you will see how really different they are on different time frames. when SMA(9) crossed SMA(21) on M15 time frame, it took almost 4 hours for them to cross on M30 time frame
I know they are different that's why I wanted to know how to calculate them on a different timeframe.
I think you don't get my point .
there are many reasons, one of them maybe to see how strong the trend is on the bigger timeframe then use the small timeframe to trade!
its very useful information to have .
void OnTick() { /////////////////////////////////////////////////////////////////// MAS D1 double d1_9_v1 =iMA(NULL,PERIOD_D1,9,0,MODE_SMA,PRICE_CLOSE,1);//small double d1_9_v2 =iMA(NULL,PERIOD_D1,9,0,MODE_SMA,PRICE_CLOSE,2); double d1_21_v1 =iMA(NULL,PERIOD_D1,21,0,MODE_SMA,PRICE_CLOSE,1);//main double d1_21_v2 =iMA(NULL,PERIOD_D1,21,0,MODE_SMA,PRICE_CLOSE,2); /////////////////////////////////////////////////////////////////// MAS H4 double h4_9_v1 =iMA(NULL,PERIOD_H4,9,0,MODE_SMA,PRICE_CLOSE,1);//Small double h4_9_v2 =iMA(NULL,PERIOD_H4,9,0,MODE_SMA,PRICE_CLOSE,2); double h4_21_v1 =iMA(NULL,PERIOD_H4,21,0,MODE_SMA,PRICE_CLOSE,1);//Main double h4_21_v2 =iMA(NULL,PERIOD_H4,21,0,MODE_SMA,PRICE_CLOSE,2);
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20
hi, sorry I'm not following you so correct me if I'm wrong I can't calculate different timeframes or symbols unless I download the history of each timeframe (or symbol lets do timeframe for now) ?
and if I get it right (lets say I did download the history), I can use my code above ?
hi, sorry I'm not following you so correct me if I'm wrong I can't calculate different timeframes or symbols unless I download the history of each timeframe (or symbol lets do timeframe for now) ?
and if I get it right (lets say I did download the history), I can use my code above ?
so anyone knows how to calculate two timeframes ?
I have this function maybe I can use it to do it, I can create another function for the 4H timeframe then use both in my code so if anyone like to share his(her) opinion he is welcome to do so.
thank you
double mad[100],madclose[100]; int kd,limitmad=ArraySize(mad); //--- get ma for(kd=0; kd<limitmad; kd++) { mad[kd]=iMA(NULL,PERIOD_D1,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,kd); madclose[kd]=iMA(NULL,PERIOD_D1,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,kd); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I'd like to open a discussion about multiple timeframe so I created this sample code and it suppose to read data from two different timeframes and act depends on the results that given to it but it doesn't work any idea why ?
Thank You.