How to code? - page 57

 
nondisclosure007:
I'm trying to figure out what is wrong here. I wrote this little indicator as to try and find out why I can't seem to draw arrows on every single bar in a chart. No good reason to.

I have another indicator that i'm working on that'll be discreet on choosing which one, i wrote this to try and figure out what the darn problem is.

It only draws an arrow on the bottom of the candle for the last few bars. It should draw arrown on every single bar in the chart on the top and bottom of each candle.

And only 1 candle's data is showing up in the data windows.

I've included a pic and the indicator. any help would be appreciated.

You have to declare the two buffers : #property indicator_buffers 2

 
Michel:
You have to declare the two buffers : #property indicator_buffers 2

wow. can't believe i missed that.

now they're showing up on every candle. i've even put in a simple compare to an ima to see if i can dictate which one. that works too. now all i have to do is look at my original indicator that's giving me the problem and compare the 2.

thanks!

 
ralph.ronnquist:
Are you sure? Have you "compressed" the price scale to make sure it doesn't draw outside the current window?

you were right. they were there, just waaaaay off. i changed the formula of where to put the arrow. now they all show up.

 

MACD stoploss

I want to stoploss on MACD.

I have this code :

double Mach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,TradeBar);

double vMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,TradeBar+1);

double vvMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,TradeBar+2);

GlobalVariableSet("mt_Vager1"+Symbol()+Period(),mtr);

GlobalVariableSet("l_Vager1"+Symbol()+Period(),TP_SL_Inc);

if (TotalOrders(Magic_Number)>0){

bool g=false;

while (!g){

g=true;

for (int kli=OrdersTotal()-1;kli>=0;kli--){

OrderSelect(kli,SELECT_BY_POS);

if

(OrderMagicNumber()==Magic_Number && OrderType()==OP_BUY && Mach<vMach && vMach<vvMach)

{

OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slippage,Pink);

g=false;

break;

}

if (OrderMag

icNumber()==Magic_Number && OrderType()==OP_SELL && m1>m2 && m11<=m21)

(OrderMagicNumber()==Magic_Number && OrderType()==OP_SELL && Mach>vMach && vMach>vvMach)

{

OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slippage,Pink);

g=false;

break;

}

}

}

}

Open works but not stoploss exit.

Thanks for help.

Jo

 

MACD stoploss

Read TradeBar

 

I thought I could limit the number of alerts triggered by trigger using this:

if(trigger == 1)

{

int StartWaitingTime = GetTickCount();

if(GetTickCount() - StartWaitingTime > MaxWaiting_sec * 1000)

{

if(ShowAlert == true) {

Alert("Buy...........

But it does not seem to work, please help to modify it so it works, thanks!

 
nondisclosure007:
you were right. they were there, just waaaaay off. i changed the formula of where to put the arrow. now they all show up.

You also need to reset the avgRange to 0 before the loop.

avgRange = 0;

for (counter=i ;counter<=i+9;counter++)

{

avgRange=avgRange+MathAbs(High[counter]-Low[counter]);

}

Robert

 

You have an extra line in red that might cause a problem.

Robert

Jovager:
I want to stoploss on MACD.

I have this code :

double Mach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,TradeBar);

double vMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,TradeBar+1);

double vvMach=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,TradeBar+2);

GlobalVariableSet("mt_Vager1"+Symbol()+Period(),mtr);

GlobalVariableSet("l_Vager1"+Symbol()+Period(),TP_SL_Inc);

if (TotalOrders(Magic_Number)>0){

bool g=false;

while (!g){

g=true;

for (int kli=OrdersTotal()-1;kli>=0;kli--){

OrderSelect(kli,SELECT_BY_POS);

if

(OrderMagicNumber()==Magic_Number && OrderType()==OP_BUY && Mach<vMach && vMach<vvMach)

{

OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slippage,Pink);

g=false;

break;

}

if (OrderMag

icNumber()==Magic_Number && OrderType()==OP_SELL && m1>m2 && m11<=m21) (OrderMagicNumber()==Magic_Number && OrderType()==OP_SELL && Mach>vMach && vMach>vvMach)

{

OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slippage,Pink);

g=false;

break;

}

}

}

}

Open works but not stoploss exit.

Thanks for help.

Jo
 
 
Slakerz:
Hi guys, i've been trying to figure out how to put a StopLoss.. my EA is as below,

...

Who is this CHinGsMAroonCLK ?

As I remember, this EA is nothing else than 10p3 from elCactus, but maybe I am wrong...

Check it's thread, you will probably find what you are looking for: https://www.mql5.com/en/forum/174975

Reason: