MQL4 Learning - page 78

 
MANSTIR:
i'm sorry sir,

the code iclose price is moving, i'm want some fix closed price on specific time only..

I'm sorry as well, but it's working. I put on my chart:

datetime some_time=StrToTime("02:10");

int shift=iBarShift(Symbol(),PERIOD_H1,some_time);

Print("close price of the bar with open time ",TimeToStr(some_time,TIME_DATE|TIME_MINUTES)," is ",Close[shift]," shift - ",shift," time - ",some_time); }[/CODE]

and in my logs I see:

[CODE]2009.07.31 09:15:48 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:48 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:47 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:46 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:45 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200
 
MANSTIR:
i'm sorry sir,

the code iclose price is moving, i'm want some fix closed price on specific time only..

after compile...

the iClose[shift]; - '[' - left parenthesis expected & '[' - unexpected token

if i put the code like this - d13 = iClose(NULL,PERIOD_H1,shift);

its no errors.. but the closed price is moving

pleaase help me... i'm out of my mind

regards,

MANSTIR

see picture below

You're using iClose the function improperly. It should be Close[shift] the array.

Lux

 
Roger09:
I'm sorry as well, but it's working. I put on my chart:
datetime some_time=StrToTime("02:10");

int shift=iBarShift(Symbol(),PERIOD_H1,some_time);

Print("close price of the bar with open time ",TimeToStr(some_time,TIME_DATE|TIME_MINUTES)," is ",Close[shift]," shift - ",shift," time - ",some_time); }[/CODE]

and in my logs I see:

[CODE]2009.07.31 09:15:48 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:48 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:47 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:46 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200

2009.07.31 09:15:45 Test EURUSD,H1: close price of the bar with open time 2009.07.31 02:10 is 1.409 shift - 16 time - 1249006200
luxinterior:
You're using iClose the function improperly. It should be Close[shift] the array. Lux

sir Roger09 & luxinterior,

thanks for your codes, excellent ... i try to run the indicator on Monday morning.. really appreciate your help.. really2 help me out

If successful i will share my indicator to u..

regards,

MANSTIR

 

digits

I am looking for a way to just isolate the last digit in a pricing code. I would like to modify the last digit to be a different color. I know I have to go through the object function and can I can change the entire group of digits color. But I am looking to keep the first four numbers one color and the last a different color. I was thinking maybe making digits x.xxx1, will x not allow the first digits to show?? if so then I could just make a second group of price digits -1 and then xy to appear together.

Thanks for any help

 

Use the DoubleToStr function then the StringSubstr and then convert it back to a double with the StrToDouble. Look in the help file for information about each fucntion.

Lux

 

3 Coding questions.

Greetings,

I am working on my first EA and I am using 3 nolag MA's (donchians in meta4 arent working the way I want them too) and a MACD for indicators on top of a bar counting system. The problem I am having is that: no matter what I do, or what conditions I set, it is buying on the last peak. Obviously, this is bad. If it wasn't for this meer fact, I would be back testing for 90%+ wins. Right now I'm stuck at around 75-80% wins.

Hence, I am trying to do the following:

A) make an internal toggle conditional "buymode" and "sellmode" based off MACD indicators like so:

if(MacdCurrentSignalCurrent && MacdPrevious(MACDOpenLevel*Point) && MaCurrent<MaPrevious) BuyMode = True;

if(MacdCurrentSignalCurrent && MacdPrevious(MACDOpenLevel*Point) && MaCurrent<MaPrevious) SellMode = false;

Obviously, the toggle is there but I am having issue's linking it to even simple code such as

If (BuyMode = True) && (Close[0] > Open [0]) Order = SIGNAL_BUY;

Is there a way to link the conditional Buy mode to query the buy conditions only after the toggle has been met from that point foward until the condition is set to false? Can someone snippet a conditional for me?

B) I'm trying to make a "SuperPip" function.

At the moment a simple buy if the bar closes higher than it opened works fine... other than that last trade at peak that is...

Yet, I have 250,000 of them on an uptrend and just as many on a down trend. Therefore, it donned on me.. "Ok Trailing Stops don't work in the first place, they raise your stop loss, yes good, but then sell when it hits sl or it never seems to do more than "break even", aka I'm paying the bank to play. Not good. Statistically, its just another way to pay the bank.

So why not an increasing take profit routine?

Working with trailing stop code I came up with:

}

//SuperPip

if(UseSuperPip && SuperPip > 0)

{

if((OrderOpenPrice() + Ask) > (SuperPip * 0.50 + SuperPip))

{

if((OrderTakeProfit() < (SuperPip * 0.50 + SuperPip)) || (OrderTakeProfit() == 0))

{

OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * SuperPip, OrderTakeProfit(), 0, DarkOrange);

if (!EachTickMode) BarCount = Bars;

continue;

}

Apparently neither of these work and I need some help. It seems that in test my indicators are completely different than Live in the first place and I'm finding my self struggling with filters to draw the same conclusions in both... hopefully not in vein.

Point is:

If I'm in a good trade, why do I want to get out of it and end up in a bad one?

I could really use some help with my code.

Thank You,

GrStaKa

PS: Why are my indicators loading every 3 seconds? Is this normal ?

 

Help Required

I am hoping someone could shed some light on my first code piece, everything else is workin OK but this, I would like to have arrows drawn on my chart when certain conditions are met.

Here is the code but I am certain there's a lot more to it

I am looking at when the value of symbol 1 is below 15 and the RSI (8) is below 30 draw an UP Arrow

if (sym_1 < 15) and (RSIBuffer[0] < 30 ) Draw_Arrow

Hoping someone can help

Regards

Kipper

 

Why not do like most other people do? Take a look at the code of your favorite indicator that draws arrows like you want to do and figure out what the codes doing and then adapt it to your own needs.

It's the easiest way to learn and as I say, it's what pretty much everybody else does.

Good luck

Lux

 

powerswing

arrow appear late, please fix it

Files:
 

image

zzzzzzzzzzzz