Detect Last Candle Close Price ---> pending buy + X pips above/below
well, let's get started
Ok, this is what I have, opened a new Script:
//+------------------------------------------------------------------+ //| PO for last close price.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "https://forum.mql4.com/50686" //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- //---- return(0); } //+------------------------------------------------------------------+
Now I need to know the command to open a pending buy order right? I think it is OP_BUYSTOP, but I don't know where to place it. Man, that's complicated ;)
iClose[1]?
Thanks for the code, i tried implementing it in another code, giving the error: "left parenthesis expected".
My head is hurting, i need a break here.... ): Thanks for the reply though
smoknfx:
Thanks for the code, i tried implementing it in another code, giving the error: "left parenthesis expected".
My head is hurting, i need a break here.... ): Thanks for the reply though
CORRECT.
i did a typo.
notice my edited post.
syntax:
double price;
price=iClose(Symbol(),0,1);
Thanks smoknfx! I got your code working a bit, i will continue working on the whole thing tomorrow.
that is. 1 means 1 previous candle right? so if it were 3 it would look 3 candles back. awesome. (And the 0 means? not that important, just curious :D)
johnny,
0=current bar (first bar)
1=one bar back in time(second bar, actually)
2=two bars back in time(third bar)
good luck.
Thanks smoknfx! I got your code working a bit, i will continue working on the whole thing tomorrow.
that is. 1 means 1 previous candle right? so if it were 3 it would look 3 candles back. awesome. (And the 0 means? not that important, just curious :D)
After some hours now i got it working :) Now it gets more complicated, because my "buy stop" i want to put above the candle gets "swapped prices" on a bearish candle (because the open price is above the close price)
Is there a way we can check if the last candle was bearish or bullish?
And then if the last candle was bearish, swap
iClose(Symbol(),0,1);
with
iOpen(Symbol(),0,1);
You probably write is like that: if the candle was bearish, use this code .......
and then below that: else use this normal code ........
Somebody can help how to check that, check if the candle was bearish and then use a different code?
Hello,
(I have searched everywhere already, found many people who have the same question but received no answer. I tried hours to code it myself, i have very bad programming skills.)
What I need is a script which opens a pending buy order, X pips above the last candle's close price.
(additionally, put StopLoss X pips below the open price)
Example: Pending Distance is set to 12 pips. SL is set to 20 pips. Last candle close price is 1.2236. When i run the script (press the hotkey for it) it then puts a buy stop at 1.2248, and SL at 12216.
The rest i will try to edit and change for myself, I would thank you very very much if you could tell me how to write this basic code.
Thanks to any programmer who can help me, you are the best!
-johnny