How to code? - page 121

 
IN10TION:
:: hi! check the code inside this indicator... (for your opening time only, it's not an EA)

thanks bro....

I'll take a look

 
:: if it's always looping you have to stop calling your function every price tick coming in ... check your other code ...
fercan:
Can anyone stop this from looping and looping?
 
denis68:
matrixebiz i have done that now i can't compile my ea when i added the following lines to my ea

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 Lime

bool acsell = ac1==0 && ac22==0; // Lime changes to Red

i get 12 errors: AC variable not defined :

and i would like to thank you for the help

Well you can't just add those lines without making the other necessary changes to your EA code.

Like your CloseBuy statement would change from;

if ((AC1 < AC2)) Order = SIGNAL_CLOSEBUY;

to;

if ((ac1==0 && ac22==0)) Order = SIGNAL_CLOSEBUY;

if your going to use these type of commands;

if ((ac1==0 && ac22==0)) Order = SIGNAL_CLOSEBUY;

then you wouldn't need these;

bool acbuy = ac2==0 && ac11==0; // Red changes to Lime

bool acsell = ac1==0 && ac22==0; // Lime changes to Red

I thought you new more code than you do.

 
IN10TION:
:: if it's always looping you have to stop calling your function every price tick coming in ... check your other code ...

ok? so how do you do that? can you give me a code i can add before BEM?

 
:: BEM deals with your indicator signals right? like your pips & BE values that are calculated somewhere else in your code... well, do this comparison somewhere else... not looping every time in between your orders. I don't see the rest of your code... that's up to you...

IN10TION

fercan:
ok? so how do you do that? can you give me a code i can add before BEM?
 

I'm still struggling with counting the stop loss bars from my earlier posts.

Looking at the original code, I've got a feeling that it might be flawed. It seems to be setting the stoploss at the bar low from "x" bars back rather than the lowest over the period of the "x" bars.

It reads:

SL=iLow(Symbol(),Period(),iLowest(Symbol(),Period( ),MODE_LOW,StopLossBars,0));

I don't understand why it is using both iLow and iLowest. Would I be correct in thinking that iLowest on its own is all that is needed?

 

I also have another problem with the code of my EA. I have a line which should close a position when certain criteria are met. One of the criteria is that the position is currently losing money.

This is the line:

if ( (openPositions(OP_BUY)>0) && (OrderProfit( ) <= 0 ) && (macdnow macd_sigprevious)) {closeLong();}

The EA works in that it certainly closes losing positions when the other criteria are met. For some reason though, the EA also closes winning positions too. I guess that I'm using the OrderProfit function incorrectly.

Could somebody help please?

 

winwin

hey guys,

eeeeeee ccccht

 

Right now this indicator posts bar openings that are greater than or equal to the previous opening in Green and lower than in Red. My question is how would I change this code to make the openings that are EQUAL to the previous opening show up in YELLOW?

if( X01 >= X02 ) { color_X01 = Lime ; } else { color_X01 = Red ; }

if( X02 >= X03 ) { color_X02 = Lime ; } else { color_X02 = Red ; }

if( X03 >= X04 ) { color_X03 = Lime ; } else { color_X03 = Red ; }

if( X04 >= X05 ) { color_X04 = Lime ; } else { color_X04 = Red ; }

if( X05 >= X06 ) { color_X05 = Lime ; } else { color_X05 = Red ; }

if( X06 >= X07 ) { color_X06 = Lime ; } else { color_X06 = Red ; }

if( X07 >= X08 ) { color_X07 = Lime ; } else { color_X07 = Red ; }

if( X08 >= X09 ) { color_X08 = Lime ; } else { color_X08 = Red ; }

if( X09 >= X10 ) { color_X09 = Lime ; } else { color_X09 = Red ; }

 
:: then define every statement what it can't be & that is NOT equal... at last use the equal statement for Yellow.

IN10TION

fireslayer26:
Right now this indicator posts bar openings that are greater than or equal to the previous opening in Green and lower than in Red. My question is how would I change this code to make the openings that are EQUAL to the previous opening show up in YELLOW?

if( X01 >= X02 ) { color_X01 = Lime ; } else { color_X01 = Red ; }

if( X02 >= X03 ) { color_X02 = Lime ; } else { color_X02 = Red ; }

if( X03 >= X04 ) { color_X03 = Lime ; } else { color_X03 = Red ; }

if( X04 >= X05 ) { color_X04 = Lime ; } else { color_X04 = Red ; }

if( X05 >= X06 ) { color_X05 = Lime ; } else { color_X05 = Red ; }

if( X06 >= X07 ) { color_X06 = Lime ; } else { color_X06 = Red ; }

if( X07 >= X08 ) { color_X07 = Lime ; } else { color_X07 = Red ; }

if( X08 >= X09 ) { color_X08 = Lime ; } else { color_X08 = Red ; }

if( X09 >= X10 ) { color_X09 = Lime ; } else { color_X09 = Red ; }
Reason: