How to code? - page 226

 

Thank you for your answer.

I understand what you want. I think I do already the same with my variable prevtime, where I check if

prevtime == Time[0]

Or is there a different to use Time[0] and Bars?

But my problem is the Close Price.

Because can I check it in the moment "Close[0]" or do I have to check it at the open price from the following bar and write "Close[1]"?

What I am thinking wrong?

 
sunshineh:
Thank you for your answer.

I understand what you want. I think I do already the same with my variable prevtime, where I check if

prevtime == Time[0]

Or is there a different to use Time[0] and Bars?

But my problem is the Close Price.

Because can I check it in the moment "Close[0]" or do I have to check it at the open price from the following bar and write "Close[1]"?

What I am thinking wrong?

Yes with Time[0] will work the same.

I don't really understand your problem with close, if you wish to use close price of current new bar eg. if the prevtime!=Time[0] will mean the new bar came, then the close[0] == open[0] == high[0] == low[0]. If for some calculations you wish to use close of other bar then you can get back to it by shifting the index like in your example Close[1] will be close of prior - CLOSED bar.

Hope it helps.

 

Can someone help me with a coding question?

I am trying to figure out how to code two particular functions for an EA.

#1: I want to have the inputs for the EA to tell it to trade between x time to y time (start time - end time).

#2: I want the EA to only take one trade per trade time (trade cycle). In other words, if the EA is only to trade from 2-4am EST and it completes a trade, I do not want the EA to open up another trade for that day/cycle.

Your help is much appreciated

 

Pyramiding help needed

Hi

I've problem with error 130.

I pyramiding with this piece of code (starts when first order was opened on technical signal)

for (count= OrdersTotal()-1; count>=0; count--){

OrderSelect(count, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() == Currencies){

if(OrderType()==OP_SELL){

if(OrderMagicNumber()==16381 && CheckMagic(16383,OP_SELL)==false && CheckMagic(16385,OP_SELL)==false ){

if(Ask <=OrderOpenPrice()-breakeven*Point)SellOrders(OP_SELL, LotsCount(1),NormalizeDouble(OrderOpenPrice(),4), NormalizeDouble(Ask,4), NormalizeDouble(OrderTakeProfit(),4), TimeToStr(Time[0]),16383);

}

if(OrderMagicNumber()==16383 && CheckMagic(16381,OP_SELL)==true && CheckMagic(16385,OP_SELL)==false)

{

if(Ask <=OrderOpenPrice()-breakeven*Point)SellOrders(OP_SELL, LotsCount(0.5),NormalizeDouble(OrderOpenPrice(),4), NormalizeDouble(Ask,4), NormalizeDouble(OrderTakeProfit(),4), TimeToStr(Time[0]),16385);

}

}

}

}

First three orders are ok when i'm testing.

Later i get error 130

You can see on image below .Please help.

Files:
error130.jpg  193 kb
 

Handling CrossOver

I'm attempting to code an EA to backtest the Gann_HiLo_Activator_v2. This indicator recalculates it's value during the course of a bar. At the end of the bar the value is set, much the same as RSI/MACD. My issue is nailing the cross.

Sometimes the bar will cross the Gann and sometimes bars DON'T cross, meaning the Open[0] or Close[0] aren't encompassing the value of the Gann line. How can I nail this cross so that the EA picks up when the price drops above or below this line. This would only need to be done once per bar, so I've been using Volume[0]>1 as a filter.

 

Hello,

I want my code to be executed every second, not every tick. How is that possible?

Thank you in advance.

 
jan100:
Hello,

I want my code to be executed every second, not every tick. How is that possible?

Thank you in advance.

Hello!

Yes you need to use SCRIPT for this instead of EA,

and in the start function use something like this:

while(true) // allways true

{

//DO ORDERS HERE OR SOMETHING

Sleep(1000);//1000 miliseconds = 1 second

}

Regards

Kale

 

Help please with maths

Deleted, I worked it out.

 

Finding end of Bar of Time Period vs. Ticks in Metatrader

The problem I'm having with coding EAs is that Metatrader simulates the indicator for each bar within the time period with ticks -- for example, with Minute 5 data, it simulates every bar instead of dealing with the end of bar for the time period like the indicators do.

Does anybody know how to deal with this -- how to make it work like indicators for the time period rather than going into each bar for the time period?

Thanks!

Andrew Haas

 

sell EA

I wanted to ask you if I have the right to sell EA which i made? Is it legal, if not what to do about? thank U and sorry for E-sh

Reason: