Ask! - page 20

 

lsma code

Doc,

Here is the source code for the lsma. Thanks for your input!

//---- indicator settings

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 Yellow

#property indicator_color2 Chartreuse

#property indicator_color3 Red

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

int width;

extern int Rperiod = 34;

extern int Draw4HowLongg = 300; // 500 // 1000

int Draw4HowLong;

int shift;

int i;

int loopbegin;

double sum[];

int length;

double lengthvar;

double tmp ;

double wt[];

int c;

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

//| Custom indicator initialization function |

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

int init()

{

//---- 2 additional buffers are used for counting.

IndicatorBuffers(5);

//---- drawing settings

SetIndexBuffer(2,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexBuffer(0,ExtMapBuffer3);

SetIndexBuffer(3,sum);

SetIndexBuffer(4,wt);

SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3);

SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);

SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);

//---- initialization done

return(0);

}

int start()

{ Draw4HowLong = Bars-Rperiod - 5;

length = Rperiod;

loopbegin = Draw4HowLong - length - 1;

for(shift = loopbegin; shift >= 0; shift--)

{

sum[1] = 0;

for(i = length; i >= 1 ; i--)

{

lengthvar = length + 1;

lengthvar /= 3;

tmp = 0;

tmp = ( i - lengthvar)*Close[length-i+shift];

sum[1]+=tmp;

}

wt[shift] = sum[1]*6/(length*(length+1));

//========== COLOR CODING ===========================================

ExtMapBuffer3[shift] = wt[shift]; //red

ExtMapBuffer2[shift] = wt[shift]; //green

ExtMapBuffer1[shift] = wt[shift]; //yellow

// for(c=loopbegin;c==shift;c++)

// {

if (wt[shift+1] > wt[shift])

{

ExtMapBuffer2[shift+1] = EMPTY_VALUE;

// ObjectCreate("smiley_face", OBJ_ARROW, 0, Time[shift], Low[shift]-Point*20);

// Print("time= ",Time[shift]);

// ObjectSet("smiley_face", OBJPROP_ARROWCODE, 242);

// ObjectSet("smiley_face", OBJPROP_COLOR , Red);

// ObjectSet("smiley_face", OBJPROP_WIDTH , 1);

// ObjectsRedraw();

//ExtMapBuffer3[shift+1] = EMPTY_VALUE;

//ExtMapBuffer3[shift+1] = EMPTY_VALUE;

}

else if (wt[shift+1] < wt[shift])

{

ExtMapBuffer1[shift+1] = EMPTY_VALUE; //-1 red/greem tight

//ExtMapBuffer3[shift+1] = EMPTY_VALUE;

}

else

{

ExtMapBuffer1[shift+1]=CLR_NONE;//EMPTY_VALUE;

ExtMapBuffer2[shift+1]=CLR_NONE;//EMPTY_VALUE;

}

}

return(0);

}

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

 

hii guyss

i want to know how to write this code into ea

rsi 14

parameter setting 30 and 70

buy

-rsi cross above line 30 from below( first the rsi should cross below line 30 from above then only cross back the line where the signal is valid)

sell

-rsi cross below line 70 from above( first the rsi should cross above line 70 from below then only cross back the line where the signal is valid)

thanks in advance

 

how to add trade time to EA??

ex: EA not trading in 14~20h and trading normal in another times !

and close all profitable trading,and hold lose trading before 14h???

thanks

(sorry for my bad english)

 
quangmach:
how to add trade time to EA??

ex: EA not trading in 14~20h and trading normal in another times !

and close all profitable trading,and hold lose trading before 14h???

thanks

(sorry for my bad english)

I am not sure but it may be opposite with timefilter, for example, after start add something like this:

if (UseHourTrade){

if ((Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {

Comment("Time for trade has not come else!");

return(0);

}

}[/CODE]

And in the settings of EA add the following:

[CODE]extern bool UseHourTrade = True;

extern int FromHourTrade = 14;

extern int ToHourTrade = 20;

But please note that the time (14 and 20) is Metatrader time (depends on the broker). Besides it depends on timeframe which you are using your EA with. For example if close bar will be at 15 so it will be from 15 till 20 irrespective of your 14 - 20. Depends on the close bars.

 
newdigital:
I am not sure but it may be opposite with timefilter, for example, after start add something like this:
if (UseHourTrade){

if ((Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {

Comment("Time for trade has not come else!");

return(0);

}

}[/CODE]

And in the settings of EA add the following:

[CODE]extern bool UseHourTrade = True;

extern int FromHourTrade = 14;

extern int ToHourTrade = 20;
But please note that the time (14 and 20) is Metatrader time (depends on the broker). Besides it depends on timeframe which you are using your EA with. For example if close bar will be at 15 so it will be from 15 till 20 irrespective of your 14 - 20. Depends on the close bars.

wow,thanks so much

and how about

and close all profitable trading,and hold lose trading before 14h???

is it possible??

 

Comment Color

Hi --

Is there a way to change the color on the indicator's comments -- the ones that show in separate windows ?

If so -- how ?

thanks

 
kiwigold:
Hi --

Is there a way to change the color on the indicator's comments -- the ones that show in separate windows ?

If so -- how ?

thanks

U can make it by using labels. Label can be placed in any place of selected window, it also can have any font u want and any colour/size etc. So U can use label as a comment place it x=20 and y=20 and set color of the font as u want.

 

counting bars past to present

Bar counting always occurs right to left (present to past) in MQL correct?

How do I achieve past to present bar counting?

For a simple example, how would I go about numbering each bar in a given month with 1 representing the first bar of the month and subsequent bars incrementing up?

Thanks for any assistance.

Bill (still caught in a loop)

 

create new objects using name and position of existing objects

One of my learning projects is going about customizing the tester.tpl which governs the chart display option for the Strateg Tester. I find the default chart style very difficult to visualize. So, I created a new template and then built a script for replacing all arrows to more attractive arrows.

However, I'd also like to grab info in the arrow names and display that as text on the chart. The arrow names include stuff like "#62 buy" or "73 sell close". That way you can look at the chart and see exactly when a particular trade # is entered/exited. I don't know why this isn't included by default with the Strategy Tester as it is with other platforms (e.g. TradeStation).

Anyway, I'd like to grab the text in question and insert new text objects just below the existing arrows on the chart. But, I'm not figuring out how to accomplish this.

How do I go about doing this?

Thanks

Bill

 
billworld2:
Bar counting always occurs right to left (present to past) in MQL correct?

How do I achieve past to present bar counting?

For a simple example, how would I go about numbering each bar in a given month with 1 representing the first bar of the month and subsequent bars incrementing up?

Thanks for any assistance.

Bill (still caught in a loop)

U should read about Date and Time functions, and use iBarShift function to get the shift of the first bar from specified month from specified timeframe.

Reason: