You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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 ??
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);
Print("qqea_up: ", qqea_up, "qqea_down: ", qqea_down);
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 ??At face value your code looks alright, that is assuming "qqea_alert_x_candles_ago" > 0.
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?
At face value your code looks alright, that is assuming "qqea_alert_x_candles_ago" > 0.
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,
HiachieverThe code is from another EA but I was thinking that when the loop goes to "qqea_alert_x_candles_ago" > 1 then this statement "if (i == 1) qqeacross = True;" would be False now, correct? When it should stay True until i>qqea_alert_x_candles_ago.
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 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;
The code is from another EA but I was thinking that when the loop goes to "qqea_alert_x_candles_ago" > 1 then this statement "if (i == 1) qqeacross = True;" would be False now, correct? When it should stay True until i>qqea_alert_x_candles_ago.
No that isn't correct.
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
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?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
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;Well what I did was open up or display the other two buffers in the indicator code by rem'ing out these two lines;
// SetIndexLabel(1,NULL);
// SetIndexLabel(2,NULL);
Then with my modified AC did an iCustom call;
double ac1 = iCustom(NULL, 0, "AcceleratorMod", 1, 1);
double ac2 = iCustom(NULL, 0, "AcceleratorMod", 2, 1);
double ac11 = iCustom(NULL, 0, "AcceleratorMod", 1, 2);
double ac22 = iCustom(NULL, 0, "AcceleratorMod", 2, 2);
bool acbuy = ac2==0 && ac11==0; // Red changes to Green
bool acsell = ac1==0 && ac22==0; // Green changes to Red
Hope that helps
matrixebiz what do you mean by rem'ing out these two lines; and how do i do it, i can;t get in to the code of the AC indicator i have tried,