| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
Alerts that last longer
hi i am newbie trying to understand ins and outs of this and any help will be appreciated!!
my current indicator has the following code for generating alerts, but this alert lasts for only one beep, is there any way i can make it to beep for 30 or 60 sec or atleast bit longer than 1 beep if (setalert == 1 && shift == 0) { Alert(Symbol(), " ", period, " ", pattern); setalert = 0; } Thanks |
|
|||
|
for CEHansen
Hi,
Inside that the for where you take the bars one by one you have to use i variable everywhere instead of Current. Current is uninitialised so it's 0. The easyest way to see that is put inside the for at the begining this: Current = i; The arrows will appear. Also don't forget to use a bigger value for Sto_Lookback. Mabe 100,1000 or something like that. P.S Use to make the for like this it is better from my point of view. for (int i = Sto_Lookback; i >0; i--){ ... } Because this is the normal way of "bars" comming 0 is the last one. It would save you of some other trubles later. (for example - repainting). Just a thought. Thanks, Victor |
|
|||
|
Thanks Victor!
I got the arrows to show by doing what you suggested. Turned out the indicator is not really doing what I intended it to do, LOL! Hereīs what I want "i" to be: take these lines as an example... //short stochastics value at "i" double sto_short = iStochastic(NULL, 0, 8, 3, 3, MODE_SMA, 0, MODE_MAIN, i); //long stochastics value at "i" double sto_long = iStochastic(NULL, 0, 36, 3, 3, MODE_SMA, 0, MODE_MAIN, i); //if short stochastics move up... and both short and long stochastics //have both been below 25 anywhere within the last "i" bars then stochup is true if (sto_short_now > sto_short_pre && sto_short <= 25 && sto_long <= 25) {stochup = true;} My intend: if sto_short and sto_long have both been <= 25 at one of the last (sto_lookback) bars... then stochup is true... thatīs what I wrote the "for" loop for... which I obviously screwed up big time, LOL... I donīt really have a clue how to get this done... Thanks again, CEH |
|
|||
|
Order Modify Error 1
On my backtesting I keep getting the occasional "OrderModify error1". From what I can figure it means that there is no change, i.e. OrderModify() arguments are the same that corresponding parameters of the modified order.
This might be due to double comparison issue. Question is how might I solve this issue? Here's the area I believe is causing the problem: if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //MoveOnce if(MoveStopOnce && MoveStopWhenPrice > 0) { if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) { if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) { OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red); if (!EachTickMode) BarCount = Bars; continue; } } } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; continue; } } } } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //MoveOnce if(MoveStopOnce && MoveStopWhenPrice > 0) { if(OrderOpenPrice() - Ask >= Point * MoveStopWhenPrice) { if(OrderStopLoss() > OrderOpenPrice() - Point * MoveStopTo) { OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red); if (!EachTickMode) BarCount = Bars; continue; } } } //Trailing stop if(UseTrailingStop && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; continue; } } } } } } |
|
|||
|
Quote:
For example in Visual Basic you would have to write. i = i + 1 to increment the i variable. however, in C you can simply write i++. Hope this helps. Hiachiever |
|
||||
|
Quote:
so if I put if (int i=6; i>0; i++) it will 'loop' or keep checking value until 6 max? not sure if that is right. What if I use i--? Please clarify |
|
|||
|
Quote:
if you want to start at 6 and go back to 0 then use i-- (int i=6; i>0; i--) This will start at 6, decrement by 1 on each loop for as long as I > 0. If you want to include 0 then use i>=0. Cheers, Hiachiever |
![]() |
| Bookmarks |
| Tags |
| candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
|
||||
| Posted By | For | Type | Date | |
| Need an experienced programmer? - Page 2 | Post #0 | Refback | 09-24-2008 07:24 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 05:22 PM |