| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
Move Stop Once
Here is my bit of code for moving the stoploss to breakeven after a certain profit. Is there anything wrong with it?
Code:
//MoveOnce
if(MoveStopOnce && MoveStopWhenPrice > 0) {
if(Bid - OrderOpenPrice() == Point * MoveStopWhenPrice) {
OrderModify(OrderTicket(),OrderOpenPrice(), Bid - Point * MoveStopTo, OrderTakeProfit(), 0, Red);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
|
|
|||
|
People that can help:
The code for the previous bar is below: //to buy double indicatorpast = icustom(....................,1); double indicatornow = icustom(....................,0); if (close[1]<indicatorpast && close[0]>indicatornow) OpenBUY(); if (close[1]>indicatorpast && close[0]<indicatornow) OpenSELL(); but with this satatement, the expert opens positions not only when the price cross the indicator, it opens position above the indicator too. I want that the expert open position ONLY when it cross the indicator, so i tried that: //to buy double indicatorpast = icustom(....................,1); double indicatornow = icustom(....................,0); if (close[1]<indicatorpast && close[0]==indicatornow) OpenBUY(); if (close[1]>indicatorpast && close[0]==indicatornow) OpenSELL(); But this statement it is not performing. Do you know what is happen? Because i think there arent errors in the statement. The question is why is not opening at the exact point of cross when close[0]==Indicatornow? If the function would be with ==, we will prevent the open of orders above the point of crooss between the indicator and the close of the present bar but is not funtioning with this type of relationship between the variables. Do you have experimented the same problem? Abyone knows how resolve it? Thanks, again. |
|
|||
|
Quote:
|
|
|||
|
swicthing software
hi boys, I would need to turn this indicator or the trading relative sistem into language mql because this functions on metatrader 4. Am I changing broker and software, is someone able' to help me?
{Calculation of Expanded Regression Moving Average} {BEGINNING} {"-HShift" - BARS FORWARDS} DataBars:= Ref(Price,- HShift); e1:= Mov(DataBars,PeriodMA,TypeMA); e2:= Mov(e1,PeriodMA,TypeMA); e3:= Mov(e2,PeriodMA,TypeMA); e4:= Mov(e3,PeriodMA,TypeMA); e5:= Mov(e4,PeriodMA,TypeMA); e6:= Mov(e5,PeriodMA,TypeMA); c1:= -b*b*b; c2:= 3*b*b+3*b*b*b; c3:= -6*b*b-3*b-3*b*b*b; c4:= 1+3*b+b*b*b+3*b*b; MV:= c1*e6+c2*e5+c3*e4+c4*e3; {Calculation of Time of Life MV for elimination of distortion of initial values} {T3 Moving Average} e1:= Mov(Pr,PeriodMA1,TypeMA1); e2:= Mov(e1,PeriodMA1,TypeMA1); e3:= Mov(e2,PeriodMA1,TypeMA1); e4:= Mov(e3,PeriodMA1,TypeMA1); e5:= Mov(e4,PeriodMA1,TypeMA1); e6:= Mov(e5,PeriodMA1,TypeMA1); c1:= -b1*b1*b1; c2:= 3*b1*b1+3*b1*b1*b1; c3:= -6*b1*b1-3*b1-3*b1*b1*b1; c4:= 1+3*b1+b1*b1*b1+3*b1*b1; MA1:= c1*e6+c2*e5+c3*e4+c4*e3; {Trend Up and Down} UpTrend:=Mv>=MA1; DownTrend:=MA1>=Mv; {Signal Long and Short} Long:= cross(Mv,MA1) and Mv>=MA1; Short:= cross(MA1,Mv) and MA1>=Mv; {OpenBuy and CloseBuy} OpenBuy:= cross(Mv,MA1) and Mv>=MA1; CloseBuy:= cross(MA1,Mv) and MA1>=Mv; {OpenSell and CloseSell} OpenSell:= cross(MA1,Mv) and MA1>=Mv; CloseSell:= cross(Mv,MA1) and Mv>=MA1; |
|
||||
|
Quote:
__________________
|
|
|||
|
Quote:
Code:
bool IsDemo()
__________________
Need a professional MQL4 programmer? PM me |
|
|||
|
Coding "Trend Condition" with StepMA
Buy condition:
StepMA (with Colour Mode: 2) is "long" Stochastic crosses 20 from below to above Sell condition: StepMA (with Colour Mode: 2) is "short" Stochastic crosses 80 from above to below double StochCurrent = iStochastic(NULL, 0, 21, 3, 8, MODE_SMA, 0, MODE_MAIN, Bar + 0); double StochPrevious = iStochastic(NULL, 0, 21, 3, 8, MODE_SMA, 0, MODE_MAIN, Bar + 1); double TrendLong = iCustom(NULL, 0, "stepma_v7ea", 1, 1.0, 0, 0, 0, 0.0, false, 2, 0, 1, Bar + 0); double TrendShort = iCustom(NULL, 0, "stepma_v7ea", 1, 1.0, 0, 0, 0, 0.0, false, 2, 0, 2, Bar + 0); Buy if: TrendLong && StochCurrent > 20 && StochPrevious < 20 Sell if: TrendShort && StochCurrent < 80 && StochPrevious > 80 Can someone help me with the code of the "Trend Condition" in the above example, it does not work. I tried to call the buffer 1 and buffer 2 for long and short mode but I don't understand the code of this indicator. Thank you in advance! |
![]() |
| Bookmarks |
| Tags |
| candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
|
||||
| Posted By | For | Type | Date | |
| Need an experienced programmer? - Page 2 | Post #0 | Refback | 09-24-2008 07:24 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 05:22 PM |