Ask! - page 115

 
TheRumpledOne:
Is there a simpler way to find the bar number of today's high and low?

today_high = High[0];

today_low_ = Low[0];

Find the bar number for today ??? The 0 mean today. On D1 of course.

If you are on other TF:

today_high = iHigh(Symbol(),PERIOD_D1,0);

today_low = iLow(Symbol(),PERIOD_D1,0);

FerruFx

 
TheRumpledOne:
I would like to know what bar the highest high and lowest low occurred for today on H1 or less time periods.

I know I can use a for loop and check.

Is there a more elegant way to do this?

Is there a first bar of today function?

Thanks.

datetime some_time_start_day=D'0000.00.00 00:00';

datetime some_time_end_day=D'0000.00.00 00:00';

int shiftStart=iBarShift(NULL,PERIOD_M1,some_time_start_day);

int shiftEnd=iBarShift(NULL,PERIOD_M1,some_time_end_day);

double valH=High;

double valL=Low;

nothing simpler then this... ps. I thought the question was find the bars on a lower timeframe, otherwise just do what FerruFx explained take from D1

.

 

Dear codersguru,

I need ea that should be piece of cake for you,

it close all open positions (for certain pair) when 2 MA crossed.

Off course, if faster MA crossed down slower MA it close long position,

vice versa.

Variabels :

- Faster MA type

- Faster MA value

- Slower MA type

- Slower MA value

- TimeFrame (we can fixed the timeframe without being interferred

when we switching between timeframe graph windows)

I have tried to modified MA crossed EA, but always failed.

Thank you for your kindness.

 
IN10TION:
datetime some_time_start_day=D'0000.00.00 00:00';

datetime some_time_end_day=D'0000.00.00 00:00';

int shiftStart=iBarShift(NULL,PERIOD_M1,some_time_start_day);

int shiftEnd=iBarShift(NULL,PERIOD_M1,some_time_end_day);

double valH=High;

double valL=Low;

nothing simpler then this... ps. I thought the question was find the bars on a lower timeframe, otherwise just do what FerruFx explained take from D1

.

Thanks.

I guess there isn't a simpler way.

I thought there might be a keyword/reserved word for BarStartOfDay or something.

 
IN10TION:
iBarShift will find for you the bar that start on that day or also the end bar for that day.

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)

next...

use those bar positions to find the results of iHighest and iLowest

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

results & done

Here's why I wanted to know:

https://www.mql5.com/en/forum/178406/page8

 

Hi,

First off thank you in advance for you help!

I am trying to see if there is a way to use multiple threads in an expert advisor like you can in c++.

The reason is, I do news trading and I need to have several orders all send at the same time. For example, I need to place 3 orders GBP/USD, USD/CAD, EUR/USD as soon as the data comes in. Now my problem is that if I use the regular order send function 3 times, it is slow, as it sends the orders incrementally, not at the same time.

OrderSend("GBPUSD",OP_BUY,0.01,ask,5,ask-25*point,ask+25*point,"Cole",11111,0,Red);

OrderSend("USDCAD",OP_BUY,0.01,ask,5,ask-25*point,ask+25*point,"Cole",11111,0,Red);

OrderSend("EURUSD",OP_BUY,0.01,ask,5,ask-25*point,ask+25*point,"Cole",11111,0,Red);

I am sure this can be done somehow because If I open up 3 separate MT4 buy/sell windows and click them all at the same time (using a news trading program), the orders all send at the same moment and come in much faster. When you do it this way, the orders all pop up at once, as opposed to using my EA with 3 OrderSend calls, they pop up one after another.

Is there any way to setup multiple running threads in an EA, or perhaps is there some type of batch OrderSend?

Thanks!

Cole

 
ColeFlournoy:
Hi,

First off thank you in advance for you help!

I am trying to see if there is a way to use multiple threads in an expert advisor like you can in c++.

The reason is, I do news trading and I need to have several orders all send at the same time. For example, I need to place 3 orders GBP/USD, USD/CAD, EUR/USD as soon as the data comes in. Now my problem is that if I use the regular order send function 3 times, it is slow, as it sends the orders incrementally, not at the same time.

OrderSend("GBPUSD",OP_BUY,0.01,ask,5,ask-25*point,ask+25*point,"Cole",11111,0,Red);

OrderSend("USDCAD",OP_BUY,0.01,ask,5,ask-25*point,ask+25*point,"Cole",11111,0,Red);

OrderSend("EURUSD",OP_BUY,0.01,ask,5,ask-25*point,ask+25*point,"Cole",11111,0,Red);

I am sure this can be done somehow because If I open up 3 separate MT4 buy/sell windows and click them all at the same time (using a news trading program), the orders all send at the same moment and come in much faster. When you do it this way, the orders all pop up at once, as opposed to using my EA with 3 OrderSend calls, they pop up one after another.

Is there any way to setup multiple running threads in an EA, or perhaps is there some type of batch OrderSend?

Thanks!

Cole

In anyway, your platform won't send multiple orders at the exact same time.

FerruFx

 

FerruFX -- I'm not sure I understand what you are saying?

Thanks,

Cole

 
IN10TION:
Do you already have some code for this, that you started?

in a mq4 file?

the first thing you need is confirmation doji/inside = yes or no

depending on your settings it will look before the doji/inside or wait

when it waits 2 bars it has to decide the orders, depending on the previous bar high or low...

well you can start programming

you have some code to find the doji's or insiders?

...

Hi IN10TION,

Here is the code i am using (not my code) to find the inside bar.

}

int IsInsideBar(int shift) {

//Inside Bar, The close of the inside bar should be higher than both the close and the bar midpoint The current bar must open

//equal or higher than the close of the inside bar a BuyStop order is to be placed at the high of the inside bar if the order

//is not hit within the next 4 bars cancel order. See picture below

if (High[shift]>High[shift+1]) return(0);

if (Low[shift]<Low[shift+1]) return(0);

if (Close[shift]>Open[shift] && Close[shift]>(High[shift]+Low[shift])/2 && Open[shift-1]>=Close[shift]) return(1);

if (Close[shift]<Open[shift] && Close[shift]<(High[shift]+Low[shift])/2 && Open[shift-1]<=Close[shift]) return(-1);

return(false);

}

Now, my question is:

If I want to place a buy-stop and a sell-stop at the high and low of the next bar, the bar following the inside bar...what would the code be?

Thanks for the help...

forexcel

 
IN10TION:
I'm all ears, you can send me a private message or bring it in the open... if your indicators are well coded your finishing EA is not so far away.

Gidday In10tion

Attached is the pic of what I am trading.

I use these 4 indicators

Sell signal

1: Slow Stochastic K% Crossed D% over 80 and vice versa for Buy below 20

2: QQE RSI Crossed below ATR and vice versa for Buy

3: CCI Crosses below 0 and vice versa for Buy

4: MACD ma's crossed and 1 bar formed below 0 and vice versa for Buy

If any 3 of these conditions are met then open a position eg stoch fire signal 5 mins later MACD then 20min CCI fires signal = open position.

or any conbinations of the above as long as they are in the same direction as the Slope indicator.

Screen shot attached

Regards

Files:
bones.gif  54 kb
Reason: