Ask! - page 98

 

Help again

Hi All,

I've been working on an EA for what seems like an eternity. Thanks to all the people on this thread for all the help they've given me.

I am now stumped again and looking for more help. As we all know, most crossover type of signals from MA's to Stoch's don't work very well because many times it crosses at the end of the move.

What I am trying to do is use Stochastic RSI when it crosses the 50 line but only on the following bar once price has passed either the high or the low by a certain amount of pips (MinPips). My main problem is that when I track the cross, if price only reaches the MinPips on the subsequent bars after the cross but the cross stays in the same direction.

I'm trying to attach a picture to show what I am trying to do.

Point #1 is at a sell cross but since price never passes the low of that bar, no trade is taken (actually, I would like any previous trade to stay active).

Point #2 is at a buy cross but price only passes the high of the bar on the 4th bar after the cross and should be taken at that time. Any previous sell orders should be closed at this time.

I hope this works as it is the first time that I attach a picture. I apologize in advance if I messed up.

Putz

Files:
 

More information

The following is my programming where CurrDir is the current direction and that PrevDir is the previous direction so if it is not equal, then there has been a cross.

The problem is that if it does not cross on the current bar, then CurrDir and PrevDir become equal and it never goes past that bar to see if it reaches the ValHigh or ValLow.

Any help will be appreciated.

Putz

if(CurrDir != PrevDir)

{

if(CurrDir == 1)

{

ValHigh = iHigh(Symbol(),Timeframe2,1) + MinPips*Point;

if(Bid >= ValHigh)

{

return(1); //up

}

return (2);

}

if(CurrDir == 2)

{

ValLow = iLow(Symbol(),Timeframe2,1) - MinPips*Point;

if(Ask <= ValLow)

{

return(2);//down

}

return (1);

}

 

Figured out...I think

I think I finally figured out my problem. It is now almost 2:30 am and I'm exhausted so I will check it out tomorrow...

Putz

 

Is there a way to change the data format of MT4 export file

I am looking for the ASCII.csv but need the data to be in the following format;

1) separate columns (only need: time, high, low and close)

2) only for the last 1000 bars

3) reverses the order (last on top)

4) saves it in a folder that i already have on my desktop (maybe a browse function to select which one?)

Thanks in advance to anyone that might be able to help me.

 

Adding & Deleting Indicators

Can a code be written in an EA to add or delete an indicator to the trading platform???

Dave

 

I have a big trouble on management of orders....

My simple EA entry at X:59......but i have multiple entry on the same cross. My question: It's possible to check orders time entry and to compare with new order?

I want entry at x:59 only with 1 order for cross....

Someone can help me?

 
metastock:
I have a big trouble on management of orders....

My simple EA entry at X:59......but i have multiple entry on the same cross. My question: It's possible to check orders time entry and to compare with new order?

I want entry at x:59 only with 1 order for cross....

Someone can help me?

This is my solution, I hope this can help someone......

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

//| Signal Begin(Entry) |

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

if (Buy1_1 58 && check_buy==0) Order = SIGNAL_BUY;

if (Sell1_1 > Sell1_2 && Minute()>58 && check_sell==0) Order = SIGNAL_SELL;

if (Minute()==00) {check_buy=0;}

if (Minute()==00) {check_sell=0;}

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

//| Signal End |

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

//Buy

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

//if(!IsTrade) {

//Check free margin

if (AccountFreeMargin() < (1000 * Lots)) {

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (StopLossMode) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;

if (TakeProfitMode) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

check_buy=1;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy %W(#" + Magic_Number + ")", Magic_Number, 0, DodgerBlue);

if(Ticket > 0) {

if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {

Print("BUY order opened : ", OrderOpenPrice());

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

} else {

Print("Error opening BUY order : ", GetLastError());

}

}

if (EachTickMode) TickCheck = True;

if (!EachTickMode) BarCount = Bars;

return(0);

// }

}

//Sell

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

//if(!IsTrade) {

//Check free margin

if (AccountFreeMargin() < (1000 * Lots)) {

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (StopLossMode) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;

if (TakeProfitMode) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

check_sell=1;

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell %W(#" + Magic_Number + ")", Magic_Number, 0, DeepPink);

if(Ticket > 0) {

if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {

Print("SELL order opened : ", OrderOpenPrice());

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

} else {

Print("Error opening SELL order : ", GetLastError());

}

}

if (EachTickMode) TickCheck = True;

if (!EachTickMode) BarCount = Bars;

return(0);

//}

}

if (!EachTickMode) BarCount = Bars;

return(0);

}

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

 

To Metastock

I can't tell what causes check_buy to be True.

To limit to one order open, you can use, before entry:

if (OrdersTotal()==0)

Big Be

 

Coding Knowledge Questions

WHEN do you want to use a STATIC variable - what problems can it solve?

WHEN do you want to put something in the INIT() section - what problems does it solve?

Big Be

 

not sure if this has been asked befor, but is there a way to draw a line at the current time +1 hr befor and after at a certain price in an EA?

Reason: