| 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 |
|
|||
|
Quote:
The the code in this case would be For (int i=1; i<=6; i++) This will start at 1 and finish at 6 incrementing by 1 on each loop. Cheers, Hiachiever Last edited by hiachiever; 08-22-2008 at 05:55 AM. |
|
||||
|
I'm trying to figure out if this is wrong;
for (int i=qqea_alert_x_candles_ago; i>0; i--) { // int i = 1; qqea_up = iCustom(NULL,0,"QQE Alert v3",0,i); qqea_down = iCustom(NULL,0,"QQE Alert v3",1,i); if (qqea_up < qqea_down) { if (i == 1) qqeacross = True; qqea_long = True; qqea_short = False; } else if (qqea_up > qqea_down) { if (i == 1) qqeacross = True; qqea_long = False; qqea_short = True; } } } it should check for valid signal upto "qqea_alert_x_candles_ago" bars back, but then it has (i == 1) which i==1 only happens once ?? |
|
|||
|
Quote:
Your problem if this is not working is more than likley in relation to iCustom. For this function to work correctly you need to pass an input element for every input element in the actual indicator. If you don't do this, or pass the wrong data types then icustom will return nothing. I have added a Print statement into the code above. Use this to determine if the values returned from iCustom actually contain anything. Cheers, Hiachiever |
|
|||
|
Help needed with code to count bars
My EA has a number of options to calculate the stoploss of an open position. One of those options is to use the low of last "x" number of price bars.
The line of code currently used within the EA to calculate the stoploss (SL) of this option for a long position is: SL=iLow(Symbol(),Period(),iLowest(Symbol(),Period( ),MODE_LOW,StopLossBars,0)); StopLossBars is an externally input variable. The problem I have is that I want the value of StopLossBars to increase with every bar counted since the position was opened until one of my other conditions for stoploss over rides this condition. I guess a line of code such as: StopLossBars = StopLossBars + BarsCountedSincePositionOpened would do the trick. Unfortunately my coding is pretty limited to cut'n'paste and I don't know how to calculate or code BarsCountedSincePositionOpened. Could somebody tell me how to do it please? |
|
||||
|
Quote:
|
|
|||
|
Helping
Dear all,
I got this coding from a colleague. He told me, that should be a very good Indicator signaling SMA up or down entries. Can somebody help me to create an indicator with this coding below. /*[[ Name := SMA Up and Down Separate Window := no First Color := Blue First Draw Type := Line Use Second Data := Yes Second Color := Red Second Draw Type := Line ]]*/ Inputs : MAPeriod(10), Bandwide_UP(20),Bandwide_DOWN(20); Variables : shift(0), cnt(0), sum(0), loopbegin1(0), loopbegin2(0), first(True), prevbars(0); Variables : MA(0); SetLoopCount(0); // initial checkings If MAPeriod < 1 Then Exit; // check for additional bars loading or total reloading If Bars < prevbars Or Bars-prevbars>1 Then first = True; prevbars = Bars; // loopbegin1 and loopbegin2 prevent couning of counted bars exclude current If first Then Begin loopbegin1 = Bars-MAPeriod-1; If loopbegin1 < 0 Then Exit; // not enough bars for counting loopbegin2 = Bars-MAPeriod-1; If loopbegin2 < 0 Then Exit; // not enough bars for counting first = False; // this block is to be evaluated once only End; // convergence-divergence loopbegin1 = loopbegin1+1; // current bar is to be recounted too For shift = loopbegin1 Downto 0 Begin MA = iMA(MAPeriod,MODE_SMA,shift); SetIndexValue(shift,(MA+Bandwide_UP*point)); SetIndexValue2(shift,(MA-Bandwide_DOWN*point)); loopbegin1 = loopbegin1-1; // prevent to previous bars recounting End; Best regards, Rogerio |
|
|||
|
help needed with code
i need help with the following code at the moment it only opens a order if AC is above or below zero and i want it to open if red changes to green and visa verser
double AC1 = iAC(NULL, 0, Current + 0); double AC2 = iAC(NULL, 0, Current + 1); if ((AC1 < AC2)) Order = SIGNAL_CLOSEBUY; |
|
|||
|
Quote:
In the for loop you are starting at 6 and decrementing to 1. This means in the final loop the for loop executes it carries out the "if (i == 1) qqeacross = True;" check. End result is that the output will be true if qqeacross has occurred. The only problem that this may present is if qqeacross was set to true in a previous looop. To overcome this you should have qqeacross = false; prior to the for loop. In this way you can ensure that if qqeacross = true, then it was set by the loop just completed. Cheers, hiachiever |
|
|||
|
Quote:
The way to do it is create a vriable on global scope (ie before init) eg int BarCount; int init () Then in your stop loss code use the following: if (BarCount<Bars) { SL=iLow(Symbol(),Period(),iLowest(Symbol(),Period( ),MODE_LOW,StopLossBars,0)); StopLossBars++; BarCount=Bars; } This will increment StopLossBars by 1 on each new bar. The only other addition to your code would be to reset 'StopLossBars' back its original default value when a new trade is opened. 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 |