How to code? - page 253

 

Thanks again ! I will play with this right now !

CiloX

 

lot of good stuff to learn in this single thread

did apply few when I did my programming

always fun when it gone through the compiler and did our modification

I don't do EA (expert advisor coding) , so it get me really OFF when the trend don't go the way , my new code said it should or got some repaint issue( repainting could be resolved very easily by standard way of add some coding) -- have fun, I am into more blind faith way of trading, never did explore that area , as I thought people are joking when they said some other exotic thing could work, but will try to do some NEW way of thinking this week onward and then test it live later

one best way is to detect absolute U-turn i.e. No W turn or turning back [ not hard, but not easy, pretty challenging]

 

simple....? or not

hi

can any one help me plz.......am traying to make a simple indicator that show the price as rectangle in separate window.......each rectangle is the same in points as the candle stick bar.. frome high to low.......but we will ignore time factor.....the rectagels are adjacent as shown in the attached pic

i want to show only three price rectangles..befor the current price rectangle........

i tray to write a code for that but becouse am totally new to programming.....

my code is not working......iv attached it......

hope some help plz

Files:
usdchf15m.bmp  1005 kb
separate.mq4  3 kb
 
ABDI123456:
hi

can any one help me plz.......am traying to make a simple indicator that show the price as rectangle in separate window.......each rectangle is the same in points as the candle stick bar.. frome high to low.......but we will ignore time factor.....the rectagels are adjacent as shown in the attached pic

i want to show only three price rectangles..befor the current price rectangle........

i tray to write a code for that but becouse am totally new to programming.....

my code is not working......iv attached it......

hope some help plz

hi

i come with a better idea and may be simple to be write in mq4

the rectangle could be drawn in the main chart window...as in the attached

pic....take in consideration that the hight (up and law distance) of the rectangle should equal the highe and low of the candlestick......

Files:
usdchf15m_1.bmp  1005 kb
 

How-to do this??

I am using #MTF-RSI indicator, setting it to 5M on a 1M Chart. I get the desired display if I keep manually refreshing the whole indicator by dragging the indicator from the custom indicator list onto the chart every few seconds, and deleting the older indicator.

I have included the indicator and a copy of what I need to work properly in my EA idea. RefreshRate() will not update the graph plot. Creating an Offline Chart will not get the indicator to match the picture I have attached. What can I do to achieve this??

Please look at .Multi-Timeframe RSI in this picture - Stair Stepping. Help if you have a suggestion!

Thanks!

 

MA Levels into an EA

MA Levels into an EA

Hello

Could any one help me

i like to code ma band from ma indicator not ienvelope

how can I program the MA Levels(offset with any value in "- or +" for band) into an EA lines of code?

I am not talking about iEnvelope code

any help

Thx

 
Styex:
So I started writing a basic EA with one of those template generating EA builders. I seem to have gotten the premise of the EA template down, however I need a way to make the EA only enter one trade at max. Right now it keeps generating trades and causes the draw down to be rediculous. Here is the trade lot code:

//Check position

bool IsTrade = False;

for (int i = 0; i < Total; i ++) {

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {

IsTrade = True;

if(OrderType() == OP_BUY) {

//Close

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

//| Signal Begin(Exit Buy) |

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

if (CloseBuy1_1 >= CloseBuy1_2) Order = SIGNAL_CLOSEBUY;

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

//| Signal End(Exit Buy) |

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

if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);

if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");

if (!EachTickMode) BarCount = Bars;

IsTrade = False;

continue;

}

//Trailing stop

if(UseTrailingStop && TrailingStop > 0) {

if(Bid - OrderOpenPrice() > Point * TrailingStop) {

if(OrderStopLoss() < Bid - Point * TrailingStop) {

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

if (!EachTickMode) BarCount = Bars;

continue;

}

}

}

} else {

//Close

If anyone could help, it would be greatly appreciated.

I am only starting too and I'll give it a try. First check count of open orders before opening any new trade

for(int pos=0;pos<OrdersTotal();pos++)

{

OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);

if( OrdersTotal()>1) // total of open orders is more than one

{

return;

}

 

Can a Coder pleas take alook @ my indicator

I cant seem to get it to work! Any help would be much appreciated!

marius_osma.mq4

Files:
 

EA Help

I found this EA on MQL4 codebase and have been using successfully on demo. But for my live broker I need it to open the order then modify for stoploss and take profit. Can someone do this for me? I would be very grateful.

edit: I think I got it if someone could help me with unbalenced parentheses. If it helps the code had no errors then I added order modify

under all order sends and it gave the error I'm new to programming so any help would be awesome.

-Thank you

I think the problem occurs somewhere in here.

void TrailingPositions() {

double pBid, pAsk, pp;

pp = MarketInfo()OrderSymbol(), MODE_POINT);

if (OrderType()==OP_BUY) {

pBid = MarketInfo()OrderSymbol(), MODE_BID);

//BreakEven routine

if (BreakEven>0) {

if ((pBid-OrderOpenPrice()>BreakEven*pp) {

if (OrderStopLoss()-OrderOpenPrice()<0) {

ModifyStopLoss(OrderOpenPrice()+0*pp);

}

}

}

if (TrailingStop>0) {

if (pBid-OrderOpenPrice()>TrailingStop*pp) {

if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {

ModifyStopLoss(pBid-TrailingStop*pp);

return;

}

}

}

}

if (OrderType()==OP_SELL) {

pAsk = MarketInfo()OrderSymbol(), MODE_ASK);

if (BreakEven>0) {

if (OrderOpenPrice()-pAsk)>BreakEven*pp) {

if ((OrderOpenPrice()-OrderStopLoss()<0) {

ModifyStopLoss(OrderOpenPrice()-0*pp);

}

}

}

if (TrailingStop>0) {

if (OrderOpenPrice()-pAsk>TrailingStop*pp) {

if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {

ModifyStopLoss(pAsk+TrailingStop*pp);

return;

}

}

}

}

}/

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

//| Modify StopLoss |

//| Parameters: |

//| ldStopLoss - StopLoss Leve |

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

void ModifyStopLoss(double ldStopLoss) {

bool fm;

PlaySound("alert.wav");

fm=OrdModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);

}

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

Files:
 

This is the one I tried to edit myself.

Files:
themaster.mq4  33 kb
Reason: