How to code? - page 129

 

Paging MR PIP

I am new to this coding stuff. I was wondering how to replace this line of code with the LSMA. Could you help me with this task.

Trend = iMA(Symbol(), TrendTimeFrame, TrendPeriods, 0, MODE_LWMA, PRICE_CLOSE, 0);

// PrevTrend = iMACD(Symbol(), PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);

With this line of code from your LSMA_ MCAD_EMA mq4.

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

//| LSMA - Least Squares Moving Average function calculation |

//| LSMA_In_Color Indicator plots the end of the linear regression line |

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

double LSMA(int Rperiod, int shift)

{

int i;

double sum;

int length;

double lengthvar;

double tmp;

double wt;

length = Rperiod;

sum = 0;

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

{

lengthvar = length + 1;

lengthvar /= 3;

tmp = 0;

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

sum+=tmp;

}

wt = MathFloor(sum*6/(length*(length+1))/Point)*Point;

return(wt);

}

Or do I have to do something else to make this work?

 
i2trader:
I am new to this coding stuff. I was wondering how to replace this line of code with the LSMA. Could you help me with this task.

Trend = iMA(Symbol(), TrendTimeFrame, TrendPeriods, 0, MODE_LWMA, PRICE_CLOSE, 0);

// PrevTrend = iMACD(Symbol(), PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);

With this line of code from your LSMA_ MCAD_EMA mq4.

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

//| LSMA - Least Squares Moving Average function calculation |

//| LSMA_In_Color Indicator plots the end of the linear regression line |

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

double LSMA(int Rperiod, int shift)

{

int i;

double sum;

int length;

double lengthvar;

double tmp;

double wt;

length = Rperiod;

sum = 0;

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

{

lengthvar = length + 1;

lengthvar /= 3;

tmp = 0;

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

sum+=tmp;

}

wt = MathFloor(sum*6/(length*(length+1))/Point)*Point;

return(wt);

}

Or do I have to do something else to make this work?

Maybe this:

Trend = LSMA(int Rperiod, int shift);

?

 

Modifying the TakeProfit target in one order (in runtime)

Hi ,

I have one question.

When we have one open order we use the OrderModify function to trailing stop the order. In this case we modify the stoploss of the order.

Could is possible to modify the takeprofit target of one open order with OrderModify function?

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Blue);

In my case I have one open order which has one sell position open and I have take profit for example when the EURUSD currency.

If we say my take profit target is 1.4010 but my currency goes near to take profit target but the order does not closes and then the trend is reversing and I loose my order by stop loss.

You will say , if you trailstop your order you will take the smaller profit.

But is it possible to change OrderTakeProfit variable to be smaller for example 1 pip so if my currency reaches the 1.4009 and never go to 1.4010 , how do I change take profit target in runtime and make it 1.4008 to take the profit. Not trailing stop.

Thank you very much.

 

Paging MR PIP

Not quite sure what you mean with that. Do i include the code of the LSMA

in { } directly behind that statement?

 

help me please!

can you help me to create simple EA:

the rules:

pair :GBPUSD

timeframe:15menit

take profit:15 pips

stoploss :15 pips

lots :0.1

open order: sellstop(-15) and buystop(+15) from price_open in current candle

EA will open order every 15 menit,when price_open=price_high=price_low

any body help me?

 

That's quite a simple EA, why not try and write it yourself?

Lux

 
luxinterior:
That's quite a simple EA, why not try and write it yourself? Lux

thanks,

i will try it

 

Determine The Oldest Orders

Hi guys,

I would appreciate it if someone can tell me how to identify the oldest orders within an EA to enable them to be closed.

Many thanks,

G-Man

 

Compare OrderOpenTime() of each order and close the oldest.

Lux

 
luxinterior:
Compare OrderOpenTime() of each order and close the oldest. Lux

Thx.

I'll give that a try.

G-Man

Reason: