How to code? - page 45

 

I can't quite get this right I am trying to get my ea to buy when all blue and sell when all red. The ea open and closes but not in the right place what do I need to look at.

double TML=iCustom(NULL,0,"TrendManager",TM_Period,TM_Shift,0,shift);

double TMS=iCustom(NULL,0,"TrendManager",TM_Period,TM_Shift,1,shift);

double hasOpen = iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,1,shift) ;

double hasClose = iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,0,shift) ;

double HeikenAshiOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,2,shift);

double HeikenAshiClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,3,shift);

double SDLL=iCustom(NULL,0,"Slope Direction Line",period,method,price,1,shift);

double SDLS=iCustom(NULL,0,"Slope Direction Line",period,method,price,2,shift);

buysig=false;

sellsig=false;

closebuy=false;

closesell=false;

bool Long = TML && SDLL && HeikenAshiOpen < HeikenAshiClose && hasOpen < hasClose;

bool Short = TMS && SDLS && HeikenAshiOpen > HeikenAshiClose && hasOpen > hasClose;

buysig = Long;

sellsig = Short;

closebuy=sellsig;

closesell=buysig;

 

Gidday

I have been reading alot on these threads about the ashi indicators but how do I get the Heiken_Ashi_Smoothed to show an uptrend and downtrend it seems far more difficult than first thought do I need to create 4 variables 2 for up and 2 for down as in below

double hasOpenLong=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,1,shift) ;

double hasCloseLong=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,3,shift) ;

double hasOpenShort=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,0,shift) ;

double hasCloseShort=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaPeriod2,2,shift) ;

Any help would be great

Cheers

Beno

 

Variable Storage

I have an indicator that creates objects (arrows) during certain events on my chart.

Let's say 3 arrows have popped up on the 1 min chart, and then I click on 5min and back to 1min..... the arrows have disappeared!!!

Is this a variable storage problem? Here's some code...

(above) extern int arrowCount = 1;

(if arrow should show)

ObjectCreate("Sniper ArrowDown"+arrowCount, OBJ_ARROW, 0, TimeCurrent(),Bid);

ObjectSet("Sniper ArrowDown"+arrowCount,OBJPROP_ARROWCODE,242);

ObjectSet("Sniper ArrowDown"+arrowCount, OBJPROP_COLOR,Red);

ObjectSet("Sniper ArrowDown"+arrowCount, OBJPROP_STYLE, STYLE_SOLID);

ObjectSet("Sniper ArrowDown"+arrowCount, OBJPROP_WIDTH, 1);

arrowCount++;

Any ideas??

 
dharsant:
Got it, thanks for the help!!!

Glad you figured it out.

I was just throwing some ideas, I wasn't sure if they would work or not.

I was thinking something like this so sound only played once:

bool Play_Sound;

if ((latestlatestmain >= 0) && (latestmain < 0))

{

Play_Sound=true;

}

if (Play_Sound==true)

{

PlaySound("alert2.wav");

Play_sound=false;

}

Maybe?

 

Thanks Wolfe, I was thinking along those lines too,

I ended up using something similar but using an array!

Appreciated your time mate.

For anybody who might be able to help with my new problem posted above, it'd be much appreciated.

I'm trying to have it draw arrows on my chart during a certain event, which I can get done.

But somehow I'm storing and initiating the script wrongly, as the arrows that have previously been set on the chart does not stay there (they disappear) when I click to change Timeframes.

Any Ideas?

 

Code one trade per certain time?

need help with a code?

heres how it works:

only open a certain # of order per time (lets say 3 am - 6 am) or day or week

will not open another trade even though it creates a signal within that time

 

Here is the ea that I am having with and the indi's I have called it The Abyss due to that's where I am trying to learn to code. lol

I am currently looking into these 2 errors on this site and the MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader site.

2007.10.24 21:22:24 1998.11.20 06:00 The Abyss GBPJPY,Daily: OrderSend error 130

2007.10.24 21:22:24 1998.11.20 06:00 The Abyss GBPJPY,Daily: invalid double number as parameter 6 for OrderSend function

Could some one please have a look at the code and let me know what I have done wrong and how I could fix it.

Any help would be great

Cheers

Beno

 
antone:
need help with a code?

heres how it works:

only open a certain # of order per time (lets say 3 am - 6 am) or day or week

will not open another trade even though it creates a signal within that time

so can anyone help me please?

example it will only trade one order in 5 am - 10 am but can trade again in another time..

 

When using icustom in an EA how do you determine which buffers and index's to use. e.g. if I was trying to get an up or down trend from silvertrend indicator or similar. I might not be using the right terminology but hopefully you get where I'm coming from.

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Blue

#property indicator_color2 Red

//---- input parameters

extern int RISK=3;

extern int SSP=9;

extern int CountBars=350;

//---- buffers

double val1[];

double val2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

string short_name;

//---- indicator line

IndicatorBuffers(2);

SetIndexStyle(0,DRAW_HISTOGRAM,0,2);

SetIndexStyle(1,DRAW_HISTOGRAM,0,2);

SetIndexBuffer(0,val1);

SetIndexBuffer(1,val2);

 

for this codes it will be like that :

The buffer that is used is bolded. After the buffer we have the shift.

iCustom(NULL,0,"silvertrend",RISK,SSP,CountBars,0,0);

[/CODE]

Or like this:

[CODE]

iCustom(NULL,0,"silvertrend",3,9,350,0,0);

Regards

Kale

Reason: