How to code? - page 35

 

Fast order creation

I'm monitoring several charts and when I see a good trade entry point I'd like to create an order as quickly as possible without using the dialog box. What would you suggest?

Thanks in advance,

Ed

 

Is it possible , two EA in the same time?

Hi evrerybody

Is it possible to make working my two EA?

- in the same time

- in the same Timeframe (ex : 1 minute)

- and with the same Currency Pair (ex :EUR/USD)

I've change the MagicNumber (EA_1 = 10 ; EA_2 = 20) but they're working one after another even if, the conditons for a trade are good for each .

Help me please.

Thanks!

Files:
ea_1.mq4  10 kb
ea_2.mq4  10 kb
 
ralph.ronnquist:
Hmm; I didn't trial your EA, but by reading the logic, it looks to me like the only thing stopping a subsequent Sell after a Buy is that "IsTrade" is true. (Except that it won't open a Sell at the very same time as it opens a Buy)

So if you want the Sell logic to apply unconditionally, I would have thought that my edit (1) only -- forget 2-4 -- would do the trick. Or remove the "IsTrade" logic.

Though, there's the subordinate logic with "TickCheck" and "BarCount", which stops another trade at the same tick or at the same bar, but I assume you want that to apply still.

Of course I can't say much about the signaling part, which you omitted. E.g., if raising a "Sell_Signal" takes account of "BuyOrders", then there's more to do.

Hello,

Thanks again for your time. Just for your info, I resolved the issue. Your suggested modification was the first step in the right direction. It needed on additional modification (in bold type) as follows:

if (Buy_Signal && BuyOrders < Max_Buys&& BuyOrders==0) Order = SIGNAL_BUY;

if (Sell_Signal && SellOrders < Max_Sells && SellOrders==0) Order = SIGNAL_SELL;

Thanks again. Perhaps, if you don't mind you could help me with one other question. I would like to add the EA to have the flexibility to close any open order after X number of days, where X is adjustable in the expert setup dialog. So, say a buy trade opens on a certain date and time, be able to close the trade three days later at the same time of day?

Any ideas or suggestions is appreciated.

 

You might put this code after the "BuyOrders++;" line:

if ( TimeCurrent() - OrderOpenTime() >= 86400 * MaxTradePeriodInDays )

Order = SIGNAL_CLOSEBUY;

and similar for the sell orders.

Doesn't do weekends well, though.

 

Indicator with this code:

Hi my Dears,

I want 2 indicators in MT4 with these code below: (with arrow signal buy/sell on the chart)

Number 1:

----------

MA1 = SMA(5,Close), MA2 = SMA(10,Close), MACD(12,26,9)

To signal a long trade: MA1 > MA2, RSI(14) > 50, and MACD Fast > MACD Signal

To signal a short trade: MA1 < MA2, RSI(14) < 50, and MACD Fast < MACD Signal.

----------

Number 2:

----------

F1 is Fractal Up Level and F2 is Fractal Down Level in the code below

UpTrend and DownTrend(Description):

F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND Ref(H,-3)<Ref(H,-2) AND Ref(H,-4)<Ref(H,-2),Ref(H,-2));

F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));

a:=Cross(H,F1);

b:=Cross(F2,L);

state:=BarsSince(a)<BarsSince(b);

{Signal Long and Short}

LongSignal:= state<Ref(state,-1);

ShortSignal:=state>Ref(state,-1);

{Trend Up and Down}

UpTrend:=state>0;

DownTrend:=state<1;

---------------------------------------

Thanks and Best Regards,

Khamoosh

 

Hours and Hours!!!!!!!

I really need help!

I do not get this at all!!!!!!!!!

I tried Mql4.com, F1 while selecting the word,everything!

I do not get it!!!!!!

What does

IndicatorCounted()[/PHP]mean?????????

What does

Bars

mean??????????????

What is [PHP]Bars-IndicatorCounted()

mean????????????

 

You need what kind of help ? Indicators.." You can get some here..what you need now is to learn and practice,,he..he...he..

 
Dan7974:
I really need help!

I do not get this at all!!!!!!!!!

I tried Mql4.com, F1 while selecting the word,everything!

I do not get it!!!!!!

What does

IndicatorCounted()[/PHP]mean?????????

What does

Bars

mean??????????????

What is [PHP]Bars-IndicatorCounted()
mean????????????

int IndicatorCounted( )

The function returns the amount of bars not changed after the indicator had been launched last. The most calculated bars do not need any recalculation. In most cases, same count of index values do not need for recalculation. The function is used to optimize calculating.

Note: The latest bar is not considered to be calculated and, in the most cases, it is necessary to recalculate only this bar. However, there occur some boundary cases where custom indicator is called from the expert at the first tick of the new bar. It is possible that the last tick of the previous bar had not been processed (because the last-but-one tick was being processed when this last tick came), the custom indicator was not called and it was not calculated because of this. To avoid indicator calculation errors in such situations, the IndicatorCounted() function returns the count of bars minus one.

Sample:

int start()

{

int limit;

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- the last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- main loop

for(int i=0; i<limit; i++)

{

//---- ma_shift set to 0 because SetIndexShift called abowe

ExtBlueBuffer=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtRedBuffer=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtLimeBuffer=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);

}

//---- done

return(0);

}

 
natsirte:
Hi evrerybody

Is it possible to make working my two EA?

- in the same time

- in the same Timeframe (ex : 1 minute)

- and with the same Currency Pair (ex :EUR/USD)

I've change the MagicNumber (EA_1 = 10 ; EA_2 = 20) but they're working one after another even if, the conditons for a trade are good for each .

Help me please.

Thanks!

Replace the line :

if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {[/PHP] by this one : [PHP]if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
 

Fire code immediately after 15 minute bar finishes

I have a trailing stop, it up dates every tick during a 15 min bar, and the stop is calculated 20 pip from BID price.

But I would prefer that the trailing stop calculates at the end of the of the most recent 15 minute bar.

So this would this be on a BUY

if( BID > High[1] - (20 * Point)) StopLoss = High[1] - (20 * Point);

So this is to allow the current 15 minute bar to whipsaw around as much as it likes, before stops are moved.

Is this the idea, or are there others out there ?? Thx