How to code? - page 328

 
mladen:
because with custom indicator you can save states (trends) between the two ticks, and when you use iMA you can not (just one example)

So theoretically it should be able to work if I replace the stocastic equator indicator with a iMA indicator in my EA programming?

Regards

Terrance

 
tkuan77:
So theoretically it should be able to work if I replace the stocastic equator indicator with a iMA indicator in my EA programming?

Regards

Terrance

Terrance

In my experience, whenever the conditions that should be met are a bit more complicated or include previous state inheriting the best thing you can do for the EA is a custom indicator with those conditions. It will help you in multiple way but 2 are maybe the most important : it will simplify your EA code (since a part of a logic will be transferred to that custom indicator) and what is probably even more important, you will be able to check "on a glance" what will be the results of such conditions (since you have an indicator that will immediately show you if entries and exits would be profitable or not)

It is just a bit more coding but gives you much more freedom and speed in testing and saves time when checking some conditions that would after all prove to be unprofitable

 
mladen:
Terrance

In my experience, whenever the conditions that should be met are a bit more complicated or include previous state inheriting the best thing you can do for the EA is a custom indicator with those conditions. It will help you in multiple way but 2 are maybe the most important : it will simplify your EA code (since a part of a logic will be transferred to that custom indicator) and what is probably even more important, you will be able to check "on a glance" what will be the results of such conditions (since you have an indicator that will immediately show you if entries and exits would be profitable or not)

It is just a bit more coding but gives you much more freedom and speed in testing and saves time when checking some conditions that would after all prove to be unprofitable

Thanks mladen, I managed to find a way around it but when testing it out the EA I noticed that my Stochastic is showing Fixed Minimum of 18.93016 and Fixed Maximum of 82.92942.

I am trying to get a Fixed Minimum of 0 and a Fixed Maximum of 100. Is there a way to get this done?

Many Thanks and regards

Terrance

 
tkuan77:
Thanks mladen, I managed to find a way around it but when testing it out the EA I noticed that my Stochastic is showing Fixed Minimum of 18.93016 and Fixed Maximum of 82.92942.

I am trying to get a Fixed Minimum of 0 and a Fixed Maximum of 100. Is there a way to get this done?

Many Thanks and regards

Terrance

Terrance

I am afraid that without an example I do not understand what do you mean by "fixed minimum" and "fixed maximum" of a stochastic. Stochastic, by its nature of calculation is bounded to 0 and 100 and only depends on the data itself and the chosen prices if it will reach those minimum and maximum (very rarely though if you use low/high price field for stochastic. Use close/close for price field and then you will be able to reach the 0 and 100)

 

Hi,

i try to code an indicator that show me the number of consecutive bars of the same direction before the actual open bars.

I have problem when i change tf and when new bars open. It not update correctly the number.

Can you help me?

Thank you

Files:
 
dasio:
Hi,

i try to code an indicator that show me the number of consecutive bars of the same direction before the actual open bars.

I have problem when i change tf and when new bars open. It not update correctly the number.

Can you help me?

Thank you

dasio

Try different logic (like the example bellow)

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 LimeGreen

#property indicator_width1 2

double count[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

int init() { SetIndexBuffer(0,count); return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

//

//

//

//

//

for(int i=limit; i>=0; i--)

{

count = count;

if (Close>Open) if (count<0) count = 1; else count +=1;

if (Close0) count = -1; else count -=1;

}

return(0);

}
 
mladen:
dasio

Try different logic (like the example bellow)

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 LimeGreen

#property indicator_width1 2

double count[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

int init() { SetIndexBuffer(0,count); return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

//

//

//

//

//

for(int i=limit; i>=0; i--)

{

count = count;

if (Close>Open) if (count<0) count = 1; else count +=1;

if (Close0) count = -1; else count -=1;

}

return(0);

}

Ok. Thank you. I will try it.

 

Ok.

Now i code what i need. Only a problem. The number is in format x.00000000 . It is possible to have it without digits like 1 , 2 ,3 ?? Thank you

Files:
 
dasio:
Ok. Now i code what i need. Only a problem. The number is in format x.00000000 . It is possible to have it without digits like 1 , 2 ,3 ?? Thank you

dasio

Simply replace

NormalizeDouble(MathAbs(count),1)[/CODE]

with

[CODE]DoubleToStr(MathAbs(count),0)
 
mladen:
dasio

Simply replace

NormalizeDouble(MathAbs(count),1)[/CODE]

with

[CODE]DoubleToStr(MathAbs(count),0)

It's correct -.-"

Thank you.

Reason: